+ All Categories
Home > Documents > Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote...

Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote...

Date post: 25-Aug-2020
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
129
Ibis tutorial & hands-on session Jason Maassen [email protected] Thursday 13 October 2005 Sophia Antipolis
Transcript
Page 1: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis tutorial&

hands-on session

Jason [email protected]

Thursday 13 October 2005Sophia Antipolis

Page 2: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Overview

● Philosophy / design / implementation● Why do we need Ibis ?● Ibis design● Performance● Cool features

Page 3: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Overview

● Programming models● IPL (bare bones Ibis)● RMI (remote invocation)● GMI (group communication)● Satin (divide and conquer)● MPJ (MPI to Java binding)

● Hands-on session● How to roll your own Ibis applications

Page 4: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

We are interested in...

● Parallel applications on “the Grid”● Single site runs

● Grid == big collection of clusters● Only communicate within cluster ● Use fast local network (Myrinet/Infiniband/...)

● Multi site runs● Grid == big processor pool

● Communicate between clusters ● Use regular network & internet

Page 5: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

So why Ibis?

● Ideally, grid computing should be “fire and forget”● Develop application locally● Submit to some grid scheduler which

● Finds some suitable site(s)● Transfers your application and data to the

sites, and runs it. ● Returns the result

Page 6: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Problems

● Lots of problems● Resource selection● Data transfer● Security and authentication● ...● Heterogeneity

● Globus, Gridlab (GAT), etc.

Page 7: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Problems● Grids are heterogeneous:

● Intel / PowerPC / Mips / Arm / ...● Windows / Linux / Unix / OSX / ...● Different OS/library/tool versions

● Compiled (C/MPI) apps. huge pain:● Need executable for every combination of

CPU/network/OS/libraries etc.● Makes 'fire & forget' runs really hard...

Page 8: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Solution (partly)

● So, we use Java instead C or Fortran● No recompilation required● Runs (almost) anywhere

● Doesn't work on supercomputers (Hitachi SR8000, IBM BlueGene, etc.)

● Most sites have clusters anyway● Acceptable performance

● But ... only part of the solution!

Page 9: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

How about 'portable' communication?

● Class libraries are portable, but ...● Sockets are too low-level● RMI model/performance is limited

● Most parallel libraries not portable ...● MpiJava requires native code

● recompilation● no malleable runs

Page 10: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis

● Solution: Ibis !● A “run-anywhere” communication library● Just send it along with your application!

● Flexible communication models● More than just unicast communication

● More about this later● Malleability & Fault-Tolerance

● Change number of machines during the run

Page 11: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis

● Portability vs. performance ● On a single site run you often want to use

the fast local network

● Ibis allows specialized implementation● Designed for Myrinet, Infiniband, etc.● Usually use native code● Installed in advance

● not portable● cannot be shipped with application

Page 12: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis

● As a result, there may be multiple Ibis' available on a site● Automatically choose 'best' at startup● Based on requirements specified by

● Application & user (using properties)

● Not every impl. needs all features● Pick one at startup that suits your needs....

Page 13: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Design

Ibis Portability Layer (IPL)

Page 14: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Design

TCP UDP P2P

Ibis Portability Layer (IPL)

Page 15: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Design

TCP P2P GM Panda MPI

Ibis Portability Layer (IPL)

UDP

Page 16: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Design

TCP P2P GM Panda MPI

RMI Satin RepMIGMI MPJ

Ibis Portability Layer (IPL)

UDP

Page 17: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Design

TCP P2P GM Panda MPI

RMI Satin RepMIGMI MPJ

Ibis Portability Layer (IPL)

UDP

Page 18: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Design

TCP P2P GM Panda MPI

Application

RMI Satin RepMIGMI MPJ

Ibis Portability Layer (IPL)

UDP

Page 19: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Design

TCP P2P GM Panda MPI

ProActive

RMI Satin RepMIGMI MPJ

Ibis Portability Layer (IPL)

Application

UDP

