Which code segment should you insert at line 02?

You develop a parallel application that will be deployed on a Windows HPC Server 2008 cluster. You write the following code segment. (Line numbers are included for reference only.)

01 MPI_Init(&argc, &argv);
03 {
04 // program part for rank 0
06 }
06 else
07 {
08 // program part for all other ranks
09 }
10 MPI_Finalize();

You need to ensure that the code in the rank 0 section only executes on the process that has a rank of 0.
Which code segment should you insert at line 02?

You develop a parallel application that will be deployed on a Windows HPC Server 2008 cluster. You write the following code segment. (Line numbers are included for reference only.)

01 MPI_Init(&argc, &argv);
03 {
04 // program part for rank 0
06 }
06 else
07 {
08 // program part for all other ranks
09 }
10 MPI_Finalize();

You need to ensure that the code in the rank 0 section only executes on the process that has a rank of 0.
Which code segment should you insert at line 02?

A.
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size > 0)

B.
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size == 0)

C.
int rank
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)

D.
char hostName[MPI_MAX_PROCESSOR_NAME];
int resultlen;
MPI_Get_processor_name(hostName, &resultlen);
char masterName[] = "rank0";
if (strcmp(masterName, hostName) != 0)



Leave a Reply 0

Your email address will not be published. Required fields are marked *