// URI: bk://mpib.bkbits.net/mpib-dev
// SIDL interface for MPI
// MPIB is a language independent binding for the MPI standard interface.
// It allows a user to compile once with the client binding in the language
// of choice, and then dynamically load different implementations using the
// SIDL loading mechanism.
// We are shooting for a full implementation of MPI 1.2, but there are a few things missing:
// ------------------------------------------------------------------------------------------------
// Missing Feature | Reason
// ------------------------------------------------------------------------------------------------
// Communicator topologies | Laziness
// Buffered communication | Need some representation of the buffer (use SIDL arrays?)
// Convert error handling to exceptions | Laziness
// MPI user operators | Must locate a C binding to the submitted SIDL interface
// All I/O functions | Probably belong in a separate MPI-IO package
// ------------------------------------------------------------------------------------------------
package MPIB {
// This default implementation is provided with MPIB. It allows the
// user to build with any MPI implementation having a conforming C binding.
//
// Note that all classes which represent opaque MPI objects implement the
// AccessOpauqe interface, so that the underlying object may be retrieved.
package Default {
class Base implements MPIB.Base {}
class Object implements MPIB.Object {}
class DefaultComms extends Object implements DefaultComms {}
class Comm extends Object implements MPIB.Comm, MPIB.AccessOpaque {}
class DefaultDatatypes extends Object implements DefaultDatatypes {}
class Datatype extends Object implements MPIB.Datatype, MPIB.AccessOpaque {}
class DefaultGroups extends Object implements DefaultGroups {}
class Group extends Object implements MPIB.Group, MPIB.AccessOpaque {}
class DefaultOps extends Object implements DefaultOps {}
class Op extends Object implements MPIB.Op, MPIB.AccessOpaque {}
class CollectiveRequests extends Object implements MPIB.CollectiveRequests {}
class Request extends Object implements MPIB.Request, MPIB.AccessOpaque {}
class Status extends Object implements MPIB.Status, MPIB.AccessOpaque {}
class Info extends Object implements MPIB.Info, MPIB.AccessOpaque {}
}
// The opaque MPI objects of two components are from different MPIs
class Incompatible extends SIDL.BaseException {}
// The given key was not found
class KeyError extends SIDL.BaseException {}
// Possible results of opaque object comparison
enum CompareResult {IDENT, CONGRUENT, SIMILAR, UNEQUAL};
// The Base interface is intended to encapsulate the state of a
// running MPI implementation. All the static data and methods
// now belong to Base, so that we might have several different
// MPI implementations running at once.
interface Base extends SIDL.ProjectState {
string Get_processor_name();
void Get_version(out int ver, out int subver);
int Keyval_create(in opaque extra_state);
void Keyval_free(in int key_val);
double Wtime();
double Wtick();
DefaultComms comm();
DefaultDatatypes datatype();
DefaultGroups group();
DefaultOps op();
CollectiveRequests request();
int ANY_SOURCE();
int ANY_TAG();
int PROC_NULL();
string getCompareResultString(in CompareResult value);
}
// This is the base interface for any opaque object in MPI. It provides
// a way to retrieve the "implementation" context from any object.
interface Object {
Base getBase();
void setBase(in Base base);
}
// The default communicators provided by MPI
interface DefaultComms extends Object {
Comm SELF();
Comm WORLD();
}
// The Comm interface replaces MPI_Comm
interface Comm extends Object {
int size();
int rank();
CompareResult compare(in Comm comm2);
string get_name();
void set_name(in string name);
void Barrier();
Comm dup();
void Send(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
Request Send_init(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
void Ssend(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
Request Ssend_init(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
void Rsend(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
Request Rsend_init(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
Request Isend(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
Request Irsend(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
Request Issend(in opaque data, in int count, in Datatype dtype, in int dest, in int tag);
Status Sendrecv(in opaque data, in int count, in Datatype dtype, in int dest, in int tag, in opaque rdata, in int rcount, in Datatype rdtype, in int rsrc, in int rtag);
Status Sendrecv_replace(in opaque data, in int count, in Datatype dtype, in int dest, in int tag, in int rsrc, in int rtag);
Status Recv(in opaque data, in int count, in Datatype dtype, in int src, in int tag);
Request Irecv(in opaque data, in int count, in Datatype dtype, in int src, in int tag);
Request Recv_init(in opaque data, in int count, in Datatype dtype, in int src, in int tag);
void Pack(in opaque data, in int count, in Datatype dtype, in opaque output, in int outcount, inout int position);
void Unpack(in opaque data, in int count, inout int position, in opaque output, in int outcount, in Datatype dtype);
int Pack_size(in int count, in Datatype dtype);
void Gather(in opaque sendbuf, in int sendcount, in Datatype sendtype, in opaque recvbuf, in int recvcount, in Datatype recvtype, in int root);
void Gatherv(in opaque sendbuf, in int sendcount, in Datatype sendtype, in opaque recvbuf, in array<int> recvcounts, in array<int> displs, in Datatype recvtype, in int root);
void Allgather(in opaque sendbuf, in int sendcount, in Datatype sendtype, in opaque recvbuf, in int recvcount, in Datatype recvtype);
void Allgatherv(in opaque sendbuf, in int sendcount, in Datatype sendtype, in opaque recvbuf, in array<int> recvcounts, in array<int> displs, in Datatype recvtype);
void Alltoall(in opaque sendbuf, in int sendcount, in Datatype sendtype, in opaque recvbuf, in int recvcount, in Datatype recvtype);
void Alltoallv(in opaque sendbuf, in array<int> sendcounts, in array<int> sdispls, in Datatype sendtype, in opaque recvbuf, in array<int> recvcounts, in array<int> rdispls, in Datatype recvtype);
void Scatter(in opaque sendbuf, in int sendcount, in Datatype sendtype, in opaque recvbuf, in int recvcount, in Datatype recvtype, in int root);
void Scatterv(in opaque sendbuf, in array<int> sendcount, in array<int> displs, in Datatype sendtype, in opaque recvbuf, in int recvcount, in Datatype recvtype, in int root);
void Allreduce(in opaque sendbuf, in opaque recvbuf, in int count, in Datatype datatype, in Op op);
void Reduce(in opaque sendbuf, in opaque recvbuf, in int count, in Datatype datatype, in Op op, in int root);
void Reduce_scatter(in opaque sendbuf, in opaque recvbuf, in array<int> recvcounts, in Datatype datatype, in Op op);
void Scan(in opaque sendbuf, in opaque recvbuf, in int count, in Datatype datatype, in Op op);
void Attr_delete(in int keyval);
opaque Attr_get(in int keyval, out bool flag);
opaque Attr_put(in int keyval, in opaque attr_value);
void Bcast(in opaque buffer, in int count, in Datatype datatype, in int root);
Group group();
Group remote_group();
int remote_size();
Comm split(in int color, in int key);
bool test_inter();
bool Iprobe(in int source, in int tag, out Status status);
Status Probe(in int source, in int tag);
void Abort(in int errorcode);
Comm create(in Group group);
Comm Intercomm_create(in int local_leader, in Comm peer_comm, in int remote_leader, in int tag);
Comm Intercomm_merge(in int high);
void Send_char(in array<char> data, in int dest, in int tag);
void Send_int(in array<int> data, in int dest, in int tag);
void Send_double(in array<double> data, in int dest, in int tag);
void Send_dcomplex(in array<dcomplex> data, in int dest, in int tag);
Status Recv_char(inout array<char> data, in int src, in int tag);
Status Recv_int(inout array<int> data, in int src, in int tag);
Status Recv_double(inout array<double> data, in int src, in int tag);
Status Recv_dcomplex(inout array<dcomplex> data, in int src, in int tag);
void Bcast_char(inout array<char> data, in int root);
void Bcast_int(inout array<int> data, in int root);
void Bcast_double(inout array<double> data, in int root);
void Bcast_dcomplex(inout array<dcomplex> data, in int root);
}
// The default data types provided by MPI
interface DefaultDatatypes extends Object {
Datatype INT();
Datatype DOUBLE();
Datatype STRING();
Datatype SHORT();
Datatype LONG();
Datatype LONGLONG();
Datatype FLOAT();
Datatype COMPLEX();
Datatype DCOMPLEX();
Datatype PACKED();
void commit(in Datatype dtype);
void free(in Datatype dtype);
Datatype contiguous(in int count, in Datatype dtype);
Datatype darray(in int size, in int rank, in int ndims, in array<int> gsizes, in array<int> distribs, in array<int> dargs, in array<int> psizes, in int order, in Datatype dtype);
Datatype hindexed(in int count, in array<int> blocklens, in array<long> indices, in Datatype dtype);
Datatype hvector(in int count, in int blocklen, in long stride, in Datatype dtype);
Datatype indexed(in int count, in array<int> blocklens, in array<int> indices, in Datatype dtype);
Datatype indexed_block(in int count, in int blocklen, in array<int> displacements, in Datatype dtype);
Datatype structure(in int count, in array<int> blocklens, in array<long> indices, in array<Datatype> dtypes);
Datatype subarray(in int ndims, in array<int> sizes, in array<int> subsizes, in array<int> starts, in int order, in Datatype dtype);
Datatype vector(in int count, in int blocklen, in int stride, in Datatype dtype);
}
// The Datatype interface replaces MPI_Datatype
interface Datatype extends Object {
int size();
long extent();
void get_contents(out array<int> integers, out array<long> addresses, out array<Datatype> datatypes);
}
// The default groups provided by MPI
interface DefaultGroups extends Object {
Group EMPTY();
}
// The Group interface replaces MPI_Group
interface Group extends Object {
CompareResult compare(in Group group2);
Group difference(in Group group2);
Group excl(in array<int> ranks);
Group incl(in array<int> ranks);
Group range_excl(in array<int, 2> ranks);
Group range_incl(in array<int, 2> ranks);
Group intersection(in Group group2);
Group unionc(in Group group2);
int rank();
int size();
array<int> translate(in array<int> ranks, in Group group2);
}
// The default operators provided by MPI
interface DefaultOps extends Object {
Op SUM();
Op MAX();
Op MIN();
Op PROD();
Op LAND();
Op BAND();
Op LOR();
Op BOR();
Op LXOR();
Op BXOR();
Op MINLOC();
Op MAXLOC();
}
// The Op interface replaces MPI_Op
interface Op extends Object {}
interface CollectiveRequests extends Object {
void Startall(in array<Request> requests);
bool Testall(in array<Request> requests, out array<Status> statuses);
void Testsome(in array<Request> requests, out array<int> indices, out array<Status> statuses);
bool Testany(in array<Request> requests, out int index, out Status status);
void Waitall(in array<Request> requests, out array<Status> statuses);
void Waitany(in array<Request> requests, out int index, out Status status);
void Waitsome(in array<Request> requests, out array<int> indices, out array<Status> statuses);
}
// The Request interface replaces MPI_Request
interface Request extends Object {
void Cancel();
void Start();
bool Test(out Status status);
Status Wait();
}
// The Status interface replaces MPI_Status
interface Status extends Object {
int Get_count(in Datatype dtype);
int Get_elements(in Datatype dtype);
void set_elements(in Datatype dtype, in int count);
int Get_source();
int Get_tag();
bool Test_cancelled();
void set_cancelled(in bool isCancelled);
}
// The Info interface replaces MPI_Info
interface Info extends Object {
void delete_key(in string key);
Info dup();
string get(in string key) throws KeyError;
int get_nkeys();
string get_nthkey(in int n);
void set(in string key, in string value);
}
// If components use legacy code which requires the raw MPI objects, they can
// cast the various MPIB objects to the AccessOpaque interface and then extract
// out the underlying MPI object.
//
// WARNING: The legacy code MUST be compiled with exactly the same version of MPI as MPIB.
interface AccessOpaque {
opaque getOpaque() throws Incompatible;
void setOpaque(in opaque value) throws Incompatible;
}
}