Page 20: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Portability Layer

● Basic Ibis interface● Reasonably simple (5 classes & 12 interf.)

● Contains methods for● Loading an Ibis● Malleability (adding & removing machines)● Connection handling● Communication primitives (low-level)

Page 21: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

IPL Communication

● 'Low-level' communication model● Unidirectional pipes● Two end points● Connection oriented

sendport

receiveport

Page 22: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Send & receive ports

● Can be connected in arbitrary ways

Page 23: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Send & receive ports

● Can be connected in arbitrary ways● One to one (unicast) ...

Page 24: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Send & receive ports

● Can be connected in arbitrary ways● ... one to many (multicast) ...

Page 25: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Send & receive ports

● Can be connected in arbitrary ways● ... many to one ...

Page 26: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Send & receive ports

● Can be connected in arbitrary ways● ... or some combination!

Page 27: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Send & receive ports

● Advantages:● Very simple & abstract model● Easy to implement using TCP/UDP/MPI/etc.● Allows multicast, many-to-one, etc.

● Useful for parallel programs● Allows efficient implementation

● Can be implemented using efficient low-level primitives (i.e., mpi-broadcast)

● Other models do prevent this (e.g., RMI)

Page 28: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Send & receive ports

● Disadvantage:● Simplicity may cause some overhead... ● Example: need two pairs for RPC / RMI

Page 29: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Port Types

● All ports have a type consisting of:● Unique name ● Set of properties, e.g.:

● Supports unicast and multicast ● Is Reliable● Is fifo ordered● Supports object serialization● ...

Page 30: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Port Types

● Defined at runtime● Specify name and set of properties

● Types must match when connecting!

Xexceptio

n!

Page 31: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Port Types

● Defined at runtime● Specify name and set of properties

● Types must match when connecting!

√ok!

Page 32: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Port Types

● Forces programmer to specify how each communication channel is used● Prevents bugs

● Exception when contract is breached

● Allows efficient impl. to be selected● Unicast only ?● Bytes only ? ● Saves a lot of overhead!

Page 33: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Connection setup

● Need the ReceivePortIdentifier● Uniquely identifies a receiveport

● Created when ReceivePort is created

● May also have unique name (String)● Human-readable (usually)● Use for registry lookup

Page 34: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Connection setup

Create ReceivePort“server”

Page 35: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Connection setup

Registry

register(“server”)

Page 36: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Connection setup

Registry

lookup(“server”)

Page 37: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Connection setup

Registry

ID

Page 38: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Connection setup

Registry

connect

Page 39: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Connection setup

● Advantage of ReceivePortIdentifiers● Hides implementation details● Independent of

● IP-addresses● Host names ● Port numbers ● MPI-ranks● etc...

● Abstract way of addressing

Page 40: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● Ports communicate using 'messages'

● Contain read or write methods for ● Primitive types (byte, int, ...)● Object ● Arrays slices (partial write / read in place)

● Unlimited message size

Page 41: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● Get WriteMessage from SendPort

WM

Page 42: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● Write data into WriteMessage

WM

Page 43: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● Finish the WriteMessage

WM

Page 44: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● Data is send to ReceivePort

Page 45: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● ReceivePort produces ReadMessage● Explicit receive or callback (upcall)

RM

Page 46: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● Read data from ReadMessage

RM

Page 47: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● Finish the ReadMessage

RM

Page 48: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages

● Done!

Page 49: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Messages or streams ?

● Message size is unlimited● Data may be forwarded at any time● Both S. & R. messages alive at same time● There's streaming!

RMWM

Page 50: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Restrictions

● Must write and read data in same order

● A port can have only one message 'alive' at a time

● Not thread safe (but ports are)

● If there is no receiver, the sender may block (there may be flow-control)

Page 51: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Serialization

● Ibis supports 4 types of serialization● Bytes (i.e., no serialization at all)● Data (only primitive types/arrays)● Sun (standard Sun serialization)● Ibis (efficient Ibis serialization)

