# 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@ gmail.com 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@ gmail.com facebook.c om/dbkrbnrj

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