Ibis Tutorial
Ibis Tutorial
&
hands-on session
Jason Maassen
[email protected]
● 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
We are interested in...
● Lots of problems
● Resource selection
● Data transfer
● Security and authentication
● ...
● Heterogeneity
● Solution: Ibis !
● A “run-anywhere” communication library
● Just send it along with your application!
Application
ProActive
send receive
port port
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)
Send & receive ports
● Disadvantage:
● Simplicity may cause some overhead...
● Example: need two pairs for RPC / RMI
Port Types
● Defined at runtime
● Specify name and set of properties
io n!
pt
ce
ex
X
Port Types
● Defined at runtime
● Specify name and set of properties
!
ok
√
Port Types
Create ReceivePort
“server”
Connection setup
Registry
register(“server”)
Connection setup
Registry
lookup(“server”)
Connection setup
Registry
ID
Connection setup
Registry
connect
Connection setup
● Advantage of ReceivePortIdentifiers
● Hides implementation details
● Independent of
● IP-addresses
● Host names
● Port numbers
● MPI-ranks
● etc...
WM
Messages
WM
Messages
WM
Messages
RM
Messages
RM
Messages
RM
Messages
● Done!
Messages or streams ?
WM RM
Restrictions
● 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
Properties:
closed world
data ser.
explicit rec.
unicast
Ibis.createIbis(...)
Selecting an Ibis
implementations
MPI-Ibis
TCPIbis .jar PandaIbis
application local disk
jar files
Selecting an Ibis
implementation
MPI-Ibis
TCPIbis .jar PandaIbis
application local disk
jar files
Selecting an Ibis
Ibis
return new MPI-Ibis
instance class
Ibis.createIbis( )
Properties:
closed world
data ser.
explicit rec.
unicast
Properties
● Very flexible
● good and bad
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
Example
Property Values Description
Ibis
Property TCP Panda MPI
Worldmodel Open Closed Closed
Serialization B/D/O B/D/O B/D/O
Communication OO/OM/MO OO/OM/MO OO/OM/MO
Explicit receive Yes Yes Yes
AutoMessageUpcalls Yes Yes No
PollingMessageUpcalls Yes Yes No
ConnectionUpcalls Yes Yes Yes
ConnectionDowncalls Yes No No
Malleability
● Each election
● Has a name (String)
● Produces an IbisIdentifier identifying the
winner
● Is not democratic
Other cool features
if (amServer) {
// Step 4, create port
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 1: create ibis
// Step 4, create port
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
StaticProperties p1 = new StaticProperties();
// Step 5, receive message and read data
ReadMessage rm = rp.receive();
p1.add("communication", "OneToOne, Reliable, ExplicitReceipt");
String tmp = (String) rm.readObject();
rm.finish();
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 4, create port
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
PortType type = ibis.createPortType("Test Type", p1);
String tmp = (String) rm.readObject();
rm.finish();
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 4, create port
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
// Step 3: elect server rm.finish();
IbisIdentifier server = reg.elect("Server");
rp.close();
} else {
boolean amServer = server.equals(ibis.identifier());
// Step 4, create port, find receivePort and connect
SendPort sp = type.createSendPort();
sp.connect(reg.lookupReceivePort("server"));
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 4, create port
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
// Step 4, create port
// Step 4, create port, find receivePort and connect
SendPort sp = type.createSendPort();
ReceivePort rp = type.createReceivePort("server");
sp.connect(reg.lookupReceivePort("server"));
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 4, create port
// Step 4, create port, find receivePort and connect
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
sp.connect(reg.lookupReceivePort("server"));
rm.finish();
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 4, create port
// Step 5, get message and write data
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
wm.finish();
System.out.println("Client says: " + tmp);
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 4, create port
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
// Step 5, receive message and read data
// Step 4, create port, find receivePort and connect
SendPort sp = type.createSendPort();
ReadMessage rm = rp.receive();
sp.connect(reg.lookupReceivePort("server"));
String tmp = (String) rm.readObject();
WriteMessage wm = sp.newMessage();
wm.writeObject("Hello World");
wm.finish();
System.out.println("Client says: " + tmp);
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 6, close port
// Step 4, create port
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
rp.close();
// Step 5, receive message and read data
ReadMessage rm = rp.receive();
String tmp = (String) rm.readObject();
rm.finish();
sp.close();
wm.finish();
ibis.end();
}
}
Code example
import ibis.ipl.*;
if (amServer) {
// Step 4, create port
ReceivePort rp = type.createReceivePort("server");
rp.enableConnections();
ibis.end();
ibis.end();
}
}
Code Example
● Live demo
Nameserver
● 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)
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;
}
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;
}
Parallel Fibonacci
interface FibInterface extends ibis.satin.Spawnable {
public long fib(int n);
} Mark methods as
public long fib(int n) { Spawnable.
if (n < 2) return n; They are allowed to
run in parallel.
long x = fib(n 1);
long y = fib(n – 2);
sync();
return x + y;
}
Parallel Fibonacci
interface FibInterface extends ibis.satin.Spawnable {
public long fib(int n);
} Mark methods as
public long fib(int n) { Spawnable.
if (n < 2) return n; They are allowed to
run in parallel.
long x = fib(n 1);
long y = fib(n – 2);
Wait until spawned
sync();
methods are done.
return x + y;
}
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
interface
object
reference
thread
Ibis RMI
thread
network
Ibis RMI
● No socket factories
● Ibis doesn't have to use sockets!
● No activatable objects
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'
GMI Example
group
object
group
interface
reference
object
group
interface
object
GMI Implementation
skel object
interface
skel object
GMI Implementation
JVM 2
skel object
interface
skel object
JVM 4
Group operations
foo()
Single
o o()
f
Group
foo()
Group
o o()
f
foo()
foo(
)
Personalized
foo([1,2,3])
Personalized
( [ 1])
foo
foo([2])
foo(
[ 3])
Combined
foo([1])
foo([2])
Combined
fo
o ([
1]
)
foo([1,2])
)
[ 2]
o(
fo
Combined
] )
1,2
( [
foo
foo([1,2])
foo
([1
,2]
)
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
GMI Communication
Operation Invocation Reply
RMI Single Return
Async. RMI Single Discard
Future Single Forward
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();
}
public class SimpleGroup extends GroupMember implements i_SimpleGroup {
public SimpleGroup() {
super();
}
public interface i_SimpleGroup extends GroupInterface {
public void ping() {
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();
}
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();
public class SimpleGroup extends GroupMember implements i_SimpleGroup {
// Create the group
if (rank == 0) {
Group.create("GroupNoReply", i_SimpleGroup.class, size);
public SimpleGroup() {
}
super();
// Everyone adds an object
SimpleGroup s = new SimpleGroup();
} Group.join("GroupNoReply", s);
if (rank == 0) {
// Perform lookup to get group reference
public void ping() {
i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");
System.out.println("ping");
// 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();
}
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);
}
public class MulticastNoReply {
// Everyone adds an object
public static void main(String[] args) throws Exception {
SimpleGroup s = new SimpleGroup();
Group.join("GroupNoReply", s);
if (rank == 0) {
int rank = Group.rank();
// Perform lookup to get group reference
i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");
int size = Group.size();
// 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();
}
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) {
// Create the group
// Perform lookup to get group reference
i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");
if (rank == 0) {
// Configure reference to perform group invocation
Group.create("GroupNoReply", i_SimpleGroup.class, size);
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();
}
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");
// Everyone adds an object
// Configure reference to perform group invocation
SimpleGroup s = new SimpleGroup();
GroupMethod m = Group.findMethod(g,"void ping()");
m.configure(new GroupInvocation(), new DiscardReply());
Group.join("GroupNoReply", s);
// Perform the invocation
g.ping();
}
// Done
Group.exit();
}
}
Code example
public interface i_SimpleGroup extends GroupInterface {
void ping();
}
public class SimpleGroup extends GroupMember implements i_SimpleGroup {
public SimpleGroup() {
if (rank == 0) {
super();
}
// Perform lookup to get group reference
public void ping() {
i_SimpleGroup g = (i_SimpleGroup) Group.lookup("GroupNoReply");
System.out.println("ping");
}
}
// Configure reference to perform group invocation
public class MulticastNoReply {
public static void main(String[] args) throws Exception {
GroupMethod m = Group.findMethod(g,"void ping()");
int rank = Group.rank();
m.configure(new GroupInvocation(), new DiscardReply());
int size = Group.size();
// Create the group
if (rank == 0) {
// Perform the invocation
Group.create("GroupNoReply", i_SimpleGroup.class, size);
}
g.ping();
// 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();
}
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());
// Done
// Perform the invocation
g.ping();
}
Group.exit();
// Done
Group.exit();
}
}
Code Example
● Live demo
Function Objects
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)
}
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;
}
}
FlatCombiner
// Get a group reference
X 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();
FlatCombiner
get()
FlatCombiner
e t ()
g
get()
get
()
FlatCombiner
42
64
8
FlatCombiner
MyCombiner
combine([42,64,8], [])
FlatCombiner
MyCombiner
114
FlatCombiner
114
FlatCombiner Demo
● Live demo
After the Break
● Hands-on session
● Installing ibis
● Running applications
● Scripts and command line
● Writing your own applications