MPI (Basic)

// mpi1.cpp

//

 

#include
“stdafx.h”

#include
“stdio.h”

#include
“stdlib.h”

#include
“mpi.h”

 

 

int
_tmain(int
argc, char* argv[])

{

    MPI_Init(&argc, &argv);

    int rank = 0;

    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    if (rank == 0) {

        char message[] = “message data”;

        MPI_Send(message, _countof(message), MPI_CHAR, 1, 0, MPI_COMM_WORLD);

    }

    else {

        char recv[100];

        MPI_Recv(recv, 100, MPI_CHAR, 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

    }

    return 0;

}

 

References

https://www.open-mpi.org/doc/current/

https://blogs.technet.microsoft.com/windowshpc/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program/