July 2017
Intermediate to advanced
244 pages
6h 33m
English
A simple example of MPI communication is the sending of a single value from one process to another. In order to do this, one needs to use the following listed code and run the compiled binary to start at least two processes. It does not matter whether these processes run locally or on two compute nodes.
The following code was gratefully borrowed from http://mpitutorial.com/tutorials/mpi-hello-world/:
#include <mpi.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { // Initialize the MPI environment. MPI_Init(NULL, NULL); // Find out rank, size. int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); int world_size; MPI_Comm_size(MPI_COMM_WORLD, &world_size); // We are assuming at least 2 processes ...Read now
Unlock full access