● To select one of the last two use 'Object'

Page 52: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis Serialization

● Based on bytecode-rewriting ● Adds serialization and deserialization code

to serializable types● Prevents reflection overhead during

(de-)serialization● Has fallback mechanism for non-rewritten

classes

● Future work: runtime rewriting

Page 53: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Short Recap

● First create PortType● PortType creates Send & ReceivePort

● Type is checked when connecting

● Use ReceivePortID's to connect● Abstact addressing

● Use Messages to communicate● Allows streaming● 4 types of serialization

Page 54: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Creating an Ibis

● First step in application● IPL is only abstract classes & interfaces

● Ibis selects implementation for you● Multiple may be available● Selected on the basis of properties

● Specify the needs of the application

Page 55: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Selecting an Ibis

Properties: closed world data ser. explicit rec. unicast

Ibis.createIbis(...)

Page 56: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Selecting an Ibis

Properties: closed world data ser. explicit rec. unicast

Ibis.createIbis( )

local disk

.jarapplication

jar files

TCPIbis MPI-IbisPandaIbis

Find all Ibisimplementations

Page 57: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Selecting an Ibis

Properties: closed world data ser. explicit rec. unicast

local disk

.jarapplication

jar files

TCPIbis MPI-IbisPandaIbis

Select 'best'implementation

Ibis.createIbis( )

Page 58: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Selecting an Ibis

Properties: closed world data ser. explicit rec. unicast

return newinstance

MPI-Ibisclass

Ibis

Ibis.createIbis( )

Page 59: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Properties

● Usual Java properties● Set of key-value pairs

● “serialization”, “object”● “communication”, “OneToOne” ● “worldmodel”, “open”

● Very flexible● good and bad

Page 60: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Properties

● Good● Introduce features without IPL changes

● Just add more properties● Allows impl. specific properties

● Bad● No compile time checks (only runtime)

● Just strings● Sensitive to typos

Page 61: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

ExampleProperty Values Description

Worldmodel Open Support malleabilityClosed Fixed set of machines

Serialization ByteDataObject

Communication OneToOneOneToManyManyToOneExplicitReceive Support explicit rec.AutoMessageUpcalls Automatic callbackPollingMessageUpcalls Callback triggered by

pollingConnectionUpcalls Callback when machines

join or leave

Page 62: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Example

IbisProperty TCP Panda MPI

Worldmodel Open Closed ClosedSerialization B/D/O B/D/O B/D/O

Communication OO/OM/MO OO/OM/MO OO/OM/MOExplicit receive Yes Yes Yes

AutoMessageUpcalls Yes Yes NoPollingMessageUpcalls Yes Yes No

ConnectionUpcalls Yes Yes YesConnectionDowncalls Yes No No

Page 63: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Malleability

● Ibis can notify the application if a machine joins or leaves● Callbacks/upcalls to a 'ResizeHandler'● Calls are delivered in the same order on all

machines

● Each 'Ibis' has a unique IbisIdentifier● Abstract identification of the machine● Impl. using IP-addresses / MPI-ranks / etc.

Page 64: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Elections

● Ibis offers an 'election' mechanism● Allows a group of machines to determine

who's in charge

● Each election● Has a name (String)● Produces an IbisIdentifier identifying the

winner● Is not democratic

Page 65: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Other cool features

● TCP Ibis supports● Parallel streams

● For high-latency & high-bandwidth links

● NAT / firewall traversal● TCP splicing● Routing messages through external point

Page 66: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

Page 67: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

// Step 1: create ibisStaticProperties p1 = new StaticProperties();p1.add("communication", "OneToOne, Reliable, ExplicitReceipt");p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null);

Page 68: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

// Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1);

Page 69: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

// Step 3: elect serverRegistry reg = ibis.registry();IbisIdentifier server = reg.elect("Server");boolean amServer = server.equals(ibis.identifier());

Page 70: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

