#include #include using namespace std; int main(int argc, char * argv[]) { MPI_Init(&argc, &argv); // Get the rank and size in the original communicator int worldRank, worldSize; MPI_Comm_rank(MPI_COMM_WORLD, &worldRank); MPI_Comm_size(MPI_COMM_WORLD, &worldSize); int color = worldRank / 4; // Determine color based on row // Split the communicator based on the color and use the // original rank for ordering MPI_Comm rowComm; MPI_Comm_split(MPI_COMM_WORLD, color, worldRank, &rowComm); int rowRank, rowSize; MPI_Comm_rank(rowComm, &rowRank); MPI_Comm_size(rowComm, &rowSize); cout << "World Rank/size " << worldRank << "/" << worldSize; cout << " Row Rank/size " << rowRank << "/" << rowSize << endl; MPI_Comm_free(&rowComm); MPI_Finalize(); return 0; }