12
Chapel Chapel Chao, Dave, Esteban Chao, Dave, Esteban

Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

Embed Size (px)

Citation preview

Page 1: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

ChapelChapel

Chao, Dave, EstebanChao, Dave, Esteban

Page 2: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

OverviewOverview

High-Productivity Computing Systems (HPCS, Darpa)High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade High Cray’s Cascade High ProductivityProductivity Language (CHaPeL) Language (CHaPeL)

ProgrammabilityProgrammability PerformancePerformance PortabilityPortability RobustnessRobustness

Want to solve the “Parallel Programming Problem”Want to solve the “Parallel Programming Problem” Simplify initial creation of parallel programsSimplify initial creation of parallel programs Support evolution of programs to high performance, production-quality Support evolution of programs to high performance, production-quality

codecode Emphasize generalityEmphasize generality

Motivating features:Motivating features: Multithreaded programmingMultithreaded programming Locality-aware programmingLocality-aware programming Object-oriented programmingObject-oriented programming Generic programming and type inferenceGeneric programming and type inference

Page 3: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

Key FeaturesKey Features

Abstractions for data and task Abstractions for data and task parallelismparallelism Data: domains, arrays, iteratorsData: domains, arrays, iterators Task: cobegin, atomic transactions, Task: cobegin, atomic transactions,

synchronization variablessynchronization variables Global view of computation, dataGlobal view of computation, data

Page 4: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

DomainsDomains

Page 5: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade
Page 6: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

CobeginCobegin

Starts several statements at once, blocks until they finishStarts several statements at once, blocks until they finish1.1. Quicksort(low, high, data){Quicksort(low, high, data){2.2. if( …/* too small */){if( …/* too small */){3.3. … … // sort here// sort here4.4. return;return;5.5. }}6.6. pivot = computePivot(lo, hi, data);pivot = computePivot(lo, hi, data);7.7. cobegin { //below happen in parallelcobegin { //below happen in parallel8.8. Quicksort(lo, pivot, data);Quicksort(lo, pivot, data);9.9. Quicksort(pivot, high, data);Quicksort(pivot, high, data);10.10. }}11.11. // blocks here until both Quicksort calls above finish// blocks here until both Quicksort calls above finish12.12. }}

Page 7: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

Atomic TransactionsAtomic Transactions

“atomic” statements like database transaction If two start at once and collide, one rolled back

and retried Occur as if rest of the program were suspended

1. atomic {2. newnode.next = insertpt;3. newnode.prev = insertpt.prev;4. insertpt.prev.next = newnode;5. insertpt.prev = newnode;6. }

Page 8: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

SynchronizationSynchronization

Single assignment variables – block on access if not Single assignment variables – block on access if not assignedassigned

1. function Tree.sum() {2. if(is_leaf) return value;3. single var x ;4. begin x = left.sum;5. var y = right.sum;6. return x+y;7. }

syncsync variables – only have one value at a time variables – only have one value at a time Read consumes value, makes variable undefinedRead consumes value, makes variable undefined If variable undefined, reads blockIf variable undefined, reads block Write creates value, defines variableWrite creates value, defines variable If variable defined, writes blockIf variable defined, writes block

Page 9: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

Serial StatementSerial Statement

serial <expr> <block>; Allows serialization of parallel statements under certain conditions

1. class Tree {2. var is_leaf : boolean;3. var left : Tree;4. var right : Tree;5. }6. iterator Tree.walk : Tree {7. if(is_leaf) yield(this);8. else9. serial(height <= 10)10. cobegin {11. yield(left.walk);12. yield(right.walk);13. }14. }

Page 10: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

Generic Programming Generic Programming FeaturesFeatures

Can have type variables and parametersCan have type variables and parameters1. class Stack {2. type t;3. var buffsize:integer= 128;4. var data: [1..buffsize] t;5. functiontop(): t { … };6. }

“Type query” vars1. function copyN(data: [?D] ?t; n: integer): [D] t {2. var newcopy: [D] t;3. forall i in1..n do newcopy(i) = data(i);4. return newcopy;5. }

Elided types1. function inc(val): {2. var tmp = val;3. return tmp + 1;4. }

Page 11: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

LocalesLocales

A locale is a unit of storage and A locale is a unit of storage and processingprocessing

Specify at run-time the number of localesSpecify at run-time the number of locales Can specify at which locale objects are Can specify at which locale objects are

stored, computations performedstored, computations performed Can specify locale by a variableCan specify locale by a variable

1.1. on TaskLocalA do taskA()on TaskLocalA do taskA() Can specify locale by data locationCan specify locale by data location

1. forall i in D on(a(i)) do ...

Page 12: Chapel Chao, Dave, Esteban. Overview High-Productivity Computing Systems (HPCS, Darpa) High-Productivity Computing Systems (HPCS, Darpa) Cray’s Cascade

ReferencesReferences

Slides heavily influenced bySlides heavily influenced by http://chapel.cs.washington.edu/ChapelFhttp://chapel.cs.washington.edu/ChapelF

orAHPCRC.pdforAHPCRC.pdf http://chapel.cs.washington.edu/specifichttp://chapel.cs.washington.edu/specific

ation.pdfation.pdf http://http://

chapel.cs.washington.edu/ChapelForLCPchapel.cs.washington.edu/ChapelForLCPC.pdfC.pdf