if (amServer) {          // Step 4, create port              ReceivePort rp = type.createReceivePort("server");         rp.enableConnections();

Page 71: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

// Step 4, create port, find receivePort and connect  SendPort sp = type.createSendPort();sp.connect(reg.lookupReceivePort("server"));

Page 72: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

// Step 5, get message and write dataWriteMessage wm = sp.newMessage();wm.writeObject("Hello World");wm.finish();

Page 73: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

// Step 5, receive message and read dataReadMessage rm = rp.receive();String tmp = (String) rm.readObject();rm.finish();

System.out.println("Client says: " + tmp);

Page 74: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }}

// Step 6, close portrp.close();

// Step 6, close portsp.close();

Page 75: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code exampleimport ibis.ipl.*;

public class Example {

public static void main(String args[]) throws Exception {

// Step 1: create ibis StaticProperties p1 = new StaticProperties(); p1.add("communication", "OneToOne, Reliable, ExplicitReceipt"); p1.add("serialization", "object");

Ibis ibis = Ibis.createIbis(p1, null); // Step 2: create porttype PortType type = ibis.createPortType("Test Type", p1); // Step 3: elect server Registry reg = ibis.registry(); IbisIdentifier server = reg.elect("Server"); boolean amServer = server.equals(ibis.identifier());

if (amServer) { // Step 4, create port ReceivePort rp = type.createReceivePort("server"); rp.enableConnections(); // Step 5, receive message and read data ReadMessage rm = rp.receive(); String tmp = (String) rm.readObject(); rm.finish();

System.out.println("Client says: " + tmp);

// Step 6, close port rp.close();

} else {

// Step 4, create port, find receivePort and connect SendPort sp = type.createSendPort(); sp.connect(reg.lookupReceivePort("server"));

// Step 5, get message and write data WriteMessage wm = sp.newMessage(); wm.writeObject("Hello World"); wm.finish();

// Step 6, close port sp.close();

}

ibis.end(); }} ibis.end();

Page 76: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code Example

● Live demo

Page 77: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Nameserver

● Used by Ibises to find each other● Needs to be in a well known place● Used to implements joins & leaves● Used to implement Registry● Supports multiple namespaces

● So 'conflicting' apps can use the same server

Page 78: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Higher level programming models

● Remote Method Invocation (RMI)● Group Method Invocation (GMI)● Satin (Divide & Conquer)● MPJ (MPI Java 'standard')● Others are being developed

● Balutek (data parallel)● Replicated Method Invocation (RepMI)

Page 79: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Satin

● Parallel Divide-and-conquer ● Divide work into independent parts● Spawn sub-jobs● Combine sub-results● Repeat recursively

● Master-Worker is a subset of this● Only one level of recursion

● Targeted at the grid (and clusters)

Page 80: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Sequential Fibonacci

public long fib(int n) {

        if (n < 2) return n;

        long x = fib(n ­ 1);

        long y = fib(n – 2);

        

        return x + y;

}

Page 81: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Parallel Fibonacci

interface FibInterface extends ibis.satin.Spawnable {

    public long fib(int n);

}

public long fib(int n) {

        if (n < 2) return n;

        long x = fib(n ­ 1);

        long y = fib(n – 2);

        sync();

        return x + y;

}

Page 82: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Parallel Fibonacci

interface FibInterface extends ibis.satin.Spawnable {

    public long fib(int n);

}

public long fib(int n) {

        if (n < 2) return n;

        long x = fib(n ­ 1);

        long y = fib(n – 2);

        sync();

        return x + y;

}

Mark methods as

Spawnable.

They are allowed to

run in parallel.

Page 83: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Parallel Fibonacci

interface FibInterface extends ibis.satin.Spawnable {

    public long fib(int n);

}

public long fib(int n) {

        if (n < 2) return n;

        long x = fib(n ­ 1);

        long y = fib(n – 2);

        sync();

        return x + y;

}

Wait until spawned

methods are done.

Mark methods as

Spawnable.

They are allowed to

run in parallel.

Page 84: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Satin features

