PrepAway - Latest Free Exam Questions & Answers

Author: seenagape

What should you do?

You create an OpenMP application by using Microsoft Visual C++. You write the following code segment to efficiently calculate the total number of odd and even numbers in the array data in parallel. (Line numbers are included for reference only.)

01 int data[100000];
02 //Initialize array values
03 int even=0;
04 int odd=0;
05 #pragma omp parallel for
06 for(int cnt=0;cnt<100000;cnt++)
07 {
09 if(data[cnt]%2==0)
10 {
12 even++;
13 }
14 else
15 {
17 odd++;
18 }
20 }
21 std::cout << "even: " << even << ", odd: " << odd << "n";

You discover that the code segment does not compute the correct result when it is executed with more than one thread. You need to ensure that the application computes the result correctly regardless of the number of threads.
What should you do?

Which code segment should you insert at line 06?

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

01 int data;
02 //Assign value to variable data
03 MPI_Request myRequest;
04 MPI_Isend(&data, 1, MPI_INT, 0, 1, MPI_COMM_WORLD, &myRequest);
05 //Other calculations not involving variable data
06 //Alter variable data

You discover that at times, an incorrect value is sent to rank 0. You need to ensure that the variable data is ready to be modified at line 08.
Which code segment should you insert at line 06?

What should you do?

You create an OpenMP application by using Microsoft Visual C++.

You write the following code segment. (Line numbers are included for reference only.)

01 int addIndices(int a,int b)
02 {
03 return a+b;
04 }
05 int _tmain(int argc, _TCHAR* argv[])
06 {
07 int i, j;
08 int a[10][10];
09 #pragma omp parallel for
10 for (i = 0; i < 10; i++)
11 for (j = 0; j < 10; j++)
12 {
14 a[i][j] = addIndices(i, j);
15 }
16 }

The code segment stores some incorrect data in the array. You need to ensure that the code segment stores only correct data in the array.
What should you do?

Which code segment should you write?

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

01 #pragma omp parallel for
02 for(int i=0;i<10000;i++)
03 {
04 //Do some calculations
06 }
07 #pragma omp parallel for
08 for(int j=0;j<22000;j++)
09 {
10 //Do some calculations
11 }

Both for loops are mutually independent and no load imbalance occurs. You need to rewrite the code segment to remove any overhead and to improve the performance of the application.

Which code segment should you write?

Which command should you run?

You administer a Windows HPC Server 2008 cluster. Diagnostic tests are successfully executed on the cluster. Users report that jobs have failed occasionally during the last week. You discover that the jobs have failed when they were sent to a node group named DataManagement. You need to identify the nodes in the node group that have failed. Which command should you run?

Which code segment should you use to replace lines 04 and 05?

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

01 #pragma omp parallel for
02 for(int i=0;i<50000;i++)
03 {
04 doWorkA(i);
05 doWorkB(i);
06 }

The doWorkA and doWorkB methods are independent method calls. You need to optimize performance while protecting the method calls against multiple thread access.Which code segment should you use to replace lines 04 and 05?

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?