1
1
openmpi/ompi/mpi/java/c/mpi_Message.c
Oscar Vega-Gisbert 98530055d1 mpi.Message: java object members as parameters
This commit was SVN r30755.
2014-02-17 22:26:30 +00:00

80 строки
2.5 KiB
C

#include "ompi_config.h"
#ifdef HAVE_TARGETCONDITIONALS_H
#include <TargetConditionals.h>
#endif
#include "mpi.h"
#include "mpi_Message.h"
#include "mpiJava.h"
JNIEXPORT void JNICALL Java_mpi_Message_init(JNIEnv *e, jclass c)
{
ompi_java_setStaticLongField(e, c, "NULL", (jlong)MPI_MESSAGE_NULL);
ompi_java_setStaticLongField(e, c, "NO_PROC", (jlong)MPI_MESSAGE_NO_PROC);
ompi_java.MessageHandle = (*e)->GetFieldID(e, c, "handle", "J");
}
JNIEXPORT jlong JNICALL Java_mpi_Message_mProbe(
JNIEnv *env, jobject jthis,
jint source, jint tag, jlong jComm, jobject jStatus)
{
MPI_Comm comm = (MPI_Comm)jComm;
MPI_Message message;
MPI_Status status;
int rc = MPI_Mprobe(source, tag, comm, &message, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_status_set(&status, env, jStatus);
return (jlong)message;
}
JNIEXPORT jobject JNICALL Java_mpi_Message_imProbe(
JNIEnv *env, jobject jthis, jint source, jint tag, jlong jComm)
{
MPI_Comm comm = (MPI_Comm)jComm;
MPI_Message message;
MPI_Status status;
int rc, flag;
rc = MPI_Improbe(source, tag, comm, &flag, &message, &status);
if(ompi_java_exceptionCheck(env, rc) || !flag)
return NULL;
(*env)->SetLongField(env, jthis, ompi_java.MessageHandle, (jlong)message);
return ompi_java_status_new(&status, env);
}
JNIEXPORT jlong JNICALL Java_mpi_Message_mRecv(
JNIEnv *env, jobject jthis, jlong jMessage, jobject buf, jboolean db,
jint offset, jint count, jlong jType, jint bType, jobject stat)
{
MPI_Message message = (MPI_Message)jMessage;
MPI_Datatype type = (MPI_Datatype)jType;
void *bufPtr, *bufBase;
bufPtr = ompi_java_getBufPtr(&bufBase, env, buf, db, bType, offset);
MPI_Status status;
int rc = MPI_Mrecv(bufPtr, count, type, &message, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_status_set(&status, env, stat);
ompi_java_releaseBufPtr(env, buf, db, bufBase, bType);
return (jlong)message;
}
JNIEXPORT jlong JNICALL Java_mpi_Message_imRecv(
JNIEnv *env, jobject jthis, jlong jMessage,
jobject buf, jint count, jlong jType)
{
MPI_Message message = (MPI_Message)jMessage;
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr = ompi_java_getDirectBufferAddress(env, buf);
MPI_Request request;
int rc = MPI_Imrecv(ptr, count, type, &message, &request);
ompi_java_exceptionCheck(env, rc);
(*env)->SetLongField(env, jthis, ompi_java.MessageHandle, (jlong)message);
return (jlong)request;
}