This material is part of the course Practical Introduction to Parallel Programming and meant for educational purposes only.
Course slides can be downloaded here.
You can use this sandbox to test your code making use of one or multiple parallelizatio techniques at the same time, e.g., MPI-OpenMP or MPI-Threads.
If you want to run this or any other exercise on your own computer you can download this archive, which provides a framework for building your code with CMake. You have to ensure that you have installed a C/C++ compiler that supports OpenMP (e.g. GCC or Intel's C/C++ compiler), an MPI library (e.g. OpenMPI), a POSIX Threads implementation, and CMake.
Once you downloaded the pipp2023.zip
archive please run the following under Linux / macOS:
$> unzip pipp2023.zip $> cd pipp2023 $> mkdir build $> cd build $> CC=gcc-11 CXX=g++-11 cmake .. -- The C compiler identification is GNU 11.1.0 -- The CXX compiler identification is GNU 11.1.0 ... -- Configuring done -- Generating done -- Build files have been written to: <PATH-TO>/pipp2023/build $> make -j4
The line CC=gcc-11 CXX=g++-11 cmake ..
configures a build with the GNU C/C++ compiler version 11. If you simply type cmake ..
CMake will try to find the system's default compiler. You can explicitly enable/disable MPI, OpenMP, Threads by adding one or more of the switches
cmake .. -DUSE_MPI=ON/OFF -DUSE_OpenMP=ON/OFF -DUSE_Threads=ON/OFF
If you have more than 4 cores you can compile your codes with more than 4 processes in parallel, e.g. make -j8
.
Under Windows, CMake can be used to generate project files for Microsoft Visual Studio. Please check the documentation.
If you want to add new source files, simply copy them into one of the different directories introduction
, mpi
, openmp
, threads
, and projects
and run cmake ..
again. Make sure that no two files have the same name.