2014-03-01 20:18:05 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2013-09-26 21:44:39 +00:00
|
|
|
#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");
|
|
|
|
}
|
|
|
|
|
2014-02-17 22:26:30 +00:00
|
|
|
JNIEXPORT jlong JNICALL Java_mpi_Message_mProbe(
|
|
|
|
JNIEnv *env, jobject jthis,
|
2014-03-01 19:54:36 +00:00
|
|
|
jint source, jint tag, jlong jComm, jlongArray jStatus)
|
2013-09-26 21:44:39 +00:00
|
|
|
{
|
2014-02-17 22:26:30 +00:00
|
|
|
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);
|
2014-03-01 19:54:36 +00:00
|
|
|
ompi_java_status_set(env, jStatus, &status);
|
2014-02-17 22:26:30 +00:00
|
|
|
return (jlong)message;
|
2013-09-26 21:44:39 +00:00
|
|
|
}
|
|
|
|
|
2014-02-23 20:08:53 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_mpi_Message_imProbe(
|
|
|
|
JNIEnv *env, jobject jthis, jint source,
|
2014-03-01 19:54:36 +00:00
|
|
|
jint tag, jlong jComm, jlongArray jStatus)
|
2013-09-26 21:44:39 +00:00
|
|
|
{
|
2014-02-17 22:26:30 +00:00
|
|
|
MPI_Comm comm = (MPI_Comm)jComm;
|
|
|
|
MPI_Message message;
|
|
|
|
MPI_Status status;
|
2013-09-26 21:44:39 +00:00
|
|
|
int rc, flag;
|
2014-02-17 22:26:30 +00:00
|
|
|
rc = MPI_Improbe(source, tag, comm, &flag, &message, &status);
|
2013-09-26 21:44:39 +00:00
|
|
|
|
|
|
|
if(ompi_java_exceptionCheck(env, rc) || !flag)
|
2014-02-23 20:08:53 +00:00
|
|
|
return JNI_FALSE;
|
2013-09-26 21:44:39 +00:00
|
|
|
|
|
|
|
(*env)->SetLongField(env, jthis, ompi_java.MessageHandle, (jlong)message);
|
2014-03-01 19:54:36 +00:00
|
|
|
ompi_java_status_set(env, jStatus, &status);
|
2014-02-23 20:08:53 +00:00
|
|
|
return JNI_TRUE;
|
2013-09-26 21:44:39 +00:00
|
|
|
}
|
|
|
|
|
2014-02-17 22:26:30 +00:00
|
|
|
JNIEXPORT jlong JNICALL Java_mpi_Message_mRecv(
|
|
|
|
JNIEnv *env, jobject jthis, jlong jMessage, jobject buf, jboolean db,
|
2014-03-01 19:54:36 +00:00
|
|
|
jint offset, jint count, jlong jType, jint bType, jlongArray jStatus)
|
2013-09-26 21:44:39 +00:00
|
|
|
{
|
2014-02-17 22:26:30 +00:00
|
|
|
MPI_Message message = (MPI_Message)jMessage;
|
|
|
|
MPI_Datatype type = (MPI_Datatype)jType;
|
2013-09-26 21:44:39 +00:00
|
|
|
|
|
|
|
void *bufPtr, *bufBase;
|
2014-02-16 22:58:01 +00:00
|
|
|
bufPtr = ompi_java_getBufPtr(&bufBase, env, buf, db, bType, offset);
|
2013-09-26 21:44:39 +00:00
|
|
|
|
|
|
|
MPI_Status status;
|
2014-02-17 22:26:30 +00:00
|
|
|
int rc = MPI_Mrecv(bufPtr, count, type, &message, &status);
|
|
|
|
ompi_java_exceptionCheck(env, rc);
|
2013-09-26 21:44:39 +00:00
|
|
|
|
2014-03-01 19:54:36 +00:00
|
|
|
ompi_java_status_set(env, jStatus, &status);
|
2014-02-16 22:58:01 +00:00
|
|
|
ompi_java_releaseBufPtr(env, buf, db, bufBase, bType);
|
2014-02-17 22:26:30 +00:00
|
|
|
return (jlong)message;
|
2013-09-26 21:44:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_mpi_Message_imRecv(
|
2014-02-17 22:26:30 +00:00
|
|
|
JNIEnv *env, jobject jthis, jlong jMessage,
|
|
|
|
jobject buf, jint count, jlong jType)
|
2013-09-26 21:44:39 +00:00
|
|
|
{
|
2014-02-17 22:26:30 +00:00
|
|
|
MPI_Message message = (MPI_Message)jMessage;
|
|
|
|
MPI_Datatype type = (MPI_Datatype)jType;
|
2013-09-29 10:36:09 +00:00
|
|
|
void *ptr = ompi_java_getDirectBufferAddress(env, buf);
|
2013-09-26 21:44:39 +00:00
|
|
|
|
2014-02-17 22:26:30 +00:00
|
|
|
MPI_Request request;
|
|
|
|
int rc = MPI_Imrecv(ptr, count, type, &message, &request);
|
2013-09-26 21:44:39 +00:00
|
|
|
ompi_java_exceptionCheck(env, rc);
|
2014-02-17 22:26:30 +00:00
|
|
|
(*env)->SetLongField(env, jthis, ompi_java.MessageHandle, (jlong)message);
|
2013-09-26 21:44:39 +00:00
|
|
|
return (jlong)request;
|
|
|
|
}
|