slides8d-1111

slides8d-1111 - Programming with Shared Memory Specifying...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
slides 8d-1 Programming with Shared Memory Specifying parallelism Performance issues ITCS4145/5145, Parallel Programming B. Wilkinson Fall 2010.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 We have seen OpenMP for specifying parallelism Programmer decides on what parts of the code should be parallelized and inserts compiler directives (pragma’s) Whatever programming environment we use where the programmers explicitly says what should be done in parallel, the issue for the programmer is deciding what can be done in parallel. Let us use generic language constructs for parallelism.
Background image of page 2
3 par Construct For specifying concurrent statements: par { S1; S2; . . Sn; } Says one can execute all statement S1 to Sn simultaneously if resources available, or execute them in any order and still get the correct result
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Question How is this specified in OpenMP?
Background image of page 4
5 forall Construct To start multiple similar processes together: forall (i = 0; i < n; i++) { S1; S2; . . Sm; } Says each iteration of body can be executed simultaneously if resources available, or in any order and still get the correct result. The statements of each instance of body executed in order given. Each instance of the body uses a different value of i.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Example forall (i = 0; i < 5; i++) a[i] = 0; clears a[0] , a[1] , a[2] , a[3] , and a[4] to zero concurrently.
Background image of page 6
7 Question How is this specified in OpenMP?
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Dependency Analysis To identify which processes could be executed together. Example Can see immediately in the code forall (i = 0; i < 5; i++) a[i] = 0; that every instance of the body is independent of other instances and all instances can be executed simultaneously. However, it may not be that obvious. Need algorithmic way of recognizing dependencies, for a parallelizing compiler .
Background image of page 8
9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10
Background image of page 10
Can use Berstein’s conditions at: Machine instruction level inside processor – have logic to detect if conditions satisfied (see computer architecture course) At the process level to detect whether two processes can be executed simultaneously (using the inputs and outputs of processes). Can be extended to more than two processes but number of conditions rises – need every input/out combination checked. For three statements, need how many conditions
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 35

slides8d-1111 - Programming with Shared Memory Specifying...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online