mpi example
Sure! Here is an example of MPI code in C:
#include <stdio.h>
#include <mpi.h>
int main(int argc, char argv) {
MPI_Init(&argc, &argv);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello from process %d of %d\n", rank, size);
MPI_Finalize();
return 0;
}
This is a simple MPI program that prints out the rank and size of each process. It demonstrates the basic usage of MPI functions like MPI_Init
, MPI_Comm_rank
, and MPI_Comm_size
.