This example shows how to run a MPI program on a single computer using CMake.
- OpenMPI
Open a terminal and type:
sh run.sh
A typical output should look like this one.
javier@perca:~/ > sh run.sh
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found MPI_C: /usr/lib/openmpi/lib/libmpi.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libhwloc.so
-- Found MPI_CXX: /usr/lib/openmpi/lib/libmpi_cxx.so;/usr/lib/openmpi/lib/libmpi.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libhwloc.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/javier//build
Scanning dependencies of target application-MPI
[100%] Building C object CMakeFiles/application-MPI.dir/main.c.o
Linking C executable application-MPI
[100%] Built target application-MPI
Hello world from process 7 of 8
Hello world from process 4 of 8
Hello world from process 1 of 8
Hello world from process 2 of 8
Hello world from process 0 of 8
Hello world from process 3 of 8
Hello world from process 5 of 8
Hello world from process 6 of 8
javier@perca:~/ >