You review the design of a module of an online banking system. The module will provide real-time statistics
related to payments made by the users. The module must support 1,000 concurrent users. A new instance
named Thread1 is created for every user who accesses the banking system. The following pseudocode
represents the design of the module. (Line numbers are included for reference only.) 01 var amount = 0 //
shared variable represents amount of transfer 02 var credit = 0 // shared variable represents total credit 03 var
debit = 0 // shared variable represents total debit 04 Thread1:
05 reads userInput from console
06 amount = userInput
07 creates new Thread2 instance and runs it
08 creates new Thread3 instance and runs it
09 Thread2:
10 value = amount
11 if (value > 0) debit = debit - value
12 Thread3:
13 value = amount
Lead your way to certificates!
14 if (value > 0) credit = credit + value
A new instance named Thread1 is created for every user who accesses the banking system. You need to
ensure that no data race occurs when the module runs.
What should you do?
You are designing a parallel algorithm for an OpenMP application. You write the following pseudocode to
represent the sequential logic of the algorithm. (Line numbers are included for reference only.)
01 do i = 1, m
02 do j = 1, n
03 x = i/real(m)
04 y = j/real(n)
05 depth[j, i] = calculate_val(x, y)
06 enddo
07 enddo
You need to identify the variables that must be declared as private variables to correctly parallelize the
algorithm. Which set of variables should you select?
An application contains the following code segment. (Line numbers are included for reference only.)
01 double compute(int n){
02 int i;
03 double h, x, sum, pi;
04 h = 1.0 / (double) n;
05 sum = 0.0;
Lead your way to certificates!
07 for (i=1; i <= n; i++) {
08 x = h * ((double)i - 0.5);
09 sum += (1.0 / (1.0 + x*x));
10 }
11 pi = h * sum;
12 return pi;
13 }
You want to parallelize the loop inside the sequential function by using OpenMP. You need to ensure that when
multiple threads of the function run, the loop meets the following requirements:
It has no data races.
It computes the correct result.
Which line of code should you insert at line 06?
You create an OpenMP application by using Microsoft Visual C++. The application includes an OpenMP parallel
region. The region contains the following code
Lead your way to certificates!
segment.
(Line numbers are included for reference only.)
01 int global=0;
03 void PerformComputation(int value)
04 {
05 //...
07 global+=value;
08 }
10 int _tmain(int argc, _TCHAR* argv[])
11 {
12 #pragma omp parallel for
13 for(int count=0;count<100;count++)
14 {
15 //...
16 PerformComputation(count);
17 //...
18 }
19 }
For each iteration that updates the global variable, the for loop must call the PerformComputation method.
You need to ensure that shared memory access to the global variable is protected.
Which line of code should you insert at line 06?
You create an OpenMP application by using Microsoft Visual C++. You are debugging the application. You set
a breakpoint to the first line of code inside an OpenMP parallel region.
The first thread execution inside the OpenMP parallel region must be debugged. You need to ensure that you
debug the first thread in isolation when you step through the code.
What should you do?
You create an OpenMP application by using Microsoft Visual C++. You are debugging your application. The
OpenMP parallel region contains a breakpoint. When the breakpoint is reached, the Threads window displays
multiple threads that are running. You need to identify the point of execution of all threads in the OpenMP
parallel region. What should you do?
You create an OpenMP application using Microsoft Visual C++. The application includes the following code
segment. (Line numbers are included for reference only.)
01 omp_set_num_threads(10);
03 #pragma omp parallel
04 {
05 //Other code
06 #pragma omp barrier
07 int amount;
08 //Other code
09 amount++;
10 }
You set a breakpoint at line 09 and then start the debugger. You need to change the value for the variable
amount to 15 only for the main thread.
What should you do?
You create a job that has two tasks named Task1.exe and Task2.exe. Task2.exe requires a minimum of two
cores for optimum performance of your application. The corporate policy states that you must use a maximum
of four cores to run a job. You need to write a Windows PowerShell script to use all the four cores to run the job
every time the job is run.
Which script should you use?