This source file includes following definitions.
- Java_mpi_Message_init
- Java_mpi_Message_mProbe
- Java_mpi_Message_imProbe
- Java_mpi_Message_mRecv
- Java_mpi_Message_imRecv
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 #include "ompi_config.h"
  22 
  23 #ifdef HAVE_TARGETCONDITIONALS_H
  24 #include <TargetConditionals.h>
  25 #endif
  26 
  27 #include "mpi.h"
  28 #include "mpi_Message.h"
  29 #include "mpiJava.h"
  30 
  31 JNIEXPORT void JNICALL Java_mpi_Message_init(JNIEnv *e, jclass c)
  32 {
  33     ompi_java_setStaticLongField(e, c, "NULL",    (jlong)MPI_MESSAGE_NULL);
  34     ompi_java_setStaticLongField(e, c, "NO_PROC", (jlong)MPI_MESSAGE_NO_PROC);
  35     ompi_java.MessageHandle = (*e)->GetFieldID(e, c, "handle", "J");
  36 }
  37 
  38 JNIEXPORT jlong JNICALL Java_mpi_Message_mProbe(
  39         JNIEnv *env, jobject jthis,
  40         jint source, jint tag, jlong jComm, jlongArray jStatus)
  41 {
  42     MPI_Comm comm = (MPI_Comm)jComm;
  43     MPI_Message message;
  44     MPI_Status  status;
  45     int rc = MPI_Mprobe(source, tag, comm, &message, &status);
  46     
  47     if(!ompi_java_exceptionCheck(env, rc))
  48         ompi_java_status_set(env, jStatus, &status);
  49     
  50     return (jlong)message;
  51 }
  52 
  53 JNIEXPORT jobject JNICALL Java_mpi_Message_imProbe(
  54         JNIEnv *env, jobject jthis, jint source, jint tag, jlong jComm)
  55 {
  56     MPI_Comm comm = (MPI_Comm)jComm;
  57     MPI_Message message;
  58     MPI_Status  status;
  59     int rc, flag;
  60     rc = MPI_Improbe(source, tag, comm, &flag, &message, &status);
  61 
  62     if(ompi_java_exceptionCheck(env, rc) || !flag)
  63         return NULL;
  64 
  65     (*env)->SetLongField(env, jthis, ompi_java.MessageHandle, (jlong)message);
  66     return ompi_java_status_new(env, &status);
  67 }
  68 
  69 JNIEXPORT jlong JNICALL Java_mpi_Message_mRecv(
  70         JNIEnv *env, jobject jthis, jlong jMessage, jobject buf, jboolean db,
  71         jint off, jint count, jlong jType, jint bType, jlongArray jStatus)
  72 {
  73     MPI_Message  message = (MPI_Message)jMessage;
  74     MPI_Datatype type    = (MPI_Datatype)jType;
  75 
  76     void *ptr;
  77     ompi_java_buffer_t *item;
  78     ompi_java_getWritePtr(&ptr, &item, env, buf, db, count, type);
  79 
  80     MPI_Status status;
  81     int rc = MPI_Mrecv(ptr, count, type, &message, &status);
  82     
  83     if(!ompi_java_exceptionCheck(env, rc))
  84         ompi_java_status_set(env, jStatus, &status);
  85     
  86     ompi_java_releaseWritePtr(ptr, item, env, buf, db, off, count, type, bType);
  87     return (jlong)message;
  88 }
  89 
  90 JNIEXPORT jlong JNICALL Java_mpi_Message_imRecv(
  91         JNIEnv *env, jobject jthis, jlong jMessage,
  92         jobject buf, jint count, jlong jType)
  93 {
  94     MPI_Message  message = (MPI_Message)jMessage;
  95     MPI_Datatype type    = (MPI_Datatype)jType;
  96     void *ptr = ompi_java_getDirectBufferAddress(env, buf);
  97 
  98     MPI_Request request;
  99     int rc = MPI_Imrecv(ptr, count, type, &message, &request);
 100     ompi_java_exceptionCheck(env, rc);
 101     (*env)->SetLongField(env, jthis, ompi_java.MessageHandle, (jlong)message);
 102     return (jlong)request;
 103 }