Cases
Cases
Cases for Parallel Java
Analysis 1: Distributed Simulation on the Internet
Cases
Cases for Parallel Java
Analysis 2: Java as a general scientific language
Options
Options to Parallelism in Java
Options
Options to communication in Java
NPAC
Experiments at NPAC.
shift
, transpose
, I/O, ...
Message Passing
Channel communication
Have implemented a Java class library for channel communication. Similar to dynamic channels in Fortran M.
Model attractive because
Message Passing
Channel communication
Library supports bi-directional communication of data on a channel.
Message Passing
MPI Interface
Experimenting with native methods interface to MPICH.
Interface modelled on proposed C++ bindings of MPI (but cannot support derived data types ...).
public class Comm { public Comm() ; // Default constructor: // equivalent to MPI_COMM_WORLD. public int size(); public int rank(); public void bSendInt(int [] buf, int dest, int tag); public Status recvInt(int [] buf, int source, int tag); // ...or whichever primitive types are needed }Work in progress. Simple test cases run, but no full demonstation, yet.
Data Parallel
Parallel Arrays in Java
Currently, take a pure class library approach, similar to A++/P++, HPC++ parallel STL, Adlib, etc.
We parametrize an array by a member of the Array
class, similar
to an HPF template. Index ranges of array distributed over dimensions
of process grid, represented by Procs
class.
Parallel Java application written as a class extending library
class Node
: maintains some global information and provides
collective operations on arrays.
Data Parallel
Data-parallel example: initialization
Procs p = new Procs(this, 2, 2) ; Range x = new Range(N, p, 0) ; // distrib over 1st dim of `p' Range y = new Range(N, p, 1) ; // distrib over 2nd dim of `p' Array r = new Array(p, x, y) ; byte [] w = new byte [r.seg()] ; // main data array ... declare neighbour arrays, `cn_', `cp_', etc, similarly // initialize the ``life'' board for(r.forall() ; r.test() ; r.next()) w [r.sub()] = fun(x.idx(), y.idx()) ;
Data Parallel
Data-parallel example: main loop
for (int k=0; k<NITER; k++) { // Get neighbours shift(cn_, w, r, 0, 1, CYCLIC); shift(cp_, w, r, 0, -1, CYCLIC); ... etc, copy arrays for 8 neighbours // Life update rule for(int i=0; i<w.length; i++) { switch (cn_[i] + cp_[i] + c_n[i] + c_p[i] + cnn[i] + cnp[i] + cpn[i] + cpp[i]) { case 2 : break; case 3 : w[i] = 1; break; default: w[i] = 0; break; } } }
Data Parallel
Data-parallel example: comments
Characteristics of the data-parallel style of programming:
Range
to
CRange
for cyclic distribution). Main program insensitive to
these details.
Currently the communications in Node
are implemented on
java.net
sockets. Plan to provide a ``native-methods'' Java
interface to the full NPAC PCRC library.
Array Syntax
Array syntax in Java.
A higher level approach makes Array
classes into true
container classes (for a restricted set of types), and all operations on
arrays collective.
ArrayFloat a = new ArrayFloat(p, x, y) ; ArrayFloat b = new ArrayFloat(p, x, y) ; ArrayInt c = new ArrayInt(p, x, y) ; a = MATMUL(b, c) ;Communication subsumed into collective array operations. Elements not accessed directly in the Java program.
Can implement on top of previous SPMD Java array library, or by making Java program run as a sequential master program controlling parallel back end. Compare with HPF Interpreter, A++/P++, etc.
Hampered by lack of user-defined operator-overloading in Java.