Data Parallel Languages (Chapter 4) ASC Language multiC Fortran 90 and HPF

Download Data Parallel Languages (Chapter 4) ASC Language multiC Fortran 90 and HPF

Post on 22-Dec-2015




2 download

Embed Size (px)


<ul><li> Slide 1 </li> <li> Data Parallel Languages (Chapter 4) ASC Language multiC Fortran 90 and HPF </li> <li> Slide 2 </li> <li> Parallel &amp; Distributed Computing2 Contents ASC Programming Language Multi-C Language Fortran 90 and High Performance Fortran </li> <li> Slide 3 </li> <li> Parallel &amp; Distributed Computing3 References for Chapter 4 11. Jerry Potter, Associative Computing - A Programming Paradigm for Massively Parallel Computers, Plenum Publishing Company, 1992 18. Jerry Potter, ASC Primer, 42 pages, posted at parallel website under downloads at 19. Ian Foster, Designing and Building Parallel Programs: Concepts and Tools for Parallel Software Engineering, Addison Wesley, 1995, Online at 20. The multiC Programming Language, Preliminary Documentation, WaveTracer, PUB-00001-001-00.80, Jan. 1991. 21. The multiC Programming Language, User Documentation, WaveTracer, PUB-00001-001-1.02, June 1992. </li> <li> Slide 4 </li> <li> The ASC Language Michael C. Scherger &amp; Johnnie Baker Department of Computer Science Kent State University October 2003 </li> <li> Slide 5 </li> <li> Parallel &amp; Distributed Computing5 Contents Software Location and Installation Basic Program Structure Data Types and Variables Operator Notation Control Structures Looping Accessing Values in Parallel Variables Associations and Setscope Input and Output Performance Monitor Subroutines and other topics </li> <li> Slide 6 </li> <li> Parallel &amp; Distributed Computing6 Software Compiler and Emulator DOS/Windows, UNIX (Linux) WaveTracer Connection Machine PACL/downloads.htm PACL/downloads.htm Use any text editor. Careful on moving files between DOS and UNIX! ASC Compiler ASC Emulator Anyprog.asc Anyprog.iob Standard I/OFile I/O -e -wt -cm -e -wt -cm </li> <li> Slide 7 </li> <li> Parallel &amp; Distributed Computing7 Software Example: To compile your program % asc1.exe e shapes.asc To execute your program % asc2.exe e shapes.iob % asc2.exe e shapes.iob &lt; shapes.dat % asc2.exe e shapes.iob shapes.out </li> <li> Slide 8 </li> <li> Parallel &amp; Distributed Computing8 Basic Program Structure Main program_name Constants; Variables; Associations; Body; End; </li> <li> Slide 9 </li> <li> Parallel &amp; Distributed Computing9 Basic Program Structure Example: Consider an ASC Program that computes the area of various simple shapes (circle, rectangle, triangle). Here is an example shapes.ascshapes.asc Here is the data shapes.datshapes.dat Here is the shapes.outshapes.out NOTE: Above links are only active during the slide show. </li> <li> Slide 10 </li> <li> Parallel &amp; Distributed Computing10 Data Types and Variables ASC has eight data types int (i.e., integer), real, hex (i.e., base 16), oct (i.e., base 8), bin (i.e., binary), card (i.e., cardinal), char (i.e., character), logical, index. Card is used for unsigned integer data. Variables can either be scalar or parallel. Scalar variables are in the IS. Parallel variables are in the cells. Parallel variables have the suffix [$] at the end of the identifier. Can specify the length (in bits) of parallel variables. Default word length works fine for most programs. </li> <li> Slide 11 </li> <li> Parallel &amp; Distributed Computing11 Comparison of Logical Parallel and Index Parallel A index parallel variable selects a single scalar value from a parallel variable. A logical parallel variable L is normally used to store a logical value resulting from a search such as L[$] = A[$].eq. B[$] ASC implementation simplifies usage by not formally distinguishing between the two. The correct type, based on usage, should be selected to improve readability. </li> <li> Slide 12 </li> <li> Parallel &amp; Distributed Computing12 Array Dimensions A parallel variable can have up to 3 dimensions First dimension is $, the parallel dimension The array numbering is zero-based, so the declaration int parallel A[$,2] creates the following 1dimensional variables: A[$,0], A[$,1], A[$,2] </li> <li> Slide 13 </li> <li> Parallel &amp; Distributed Computing13 Mixed Mode Operations Mixed mode operations are supported and their result has the natural mode. For example, given declarations int scalar a, b, c; int parallel p[$], q[$], r[$], t[$,4]; index parallel x[$], y[$]; then c = a + b is a scalar integer q[$] = a + p[$] is a parallel integer variable a + p[x]is a integer value r[$] = t[x,2]+3*p[$] is a parallel integer variable x[$] = p[$].eq. r[$]is an index parallel variable More examples are given on page 9-10 of ASC Primer </li> <li> Slide 14 </li> <li> Parallel &amp; Distributed Computing14 Operator Notation Relational Operators less than is denoted or &lt; equal is denoted.eq. or = not equal is denoted or != Logical Operators not is denoted by.not. or ! or is denoted by.or. OR || and is denoted by.and. or &amp;&amp; Arithmetic Operators Addition is denoted by + Multiplication is denoted by * Division is denoted by / For more information, see page 40 of ASC Primer </li> <li> Slide 15 </li> <li> Parallel &amp; Distributed Computing15 The IF-THEN-ELSE Control Structure Scalar version similar to sequential programming languages. Either executes either the body of the IF or the body of the ELSE. Parallel version normally executes both bodies. First finds the responders for the conditional If there are any responders, the responding PEs execute the body of the IF. Next identifies the non-responders for the conditional If there are non-responders, those PEs executes the body of the ELSE. This control structure is also a masking operation. </li> <li> Slide 16 </li> <li> Parallel &amp; Distributed Computing16 Parallel IF-THEN-ELSE Example if A[$].eq. 2 then A[$] = 5; else A[$] = 0; endif; A[$] BEFORE MASK BEFORE A[$] AFTER THEN MASK ELSE MASK 21510 51001 30300 21510 11001 </li> <li> Slide 17 </li> <li> Parallel &amp; Distributed Computing17 IF-THEN-ELSENANY Control Statement Similar to the IF-THEN-ELSE, except that only one of the two bodies of code is executed. First the logical expression following the IF is evaluated If there is at least one responder, then the responding processors execute the body of the IF. However, if there were no responders to the logical expression, then all processors that were initially active at the start of this command execute the body of the ELSENANY EXAMPLE IF A[$].GE. 2 and A[$].LT. 4 THEN C[$] = 1; ELSENANY C[$] = 9; ENDIF; See page 16-17 of ASC Primer for more information </li> <li> Slide 18 </li> <li> Parallel &amp; Distributed Computing18 ANY-ELSENANY Control Statement If there is at least one responder, then all active processors (i.e., ones active at the start of this command) execute the statements inside the any-block. If there are no responders, then all active processors execute the statements inside the elsenany block any can be used alone (without the elsenany) Example any A[$].eq. 10 B[$] =11; elsenany B[$] = 100; endany; For more information, see pages 17-19 of ASC Primer. </li> <li> Slide 19 </li> <li> Parallel &amp; Distributed Computing19 Looping Sequential looping Loop-Until See example on page 20 of ASC Primer Sequential looping is an infrequently used operation in ASC Two types of parallel looping constructs: Parallel For-Loop Conditional is evaluated only once. Example on page 21. Parallel While-Loop Conditional is evaluated every iteration. Example on page 21-22. </li> <li> Slide 20 </li> <li> Parallel &amp; Distributed Computing20 For construct Often used when a process must be repeated for each cell that satisfies a certain condition. The index variable is available throughout the body of the for statement The index value of for is only evalulated initially Parallel For Loop </li> <li> Slide 21 </li> <li> Parallel &amp; Distributed Computing21 For Loop Example Example: sum = 0; for x in A[$].eq. 2 sum = sum + B[$]; endfor x; Trace for example: A[$]B[$]xloopsum 1100 2211 st 2 2312 nd 5 140 2513rd10 </li> <li> Slide 22 </li> <li> Parallel &amp; Distributed Computing22 While Loop Unlike the for statement, this construct re-evaluates the logical conditional statement prior to each execution of the body of the while. The bit array resulting from the evaluation of the conditional statement is assigned to the index parallel variable on each pass. The index parallel array is available for use within the body each loop. The body of the while construct will continue to be executed until there are no responders (i.e., all zeros) in the index parallel variable. Study example and trace in the ASC Primer carefully to make sure you understand the while construct. </li> <li> Slide 23 </li> <li> Parallel &amp; Distributed Computing23 Get Statement Used to retrieve a value from a specific field in a parallel variable satisfying a specific conditional statement. Example: get x in tail[$].eq. 1 val[x] = 0; endget x; Study the trace of this example in on page 24 of ASC Primer to make sure its action is clear. </li> <li> Slide 24 </li> <li> Parallel &amp; Distributed Computing24 Next Statement Similar to get statement, except next updates the set of responders each time it is called. Unlike get, two successive calls to next is expected to select two distinct processors (and two distinct association records). Can be used inside a loop to sequentially process each responder. See page 22-23 of ASC Primer for more details. </li> <li> Slide 25 </li> <li> Parallel &amp; Distributed Computing25 Maximum and Minimum Values The maxval and minval functions maxval returns the maximum value of the specified items among the active responders. Similarly, minval returns the minimum value. Example: if (tail[$].neq. 1) then k = maxval( weight[$]); endif; See trace of example on pg 27 of ASC Primer. The maxdex and mindex functions Returns the index of one processor where a maximum or minimum occurs. If maximum/minimum value occurs at more than one location, an arbitrary selection is made as to which index is returned. </li> <li> Slide 26 </li> <li> Parallel &amp; Distributed Computing26 The associate statement Creates an association between parallel variables and a parallel logical variables. There are no structs or classes in ASC. See earlier example in sample program. See page 8 of ASC primer for more information. </li> <li> Slide 27 </li> <li> Parallel &amp; Distributed Computing27 Setscope Endsetscope Commands Resets the parallel mask register setscope jumps out of current mask setting to another mask setting. One use is to reactivate currently inactive processors. Also allow an immediate return to a previously calculated mask, such as an association. Is an unstructured command such as go-to and jumps from current environment to a new environment. Use sparingly endsetscope resets mask to preceding setting. See example on page 15 of ASC Primer. </li> <li> Slide 28 </li> <li> Parallel &amp; Distributed Computing28 Input / Output Parallel read statement See page 12-13 of ASC Primer Illustrated in earlier example program. Must have an ASSOCIATE statement. Input file must have blank line at end of data set. Input is from interactive user input or from a data file identified in the command line. </li> <li> Slide 29 </li> <li> Parallel &amp; Distributed Computing29 Input / Output Parallel print statement See page 13 in the ASC primer Illustrated in earlier example program. Must have an ASSOCIATE statement. Does not output user specified strings. I.e. User text messages. Only outputs the values of parallel variables. </li> <li> Slide 30 </li> <li> Parallel &amp; Distributed Computing30 Input / Output The msg command Page 13-14 of ASC Primer Used to display user text messages. Used to display values of scalar variables. Used to display a dump of the parallel variables. </li> <li> Slide 31 </li> <li> Parallel &amp; Distributed Computing31 Scalar variable input Static input can be handled in the code. Also, define or deflog statements can be used to handle static input. Dynamic input is currently not supported directly, but can be accomplished as follows: Reserve a parallel variable dummy (of desired type) for input. Reserve a parallel index variable used. Values to be stored in scalar variables are first read into dummy using a parallel-read and then transferred using get or next to the appropriate scalar variable. Example: read dummy[$] in used[x]; get x in used[$] scalar-variable = dummy[x]; endget x; NOTE: Dont need to use associate statement to associate dummy with used. Omission causes no problems as no check is currently made. </li> <li> Slide 32 </li> <li> Parallel &amp; Distributed Computing32 Dynamic Storage Allocation allocate is used to identify a processor whose association record is currently unused. Will be used to store a new association record Creates a parallel index that points to the processor selected release is used to de-allocate storage of specified records in an association Can release multiple records simultaneously. Example: Example: char parallel node[$], parent[$]; logical parallel tree[$]; index parallel x[$]; associate node[$], level[$], parent[$] with tree[$];...... allocate x in tree[$] node[x] = B endallocate x; release parent[$].eq. A from tree[$]. </li> <li> Slide 33 </li> <li> Parallel &amp; Distributed Computing33 Performance Monitor Keeps track of number of scalar and parallel operations. It is turned on and off using the perform statement PERFORM = 1; PERFORM = 0; The number of scalar and parallel operations can be printed using the msg command MSG Number of scalar and parallel operations are PA_PERFORM SC_PERFORM ; The ASC Monitor is important for evaluation and comparison of various ASC algorithms and software. See Pg 30-31 of ASC Primer for more information </li> <li> Slide 34 </li> <li> Parallel &amp; Distributed Computing34 Additional Features Restricted subroutine capability is currently available See call and include on pg 25-6 of ASC Primer. Use of personal pronouns and articles in ASC make code easier to read and shorter. See page 29 of ASC Primer. </li> </ul>


View more >