mpi 等级和大小
示例
要获取通信器的大小(例如MPI_COMM_WORLD)和其中的本地进程的排名,请执行以下操作:
int rank, size; int res; MPI_Comm communicator = MPI_COMM_WORLD; res = MPI_Comm_rank (communicator, &rank); if (res != MPI_SUCCESS) { fprintf (stderr, "MPI_Comm_rank failed\n"); exit (0); } res = MPI_Comm_size (communicator, &size); if (res != MPI_SUCCESS) { fprintf (stderr, "MPI_Comm_size failed\n"); exit (0); }