X10X10Jonathan LeeJonathan LeeDaniel LeeDaniel LeeWhat is X10?What is X10?Programming language designed for high-Programming language designed for high-performance, high-productivityperformance, high-productivitycomputing on high-end computerscomputing on high-end computersDevelopment at IBM ResearchDevelopment at IBM ResearchObject oriented (OO) LanguageObject oriented (OO) LanguageIntended to have simple and clearIntended to have simple and clearsemanticssemanticsKey Design DecisionsKey Design DecisionsIntroduce a new programming languageIntroduce a new programming languageUse the Java programming language as aUse the Java programming language as astarting pointstarting pointAdded aAdded a few new things, took away some oldfew new things, took away some oldthingsthingsUses partitioned global address spaceUses partitioned global address space(PGAS) model(PGAS) modelProgramming Model: PlacesProgramming Model: PlacesCollection of data objects and activities (think ofCollection of data objects and activities (think ofas threads) that operate on the dataas threads) that operate on the dataCan think of as a Can think of as a ““virtual shared-memory multi-virtual shared-memory multi-processorprocessor””Every X10 activity runs in a placeEvery X10 activity runs in a placeCan get reference to the current place with theCan get reference to the current place with theconstant constant hereherePlaces are ordered and the methods Places are ordered and the methods next()next() and andprevprev()() can be used to cycle through them can be used to cycle through themProgramming Model: PGASProgramming Model: PGASX10 uses PGAS (Partitioned GlobalX10 uses PGAS (Partitioned GlobalAddress Space)Address Space)Each place has Each place has ““partitionpartition”” of address of addressspacespaceScalar objects are allocated completely at aScalar objects are allocated completely at asingle placesingle placeElements of an array may be distributedElements of an array may be distributedacross multiple placesacross multiple placesX10 Activities, Places, PGASX10 Activities, Places, PGASDiagramDiagramX10 activities, places, and PGASProgramming Construct: Programming Construct: asyncasyncCan create asynchronous activities usingCan create asynchronous activities usingasyncasync statementstatementasync async (P) S(P) SSpawns an activity at the place designated bySpawns an activity at the place designated byP to execute SP to execute SCreates parallelism!Creates parallelism!Can be thought of as extremelyCan be thought of as extremelylightweight threadslightweight threadsAsync Async ExampleExampleSystem.out.System.out.printlnprintln(1);(1);async async (place.next()) {(place.next()) {System.out.System.out.printlnprintln(2);(2);}}System.out.System.out.printlnprintln(3);(3);Data Structures: RegionData Structures: RegionRegions:Regions: Just a collection of pointsJust a collection of pointsSimple contiguous ranges: [0:N]Simple contiguous ranges: [0:N]Multidimensional blocks: [0:N,0:M]Multidimensional blocks: [0:N,0:M]Can create arbitrary regions of any dimensionCan create arbitrary regions of any dimensionData Structures: RegionData Structures: RegionRegion Operations:Region Operations:Union: Union: R1 || R2R1 || R2Intersection: Intersection: R1 && R2R1 && R2Set Difference: Set Difference: R1 - R2R1 - R2Data Structures: DistributionsData Structures: DistributionsDistributions: MapsDistributions: Maps each point in a regioneach point in a regionto a specific placeto a specific placeBuilt inBuilt in Distributions:Distributions:Constant:Constant: all points map to a single placeall points map to a single placeBlock: contiguous sets ofBlock: contiguous sets of points equally dividedpoints equally dividedamong placesamong placesCyclic: Every Nth pointCyclic: Every Nth point assigned to a placeassigned to a placeData Structures: DistributionsData Structures: DistributionsDistribution Operations:Distribution Operations:Also include:Also include:Range Restriction: Range Restriction: D | RD | RPlace Restriction: Place Restriction: D |D | PPIndexing for places: Indexing for places: D[p]D[p]Example: Block Star DistributionExample: Block Star DistributionDistribution d = dist.factory.block([0,N],places);Distribution d = dist.factory.block([0,N],places);Distribution Distribution blockstar blockstar = [0:-1,0:-1]->here;= [0:-1,0:-1]->here;for (point p : d) {for (point p : d) {blockstar blockstar = = blockstar blockstar || [0:M]->d[i];|| [0:M]->d[i];}}Data Structures: ArraysData Structures: ArraysX10 Arrays:X10 Arrays:Takes a distribution as a parameterTakes a distribution as a parameter to assign data toto assign data toplacesplacesExample: Example: double[.]double[.] data = new double[[0:N]->here];data = new double[[0:N]->here];Built in and user defined functionsBuilt in and user defined functions supportsupportScansScansOverlaysOverlaysReductionsReductionsLiftingLiftingInitializationInitializationProgramming Construct: forProgramming Construct: forfor (point p : R) Sfor (point p : R) SPointwise Pointwise for for sequential iteration by a singlefor for sequential iteration by a singleactivityactivityEquivalent toEquivalent to Java Java foreach foreach loopsloopsννExample:Example:Region r =Region r = [0:N];[0:N];intint[.] x = new [.] x = new intint[[r-r->here];>here];for (pointfor (point p(i) : r) {p(i) : r) {x[p] =x[p] = i * 2;i * 2;}}Programming Construct:Programming Construct:foreachforeachforeach foreach (point p : R) S(point p : R) SFor parallel iteration in a single placeFor parallel iteration in a single placeνν≡≡ for (point p : R) for (point p : R) async async (here) { S }(here) { S }ννExample:Example:Region r =Region r = [0:N];[0:N];intint[.] x = new [.] x = new intint[[r-r->here];>here];foreach foreach (point(point p(i) : r) {p(i) : r) {x[p] =x[p] = i * 2;i * 2;}}Programming Construct:Programming Construct: ateachateachateach ateach (point p : D) S(point p : D) SFor parallel iteration across multiple placesFor parallel iteration across multiple placesνν≡≡ for (point p : D) for (point p : D) async async (D[p]) { S }(D[p]) { S
View Full Document