1
1
openmpi/ompi/mpi/java/java/Message.java
Jeff Squyres e4e3e411fc Next generation of MPI Java bindings.
Includes all MPI functions supported by Open MPI, including MPI-3
functions (as of about 2 weeks ago).  Many changes compared to the
prior generation of Java bindings; not much is left from the prior
generation, actually.  The changes include (but are not limited to):

 * Add support for more than just a subset of MPI-1 functions
 * Use typical Java case for symbol names
 * Support Java Direct buffers (giving darn-near "native C"
   performance)
 * Support "type struct" better than the prior generation
 * Make more of an effort for the Java bindings to be a thin layer
   over the back-end C bindings
 * ...and more

A proper README with more information about what is supported, how to
use these bindings, etc. will be committed shortly.

This commit was SVN r29263.
2013-09-26 21:44:39 +00:00

130 строки
2.8 KiB
Java

package mpi;
import java.nio.*;
import static mpi.MPI.isHeapBuffer;
import static mpi.MPI.assertDirectBuffer;
/**
* This class represents {@code MPI_Message}.
*/
public final class Message
{
protected long handle;
private static long NULL, NO_PROC;
static
{
init();
}
private static native void init();
/**
* Creates a {@code MPI_MESSAGE_NULL}.
*/
public Message()
{
handle = NULL;
}
/**
* Tests if the message is {@code MPI_MESSAGE_NULL}.
* @return true if the message is {@code MPI_MESSAGE_NULL}.
*/
public boolean isNull()
{
return handle == NULL;
}
/**
* Tests if the message is {@code MPI_MESSAGE_NO_PROC}.
* @return true if the message is {@code MPI_MESSAGE_NO_PROC}.
*/
public boolean isNoProc()
{
return handle == NO_PROC;
}
/**
* Java binding of {@code MPI_MPROBE}.
* @param source rank of the source
* @param tag message tag
* @param comm communicator
* @return status object
* @throws MPIException
*/
public Status mProbe(int source, int tag, Comm comm) throws MPIException
{
MPI.check();
return mProbe(source, tag, comm.handle);
}
private native Status mProbe(int source, int tag, long comm)
throws MPIException;
/**
* Java binding of {@code MPI_IMPROBE}.
* @param source rank of the source
* @param tag message tag
* @param comm communicator
* @return status object if there is a message, {@code null} otherwise
* @throws MPIException
*/
public Status imProbe(int source, int tag, Comm comm) throws MPIException
{
MPI.check();
return imProbe(source, tag, comm.handle);
}
private native Status imProbe(int source, int tag, long comm)
throws MPIException;
/**
* Java binding of {@code MPI_MRECV}.
* @param buf receive buffer
* @param count number of elements in receve buffer
* @param type datatype of each receive buffer element
* @return status object
*/
public Status mRecv(Object buf, int count, Datatype type)
throws MPIException
{
MPI.check();
int off = 0;
if(isHeapBuffer(buf))
{
off = ((Buffer)buf).arrayOffset();
buf = ((Buffer)buf).array();
}
Status status = new Status();
mRecv(buf, off, count, type, status);
return status;
}
private native void mRecv(
Object buf, int offset, int count, Datatype type, Status status)
throws MPIException;
/**
* Java binding of {@code MPI_IMRECV}.
* @param buf receive buffer
* @param count number of elements in receve buffer
* @param type datatype of each receive buffer element
* @return request object
* @throws MPIException
*/
public Request imRecv(Buffer buf, int count, Datatype type)
throws MPIException
{
MPI.check();
assertDirectBuffer(buf);
return new Request(imRecv(buf, count, type.handle));
}
private native long imRecv(Object buf, int count, long type)
throws MPIException;
} // Message