From bb5699e912e87ab9e89795c227e99bc1bbbbbec2 Mon Sep 17 00:00:00 2001 From: Nathaniel Graham Date: Tue, 30 Jun 2015 12:05:59 -0600 Subject: [PATCH] ompi/java: add MPI_Rget and MPI_Rput java bindings Wrote tests for ompi tests, but will commit later. Signed-off-by: Nathaniel Graham --- ompi/mpi/java/c/mpi_Win.c | 31 +++++++++++++++++++ ompi/mpi/java/java/Win.java | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/ompi/mpi/java/c/mpi_Win.c b/ompi/mpi/java/c/mpi_Win.c index 2c55359cce..117e33b4a5 100644 --- a/ompi/mpi/java/c/mpi_Win.c +++ b/ompi/mpi/java/c/mpi_Win.c @@ -298,3 +298,34 @@ JNIEXPORT void JNICALL Java_mpi_Win_setInfo( ompi_java_exceptionCheck(env, rc); } +JNIEXPORT jlong JNICALL Java_mpi_Win_rPut(JNIEnv *env, jobject jthis, + jlong win, jobject origin_addr, jint origin_count, jlong origin_type, + jint target_rank, jint target_disp, jint target_count, jlong target_datatype, + jint basetype) +{ + void *origPtr = ompi_java_getDirectBufferAddress(env, origin_addr); + MPI_Request request; + + int rc = MPI_Rput(origPtr, origin_count, (MPI_Datatype)origin_type, + target_rank, (MPI_Aint)target_disp, target_count, (MPI_Datatype)target_datatype, + (MPI_Win)win, &request); + + ompi_java_exceptionCheck(env, rc); + return (jlong)request; +} + +JNIEXPORT jlong JNICALL Java_mpi_Win_rGet(JNIEnv *env, jobject jthis, jlong win, + jobject origin, jint orgCount, jlong orgType, jint targetRank, jint targetDisp, + jint targetCount, jlong targetType, jint base) +{ + void *orgPtr = (*env)->GetDirectBufferAddress(env, origin); + MPI_Request request; + + int rc = MPI_Rget(orgPtr, orgCount, (MPI_Datatype)orgType, + targetRank, (MPI_Aint)targetDisp, targetCount, + (MPI_Datatype)targetType, (MPI_Win)win, &request); + + ompi_java_exceptionCheck(env, rc); + return (jlong)request; +} + diff --git a/ompi/mpi/java/java/Win.java b/ompi/mpi/java/java/Win.java index f968618883..6ee1bcc14b 100644 --- a/ompi/mpi/java/java/Win.java +++ b/ompi/mpi/java/java/Win.java @@ -496,4 +496,66 @@ public void setInfo(Info info) throws MPIException private native void setInfo(long win, long info) throws MPIException; +/** + *

Java binding of the MPI operation {@code MPI_RPUT}. + * @param origin_addr initial address of origin buffer + * @param origin_count number of entries in origin buffer + * @param origin_datatype datatype of each entry in origin buffer + * @param target_rank rank of target + * @param target_disp displacement from start of window to target buffer + * @param target_count number of entries in target buffer + * @param target_datatype datatype of each entry in target buffer + * @return RMA request + * @throws MPIException + */ +public final Request rPut(Buffer origin_addr, int origin_count, + Datatype origin_datatype, int target_rank, int target_disp, + int target_count, Datatype target_datatype) + throws MPIException +{ + if(!origin_addr.isDirect()) + throw new IllegalArgumentException("The origin must be direct buffer."); + + return new Request(rPut(handle, origin_addr, origin_count, + origin_datatype.handle, target_rank, target_disp, + target_count, target_datatype.handle, getBaseType(origin_datatype, target_datatype))); +} + +private native long rPut(long win, Buffer origin_addr, int origin_count, + long origin_datatype, int target_rank, int target_disp, + int target_count, long target_datatype, int baseType) + throws MPIException; + +/** + * Java binding of {@code MPI_RGET}. + * @param origin origin buffer + * @param orgCount number of entries in origin buffer + * @param orgType datatype of each entry in origin buffer + * @param targetRank rank of target + * @param targetDisp displacement from start of window to target buffer + * @param targetCount number of entries in target buffer + * @param targetType datatype of each entry in target buffer + * @return RMA request + * @throws MPIException + */ +public final Request rGet(Buffer origin, int orgCount, Datatype orgType, + int targetRank, int targetDisp, int targetCount, + Datatype targetType) + throws MPIException +{ + MPI.check(); + + if(!origin.isDirect()) + throw new IllegalArgumentException("The origin must be direct buffer."); + + return new Request(rGet(handle, origin, orgCount, orgType.handle, + targetRank, targetDisp, targetCount, targetType.handle, + getBaseType(orgType, targetType))); +} + +private native long rGet( + long win, Buffer origin, int orgCount, long orgType, + int targetRank, int targetDisp, int targetCount, long targetType, + int baseType) throws MPIException; + } // Win