The APGAS Library Resilient Parallel and Distributed Programming in - - PowerPoint PPT Presentation

the apgas library
SMART_READER_LITE
LIVE PREVIEW

The APGAS Library Resilient Parallel and Distributed Programming in - - PowerPoint PPT Presentation

The APGAS Library Resilient Parallel and Distributed Programming in Java 8 Olivier Tardieu IBM Research This material is based upon work supported by the U.S. Department of Energy, Office of Science, Advanced Scientific Computing Research


slide-1
SLIDE 1

The APGAS Library

Resilient Parallel and Distributed Programming in Java 8

Olivier Tardieu IBM Research

This material is based upon work supported by the U.S. Department of Energy, Office of Science, Advanced Scientific Computing Research under Award Number DE-SC0008923.

slide-2
SLIDE 2

the X10 language

  • the language

= ??? The Equation

2

slide-3
SLIDE 3

the X10 language

  • the language

= the APGAS library The Equation

3

slide-4
SLIDE 4

Take Away

The APGAS library supports § resilient, elastic, parallel, distributed programming on clusters of JVMs § for the Java programmer § as a pure Java library Compared to X10 § same programming model

§ places, lightweight tasks, finish, global heap

§ X10 offers a lot more

§ syntax, type system, C++/CUDA backend, program analysis and optimization

§ for a price

§ new language, 200K LOCs implementation

http://x10-lang.org/software/download-apgas/latest-apgas-release.html

4

§ for the Scala programmer § as an embedded DSL in Scala

slide-5
SLIDE 5

Outline § API and Examples § Implementation § Experimental evaluation § Roadmap § Demo

5

slide-6
SLIDE 6

HelloWorld

§ X10

finish for (place in Place.places()) { at(place) async Console.OUT.println("Hello from " + here); }

§ APGAS

import static apgas.Constructs.*; import apgas.Place; finish( () -> { for (final Place place : places()) { asyncAt(place, () -> System.out.println("Hello from " + here()) ); } } );

6

Java 8 no-arg lambdas imported static methods

slide-7
SLIDE 7

Compiling and Running

§ Compile

§ javac -cp .:apgas.jar HelloWorld.java

§ Run with one place

§ java -cp .:apgas.jar:hazelcast.jar HelloWorld

§ Run with 4 places (single host)

§ set “apgas.places” system property at launch time

§ java -Dapgas.places=4 -cp .:apgas.jar:hazelcast.jar HelloWorld

§ set “apgas.places” system property in main

§ System.setProperty(Configuration.APGAS_PLACES, "4");

§ Configure desired parallelism (typically not required)

§ set “apgas.threads” property

7

slide-8
SLIDE 8

Core API

§ class Constructs

§ static void finish(Job f); § static void async(Job f); § static void asyncAt(Place p, SerializableJob f); § static void at(Place p, SerializableJob f); // equivalent to finish async § static <T extends Serializable> T at(Place p, SerializableCallable<T> f); § static Place here(); § static Place place(int id); § static List<? extends Place> places();

§ class Place

§ Place(int id); § int id();

§ functional interfaces Job, SerializableJob, SerializableCallable<T>

8

slide-9
SLIDE 9

Fibonacci

§ X10

static def fib(n:long) { if (n<2) return n; val v0:long; val v1:long; finish { async { v0 = fib(n-2); } v1 = fib(n-1); } return v0+v1; } // static def/use analysis // compiles to C++ and Java // stack-allocated locals (C++) // autoboxing (Java)

§ APGAS

static long fib(final long n) { if (n<2) return n; final long v[] = new long[2]; finish(() -> { async(() -> v[0] = fib(n-2)); v[1] = fib(n-1); }); return v[0]+v[1]; } // no static analysis // Java only // heap-allocated locals // explicit boxing

9

slide-10
SLIDE 10

Global Heap (PGAS)

§ GlobalID

§ globally unique handle

§ GlobalRef<T>

§ union of X10’s GlobalRef and PlaceLocalHandle § explicit distributed collection of objects (zero or one per place) § dereferencing a global reference returns the object local to the place (if any)

§ PlaceLocalObject

§ implicit distributed collection of objects (zero or one per place) § “scoped static field” § serializing one object in the collection serializes the collection id § deserialization resolves the id to the local object

§ PlaceLocalArray<T>, PlaceLocalIntArray…

10

slide-11
SLIDE 11

Example

class Foo extends PlaceLocalObject { int value; public Foo() { value = here().id + 42; } public static void main(String[] args) { System.setProperty(Configuration.APGAS_PLACES, "2"); final Foo foo = Foo.make(places(), () -> new Foo()); System.err.println(here() + ": " + foo.value); // place(0): 42 at(place(1), () -> { System.err.println(here() + ": " + foo.value); // place(1): 43 }); } }

11

slide-12
SLIDE 12

Implementation Highlights

§ Java 8 lambdas

§ like X10: immutable environment capture, unlike X10: no autoboxing of vars

§ Java fork/join thread pool and scheduler

§ APGAS twist: ad hoc thread creation and disposal policies

§ Java serialization

§ unlike X10: must implement java.io.Serializable, but type inference for lambdas § APGAS twist: compiler warnings to mitigate runtime serialization exceptions

§ Hazelcast

§ fault-tolerant, elastic cluster management § in-memory resilient key value store

§ Resilient and non-resilient modes

12

2K LOCS

slide-13
SLIDE 13

Unbalanced Tree Search

13

§ Count nodes in dynamically generated tree

§ separable cryptographic random number

§ Representative of a class of irregular applications

§ computationally intensive § locality insensitive

§ APGAS implementation follows from X10

§ lifeline-based global work-stealing

§ Configuration

§ 16 servers

§ 2 Quad-Core AMD Opteron(tm) Processor 2356 § gigabit ethernet network

§ 1 APGAS place per server

slide-14
SLIDE 14

Unbalanced Tree Search

14

6.39 6.09 6.45 6.25 6.06 6.00 6.10 6.20 6.30 6.40 6.50 16 32 48 64 80 96 112 128 Million tree nodes/s/worker Workers APGAS code Sequential Java code X10 code

slide-15
SLIDE 15

Roadmap

§ 1.0 release available today

§ library and examples § Eclipse integration

§ Short term

§ tutorial § cloud integration

§ Yarn launcher

§ Scala bindings

§ Longer term

§ Spark integration § resilient elastic APGAS § deeper Eclipse integration

15

slide-16
SLIDE 16

Fibonacci in Scala APGAS def def fibonacci(i: Int) : Long = { if if(i <= 1 ) i else else { var var a,b = 0L finish finish { async async { a = fibonacci(i – 2) } b = fibonacci(i – 1) } a + b } }

16

slide-17
SLIDE 17

Take Away

The APGAS library supports § resilient, elastic, parallel, distributed programming on clusters of JVMs § for the Java programmer § as a pure Java library Compared to X10 § same programming model

§ places, lightweight tasks, finish, global heap

§ X10 offers a lot more

§ syntax, type system, C++/CUDA backend, program analysis and optimization

§ for a price

§ new language, 200K LOCs implementation

http://x10-lang.org/software/download-apgas/latest-apgas-release.html

17

§ for the Scala programmer § as an embedded DSL in Scala

slide-18
SLIDE 18

DEMO