● Satin distributes jobs across machines

● Load-balancing is done automatically● Algorithm has been proven to be optimal

on homogeneous systems● Additional highly-efficient grid-aware

algorithms

Page 85: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Satin features

● Malleability● Add/remove machines on the fly

● Fault-tolerance● When a machine leave suddenly (crashes)

the others continue the computation and automatically recompute the lost work

● Shared Objects (added recently)● Allows machines to share 'global data'

Page 86: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Satin Applications

● More interesting applications● Numerical functions● N-body simulations● Game-tree search● Raytracer● Satisfiability solver● Grammar-based text analysis● Bioinformatics applications● ...

Page 87: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis RMI

● Replacement for Sun RMI● Has the same interface● Used different stub compiler (rmic)

● Generates Ibis specific stubs/skeletons

object

thread

inte

rface

reference

Page 88: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis RMI

● Replacement for Sun RMI● Has the same interface● Used different stub compiler (rmic)

● Generates Ibis specific stubs/skeletons

object

thread

inte

rface

referencestub skel

network

Page 89: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Ibis RMI

● Not interoperable with Sun RMI ● uses a different protocol

● No socket factories● Ibis doesn't have to use sockets!

● No activatable objects

Page 90: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

GMI

● Generalized RMI model● Allows communication with groups

● A single stub refers to an entire group

● Allows more 'advanced' communication● By offering different ways of forwarding a

method invocation and handling the reply

Page 91: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

GMI

● Group● Contains 1 or more objects

● Fixed size (set when it is created)● All objects must implement the same

group interface● But objects may have different type!

● Unique name● Used in lookup (produces group reference)

● Group members have rank● Ranks are 'per-group'

Page 92: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

GMI Example

inte

rface

object

object

object

group

groupreference

groupinterface

Page 93: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

GMI Implementation

inte

rface

referencestub

skel

objectskel

objectskel

object

Page 94: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

GMI Implementation

inte

rface

referencestub

skel

objectskel

objectskel

object

JVM 1

JVM 2

JVM 3

JVM 4

Page 95: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Group operations

● The group reference can be configured● How is a method invocation handled● How is the method result handled● Configuration per method

● Implemented by selecting different communication code in the generated stubs and skeletons

Page 96: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Invocation Schemes

● Single● Forward to 1 object in group

● Group● Forward to all objects in group

● Personalized● Forward to all objects, but personalize

parameters for each target

● Combined● Combine several invocation into one, then

foward to the group using one of the above

Page 97: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Single

foo()

Page 98: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Single

foo()

Page 99: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Group

foo()

Page 100: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Group

foo()

foo()

foo()

Page 101: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Personalized

foo([1,2,3])

Page 102: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Personalized

foo([1])

foo([2])

foo([3])

Page 103: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Combined

foo([1])

foo([2])

Page 104: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Combined

foo([1,2])fo

o([2

])

foo([1])

Page 105: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Combined

foo([1,2])

foo([1,2])

foo([1,2])

Page 106: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Reply handling schemes

● Discard

● Return

● Forward● Reply is forwarded to a seperate object

● Combine● Multiple replies are combined into one

● Personalize● A personalized result is returned to each

participant of a combined invocation

Page 107: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

GMI Communication

Operation Invocation ReplyRMI Single Return

Async. RMI Single DiscardFuture Single Forward

Broadcast Group DiscardScatter Personalized Discard

Reduce results Group Combine (binomial)Gather results Group Combine (flat)

Reduce inv. Combine + Single DiscardGather inv. Combine + Single Discard

Page 108: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code examplepublic interface i_SimpleGroup extends GroupInterface {    void ping();}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();                    // Create the group          if (rank == 0) {             Group.create("GroupNoReply", i_SimpleGroup.class, size);        }                     // Everyone adds an object         SimpleGroup s = new SimpleGroup();                      Group.join("GroupNoReply", s);                    if (rank == 0) {                        // Perform lookup to get group reference            i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");                // Configure reference to perform group invocation            GroupMethod m = Group.findMethod(g,"void ping()");            m.configure(new GroupInvocation(), new DiscardReply());                            // Perform the invocation              g.ping();        }                    // Done        Group.exit();    }}

