Which code segment should you insert at line 14?

You create a parallel application by using Microsoft Visual C++. You write the following code segment. (Line numbers are included for reference only.)

01 MPI_Init(&argc, &argv);
02 int a[10], myrank;
03 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
04 if (myrank==0)
05 {
06 //Do some work
07 MPI_Send(&a, 10, MPI_INT, 1, 1, MPI_COMM_WORLD); 08 }
09 else if(myrank==1)
10 {
11 int b[10];
12 MPI_Status status;
13 MPI_Request req;
15 }

Data sent by rank 0 must be received by rank 1.
You need to ensure that while rank 1 is waiting to receive data, the process continues to call an external
method for additional tasks.
Which code segment should you insert at line 14?

You create a parallel application by using Microsoft Visual C++. You write the following code segment. (Line numbers are included for reference only.)

01 MPI_Init(&argc, &argv);
02 int a[10], myrank;
03 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
04 if (myrank==0)
05 {
06 //Do some work
07 MPI_Send(&a, 10, MPI_INT, 1, 1, MPI_COMM_WORLD); 08 }
09 else if(myrank==1)
10 {
11 int b[10];
12 MPI_Status status;
13 MPI_Request req;
15 }

Data sent by rank 0 must be received by rank 1.
You need to ensure that while rank 1 is waiting to receive data, the process continues to call an external
method for additional tasks.
Which code segment should you insert at line 14?

A.
MPI_Irecv(&b, 10, MPI_INT, 0, 1, MPI_COMM_WORLD,&req);
while(req!=MPI_REQUEST_NULL)
{
//Call external method
}

B.
MPI_Irecv(&b, 10, MPI_INT, 0, 1, MPI_COMM_WORLD,&req);
while(req!=MPI_REQUEST_NULL)
{
//Call external method
MPI_Wait(&req,&status);
}

C.
MPI_Irecv(&b, 10, MPI_INT, 0, 1, MPI_COMM_WORLD,&req);
int flag;
MPI_Test(&req,&flag,&status);
while(!flag)
{
//Call external method
MPI_Test(&req,&flag,&status);
}

D.
MPI_Recv(&b, 10, MPI_INT, 0, 1, MPI_COMM_WORLD,&status);
int flag;
MPI_Test(&req,&flag,&status);
while(!flag)
{
//Call external method
MPI_Test(&req,&flag,&status);
}



Leave a Reply 0

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