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

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Introduction to C Programming
Programming Languages and Paradigms
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Chapter 7: User-Defined Functions II
Programming in Visual Basic
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Chapter 9. 2 Objectives You should be able to describe: Addresses and Pointers Array Names as Pointers Pointer Arithmetic Passing Addresses Common Programming.
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
Data Parallel Languages ASC multiC Fortran 90 & HPF.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
ASC Language 1 Additional ASC Programming Comments NOTE: These are additional notes to be added to “ASC Programming” slides by Michael Scherger. Comparison.
Loops – While, Do, For Repetition Statements Introduction to Arrays
An Associative Program for the MST Problem Part 2 of Associative Computing.
ASC Programming Michael C. Scherger Department of Computer Science Kent State University September 27, 2002.
ASC Program Example Part 3 of Associative Computing Examining the MST code in ASC Primer.
Guide To UNIX Using Linux Third Edition
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Chapter 8 Arrays and Strings
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
COMPUTER SCIENCE I C++ INTRODUCTION
5.3 Machine-Independent Compiler Features
Imperative Programming
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
High-Level Programming Languages: C++
Introduction to Shell Script Programming
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
Chapter 8 Arrays and Strings
5-1 Chapter 5 The Repetition Process in VB.NET. 5-2 Learning Objectives Understand the importance of the repetition process in programming. Describe the.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Computer Science 12 Mr. Jean May 2 nd, The plan: Video clip of the day Review of common errors in programs 2D Arrays.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Chapter 7 Additional Control Structures. Chapter 7 Topics l Switch Statement for Multi-Way Branching l Do-While Statement for Looping l For Statement.
Execution of an instruction
These notes were originally developed for CpSc 210 (C version) by Dr. Mike Westall in the Department of Computer Science at Clemson.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics.
The ASC Language Part 2 of Associative Computing.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Intermediate 2 Computing Unit 2 - Software Development.
 Software Development Life Cycle  Software Development Tools  High Level Programming:  Structures  Algorithms  Iteration  Pseudocode  Order of.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Information and Computer Sciences University of Hawaii, Manoa
The Machine Model Memory
Arrays, For loop While loop Do while loop
Chapter 2 - Introduction to C Programming
Chapter 7 Additional Control Structures
Algorithm Discovery and Design
Introduction to C Programming
Presentation transcript:

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

Parallel & Distributed Computing2 Contents ASC Programming Language Multi-C Language Fortran 90 and High Performance Fortran

Parallel & Distributed Computing3 References for Chapter Jerry Potter, Associative Computing - A Programming Paradigm for Massively Parallel Computers, Plenum Publishing Company, Jerry Potter, ASC Primer, 42 pages, posted at parallel website under downloads at Ian Foster, Designing and Building Parallel Programs: Concepts and Tools for Parallel Software Engineering, Addison Wesley, 1995, Online at “The multiC Programming Language”, Preliminary Documentation, WaveTracer, PUB , Jan “The multiC Programming Language”, User Documentation, WaveTracer, PUB , June 1992.

The ASC Language Michael C. Scherger & Johnnie Baker Department of Computer Science Kent State University October 2003

Parallel & 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

Parallel & 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

Parallel & 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 < shapes.dat  % asc2.exe –e shapes.iob shapes.out

Parallel & Distributed Computing8 Basic Program Structure Main program_name  Constants;  Variables;  Associations;  Body; End;

Parallel & 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”.

Parallel & 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.

Parallel & 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.

Parallel & 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]

Parallel & 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

Parallel & Distributed Computing14 Operator Notation Relational Operators  “less than” is denoted by.lt. or <  “equal” is denoted.eq. or =  “not equal” is denoted by.ne. or != Logical Operators  “not” is denoted by.not. or !  “or” is denoted by.or. OR ||  “and” is denoted by.and. or && Arithmetic Operators  Addition is denoted by +  Multiplication is denoted by *  Division is denoted by / For more information, see page 40 of ASC Primer

Parallel & 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.

Parallel & 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

Parallel & 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 of ASC Primer for more information

Parallel & 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 of ASC Primer.

Parallel & 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

Parallel & 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

Parallel & 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 st nd rd10

Parallel & 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.

Parallel & 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.

Parallel & 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 of ASC Primer for more details.

Parallel & 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.

Parallel & 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.

Parallel & 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.

Parallel & Distributed Computing28 Input / Output Parallel read statement  See page 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.

Parallel & 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.

Parallel & Distributed Computing30 Input / Output The msg command  Page 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.

Parallel & 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: Don’t need to use associate statement to associate dummy with used. Omission causes no problems as no check is currently made.

Parallel & 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[$].

Parallel & 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 of ASC Primer for more information

Parallel & 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.