Page 109: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

public interface i_SimpleGroup extends GroupInterface {    void ping();}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();                    // Create the group          if (rank == 0) {             Group.create("GroupNoReply", i_SimpleGroup.class, size);        }                     // Everyone adds an object         SimpleGroup s = new SimpleGroup();                      Group.join("GroupNoReply", s);                    if (rank == 0) {                        // Perform lookup to get group reference            i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");                // Configure reference to perform group invocation            GroupMethod m = Group.findMethod(g,"void ping()");            m.configure(new GroupInvocation(), new DiscardReply());                            // Perform the invocation              g.ping();        }                    // Done        Group.exit();    }}

Code example

public interface i_SimpleGroup extends GroupInterface {    void ping();}

Page 110: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code examplepublic interface i_SimpleGroup extends GroupInterface {    void ping();}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();                    // Create the group          if (rank == 0) {             Group.create("GroupNoReply", i_SimpleGroup.class, size);        }                     // Everyone adds an object         SimpleGroup s = new SimpleGroup();                      Group.join("GroupNoReply", s);                    if (rank == 0) {                        // Perform lookup to get group reference            i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");                // Configure reference to perform group invocation            GroupMethod m = Group.findMethod(g,"void ping()");            m.configure(new GroupInvocation(), new DiscardReply());                            // Perform the invocation              g.ping();        }                    // Done        Group.exit();    }}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

Page 111: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code examplepublic interface i_SimpleGroup extends GroupInterface {    void ping();}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();                    // Create the group          if (rank == 0) {             Group.create("GroupNoReply", i_SimpleGroup.class, size);        }                     // Everyone adds an object         SimpleGroup s = new SimpleGroup();                      Group.join("GroupNoReply", s);                    if (rank == 0) {                        // Perform lookup to get group reference            i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");                // Configure reference to perform group invocation            GroupMethod m = Group.findMethod(g,"void ping()");            m.configure(new GroupInvocation(), new DiscardReply());                            // Perform the invocation              g.ping();        }                    // Done        Group.exit();    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();

Page 112: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code examplepublic interface i_SimpleGroup extends GroupInterface {    void ping();}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();                    // Create the group          if (rank == 0) {             Group.create("GroupNoReply", i_SimpleGroup.class, size);        }                     // Everyone adds an object         SimpleGroup s = new SimpleGroup();                      Group.join("GroupNoReply", s);                    if (rank == 0) {                        // Perform lookup to get group reference            i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");                // Configure reference to perform group invocation            GroupMethod m = Group.findMethod(g,"void ping()");            m.configure(new GroupInvocation(), new DiscardReply());                            // Perform the invocation              g.ping();        }                    // Done        Group.exit();    }}

// Create the group  if (rank == 0) {     Group.create("GroupNoReply", i_SimpleGroup.class, size);} 

Page 113: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code examplepublic interface i_SimpleGroup extends GroupInterface {    void ping();}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();                    // Create the group          if (rank == 0) {             Group.create("GroupNoReply", i_SimpleGroup.class, size);        }                     // Everyone adds an object         SimpleGroup s = new SimpleGroup();                      Group.join("GroupNoReply", s);                    if (rank == 0) {                        // Perform lookup to get group reference            i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");                // Configure reference to perform group invocation            GroupMethod m = Group.findMethod(g,"void ping()");            m.configure(new GroupInvocation(), new DiscardReply());                            // Perform the invocation              g.ping();        }                    // Done        Group.exit();    }}

// Everyone adds an object SimpleGroup s = new SimpleGroup();    Group.join("GroupNoReply", s);            

