Mcse 011(Mca 5)Ignou

Topics: OpenMP Pages: 6 (1946 words) Published: May 14, 2013
Question 1: Determine the dependency relations among the following instructions: I1: a = b+c; I2:b=a+d I3: e =a/f; A.J.Bernstein has elaborated the work of data dependency and derived some conditions based on which we can decide the parallelism of instructions or processes. Bernstein conditions are based on the following two sets of variables: i) The Read set or input set RI that consists of memory locations read by the statement of instruction I1. ii) The Write set or output set WI that consists of memory locations written into by instruction I1. The sets RI and WI are not disjoint as the same locations are used for reading and writing by SI. The following are Bernstein Parallelism conditions which are used to determine whether statements are parallel or not: 1) Locations in R1 from which S1 reads and the locations W2 onto which S2 writes must be mutually exclusive. That means S1 does not read from any memory location onto which S2 writes. It can be denoted as: R1∩W2= 2) Similarly, locations in R2 from which S2 reads and the locations W1 onto which S1 writes must be mutually exclusive. That means S2 does not read from any memory location onto which S1 writes. It can be denoted as: R2∩W1= 3) The memory locations W1 and W2 onto which S1 and S2 write, should not be read by S1 and S2. That means R1 and R2 should be independent of W1 and W2. It can be denoted as : W1∩W2= To show the operation of Bernstein’s conditions, consider the following instructions of sequential program:

I1:a = b+c; I2:b =a+d; I3:e = a/f;
Now, the read set and write set of I1, I2 and I3 are as follows: R1 = {b, c} W1 = {a} R2 = {a, d} W2 = {b} R3 = {a, f} W3 = {e} Now let us find out whether I1 and I2 are parallel or not: R1∩W2= R2∩W1= W1∩W2=

For Q ueries : dbkr.bnrj@ facebook.c om/dbkrbnrj

That means I1 and I2 are independent of each other: Similarly for I1 || I3 , R1 ∩W3 = R3 ∩W1 ≠ W1 ∩W3 = Hence I1 and I3 are not independent of each other. For I2 || I3 , R2 ∩W3 = R3 ∩W2 = W3 ∩W2 = Hence, the dependency relations among the following: Instructions I1 and I2 are both flow dependent and anti-dependent both. Instruction I2 and I3 are output dependent and instructions I1 and I3 are independent.

For Q ueries : dbkr.bnrj@ facebook.c om/dbkrbnrj

Question 2: Write the syntax of the following compiler directives in OpenMP: (a) Parallel (b) Sections (c) Master:

OpenMP is a compiler directive based standard developed in the late 1990s jointly by a group of major computer hardware and software vendors. It is portable across many popular platforms including UNIX and Windows NT platforms. The OpenMP FORTRAN API was released on October 28, 1997 and the C/C++ API was released in late 1998. We shall discuss only about C/C++ API. The OpenMP API uses the fork-join model of parallel execution. As soon as an OpenMP program starts executing it creates a single thread of execution, called the initial thread. The initial thread executes sequentially. As soon as it gets a parallel construct, the thread creates additional threads and works as the master thread for all threads. All of the new threads execute the code inside the parallel construct. Only the master thread continues execution of the user code beyond the end of the parallel construct. There is no restriction on the number of parallel constructs in a single program. When a thread with its child threads encounters a work-sharing construct, the work inside the construct is divided among the members of the team and executed co-operatively instead of being executed by every thread. Execution of the code by every thread in the team resumes after the end of the work-sharing construct. Synchronization constructs and the library routines are available in OpenMP to co-ordinate threads and data in parallel and work-sharing constructs. Each OpenMP directive starts with #pragma omp. The general syntax is: #pragma omp directive-name [Set of clauses] where omp is an OpenMP keyword. There may...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Mca Ignou Essay
  • Essay on Time table for IGNOU Exams
  • Ignou Essay
  • ignou Essay
  • Ignou Research Paper
  • Ignou Essay
  • Ignou Essay
  • Gtu Mca Sem 5 Mc Essay

Become a StudyMode Member

Sign Up - It's Free