#include <stdio.h>
#include "mpi.h"
int main(int argc, char* argv[])
{
int myid, numprocs,namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv); // Initialize the MPI environment
// Get the size of process in the current process group
MPI_Comm_size( MPI_COMM_WORLD, &numprocs );
// Get the rank of the current process
MPI_Comm_rank( MPI_COMM_WORLD, &myid );
// Get the name of the processor which is running this process
MPI_Get_processor_name(processor_name, &namelen);
// Say hello world
printf("Hello World! Process %d of %d on %s\n", myid, numprocs,
processor_name);
MPI_Finalize(); // Exit the MPI environment
return 0;
}
MPI运行效果图
VC6运行效果图