Page 114: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code examplepublic interface i_SimpleGroup extends GroupInterface {    void ping();}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();                    // Create the group          if (rank == 0) {             Group.create("GroupNoReply", i_SimpleGroup.class, size);        }                     // Everyone adds an object         SimpleGroup s = new SimpleGroup();                      Group.join("GroupNoReply", s);                    if (rank == 0) {                        // Perform lookup to get group reference            i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");                // Configure reference to perform group invocation            GroupMethod m = Group.findMethod(g,"void ping()");            m.configure(new GroupInvocation(), new DiscardReply());                            // Perform the invocation              g.ping();        }                    // Done        Group.exit();    }}

if (rank == 0) {                // Perform lookup to get group reference    i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");    

// Configure reference to perform group invocationGroupMethod m = Group.findMethod(g,"void ping()");m.configure(new GroupInvocation(), new DiscardReply());

                    // Perform the invocation      g.ping();}

Page 115: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code examplepublic interface i_SimpleGroup extends GroupInterface {    void ping();}

public class SimpleGroup extends GroupMember implements i_SimpleGroup {

    public SimpleGroup() {        super();    }        public void ping() {         System.out.println("ping");    }}

public class MulticastNoReply {    public static void main(String[] args) throws Exception {                int rank = Group.rank();        int size = Group.size();                    // Create the group          if (rank == 0) {             Group.create("GroupNoReply", i_SimpleGroup.class, size);        }                     // Everyone adds an object         SimpleGroup s = new SimpleGroup();                      Group.join("GroupNoReply", s);                    if (rank == 0) {                        // Perform lookup to get group reference            i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");                // Configure reference to perform group invocation            GroupMethod m = Group.findMethod(g,"void ping()");            m.configure(new GroupInvocation(), new DiscardReply());                            // Perform the invocation              g.ping();        }                    // Done        Group.exit();    }}

// DoneGroup.exit();

Page 116: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Code Example

● Live demo

Page 117: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Function Objects

● Some operations need user defined functions ● Personalizing a method invocation● Combining a result or invocation● Forwarding of results

● GMI uses function objects● Extend a class from the GMI package

Page 118: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

Result Combiners

● Use 'combiner' to merge the results of an invocation

● FlatCombiner● Combines all results in one go● Similar to 'gather' operation of MPI

● BinomialCombiner● Pairwise combines results● Similar to 'reduce' operation of MPI

Page 119: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

public class FlatCombiner {

    public boolean combine(boolean[] results, Exception[] ex)    public byte combine(byte[] results, Exception[] ex)    public char combine(char[] results, Exception[] ex)    public short combine(short[] results, Exception[] ex)    public int combine(int[] results, Exception[] ex)    public long combine(long[] results, Exception[] ex)    public float combine(float[] results, Exception[] ex)    public double combine(double[] results, Exception[] ex)

    public Object combine(Object[] results, Exception[] ex)

    public void combine(Exception[] exceptions)}

Page 120: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

public class MyCombiner extends FlatCombiner {

    public int combine(int[] results, Exception[] ex) {               int sum = 0;         for (int i=0;i<results.length;i++) {            sum += results[i];        }           return sum;     }  }

Page 121: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

// Get a group referenceX g = (X) Group.lookup("your group");    

// Configure reference to perform group invocation, // and combine the replies using 'MyCombiner'GroupMethod m = Group.findMethod(g, "int get()");m.configure(new GroupInvocation(),             new CombineReply(new MyCombiner()));                

// Perform the invocation  int result = g.get();

Page 122: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

get()

Page 123: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

get()

get()

get()

Page 124: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

42

64

8

Page 125: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

combine([42,64,8], [])

MyCombiner

Page 126: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

114

MyCombiner

Page 127: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner

114

Page 128: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

FlatCombiner Demo

● Live demo

Page 129: Ibis tutorial hands-on session · Overview Programming models IPL (bare bones Ibis) RMI (remote invocation) GMI (group communication) Satin (divide and conquer) MPJ (MPI to Java binding)

After the Break

● Hands-on session● Installing ibis● Running applications

● Scripts and command line● Writing your own applications


Recommended