Lecture 24 Chapel Introduction and Overview of X10 and Fortress John Cavazos Dept of Computer & Information Sciences University of Delaware www.cis.udel.edu/~cavazos/cisc879
But before that Created a simple program for Cell Main Program Creates an array of 50 doubles (precomputeddata) Initializes the array with numbers (0 through 49) Sends each SPE (through mailbox) address of array Waits for threads to finish SPU Program Reads address of array from mailbox DMA (get) transfers array data from main memory to LS Prints out local array contents ~cavazos/project2-sample-program
Lecture 24: Overview Chapel: Cascade High-Productivity Language Developed for DARPA HPCS Program High Productivity Computing Systems Characteristics: Global-view parallel language Support for general parallelism Locality-aware Object-oriented Generic programming
Global vs Fragmented models Global-view programming model Algorithm/data structures expressed as a whole Model executes as single thread upon entry Parallelism introduced through language constructs Examples: Chapel, OpenMP, HPF Fragmented programming model Algorithms expressed on a task-by-task basis Explicit decomposition of data structures/control flow Examples: MPI, UPC, Titanium
Global vs Fragmented models Global-view languages leave detail to compiler Fragmented languages obfuscate code
Support for General Parallelism Single level of parallelism Prevelance of SPMD model MPI (very popular) Supports coarse-grained parallelism OpenMP Supports fine-grained parallelism Should support nested parallelism Should also cleanly support data/task parallelism
Data distribution and Locality Hard for compiler to do good job of these Responsibility of performance-minded programmer Language should provide abstractions to: control data distribution control locality of interacting variables
Object-oriented Programming Proven successful in mainstream languages Separating interfaces from implementation Enables code reuse Encapsulate related code and data
Generic Programming Algorithms are written without specifying types Types somehow instantiated later Latent types Compiler can infer type from program s context Variable type inferred by initialization expression Function args inferred by actual arguments at callsites If compiler cannot infer declares an error Chapel is statically-typed All types inferred (type checking done) at compile-time For performance reasons
Chapel: Data Parallelism // a 2D ARITHMETIC DOMAIN storing indices (1,1) (m,n) var D: domain(2) = [1..m, 1..n]; // an m X n array of floating point values var A: [D] float; // an INFINITE DOMAIN storing string indicies var People: domain (string); // array of integers indexed with strings in the People domain var Age: [People] int; People += John ; Age( John ) = 62; // add string John to People domain // set John s age
Chapel: Data Parallelism // FORALL over domain of tuple of integers of domain D forall ij in D { A(ij) = ; } // FORALL over domain of strings from People domain forall I in People { Age(I) = ; } // Simple Example forall I in 1..N do a(i) = b(i);
Chapel: Task Parallelism //Begin Statement spawns new task begin writeln ( output from spawned task ); writeln( output from main task ); // Cobegin Statement // synchronization happens at the end of the cobegin block cobegin { stmt1(); stmt2(); stmt3(); }
Chapel: Task Parallelism // NOTE: Parallel tasks can coordinate with sync variables var finishedmainoutput$: sync bool; begin { finishedmainoutput$; writeln ( output from spawned task ); } writeln( output from main task ); finishedmainoutput$ = true;
X10 Overview Developed at IBM X10 is an extended subset of Java Base language = Java 1.4 language Some features removed from Java language Java Concurrency -- threads, synchronized Java Arrays replaced with X10 arrays Some features added to Java language Concurrency -- async, finish, foreach, ateach, etc. Distribution -- points, distributions X10 arrays -- distributed arrays, array reductions/initializers
X10: Activites, Places & PGAS
Fortress Overview Developed at Sun Entirely new language Fortress features Targetted to scientific computing Mathematical notation Implicitly parallel whenever possible Constructs and annotations to serialize when necessary Whenever possible, implement language feature in library
Fortress Code