Skip to content

Commit bb5699e

Browse files
author
Nathaniel Graham
committed
ompi/java: add MPI_Rget and MPI_Rput java bindings
Wrote tests for ompi tests, but will commit later. Signed-off-by: Nathaniel Graham <[email protected]>
1 parent f6882a8 commit bb5699e

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

ompi/mpi/java/c/mpi_Win.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,34 @@ JNIEXPORT void JNICALL Java_mpi_Win_setInfo(
298298
ompi_java_exceptionCheck(env, rc);
299299
}
300300

301+
JNIEXPORT jlong JNICALL Java_mpi_Win_rPut(JNIEnv *env, jobject jthis,
302+
jlong win, jobject origin_addr, jint origin_count, jlong origin_type,
303+
jint target_rank, jint target_disp, jint target_count, jlong target_datatype,
304+
jint basetype)
305+
{
306+
void *origPtr = ompi_java_getDirectBufferAddress(env, origin_addr);
307+
MPI_Request request;
308+
309+
int rc = MPI_Rput(origPtr, origin_count, (MPI_Datatype)origin_type,
310+
target_rank, (MPI_Aint)target_disp, target_count, (MPI_Datatype)target_datatype,
311+
(MPI_Win)win, &request);
312+
313+
ompi_java_exceptionCheck(env, rc);
314+
return (jlong)request;
315+
}
316+
317+
JNIEXPORT jlong JNICALL Java_mpi_Win_rGet(JNIEnv *env, jobject jthis, jlong win,
318+
jobject origin, jint orgCount, jlong orgType, jint targetRank, jint targetDisp,
319+
jint targetCount, jlong targetType, jint base)
320+
{
321+
void *orgPtr = (*env)->GetDirectBufferAddress(env, origin);
322+
MPI_Request request;
323+
324+
int rc = MPI_Rget(orgPtr, orgCount, (MPI_Datatype)orgType,
325+
targetRank, (MPI_Aint)targetDisp, targetCount,
326+
(MPI_Datatype)targetType, (MPI_Win)win, &request);
327+
328+
ompi_java_exceptionCheck(env, rc);
329+
return (jlong)request;
330+
}
331+

ompi/mpi/java/java/Win.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,66 @@ public void setInfo(Info info) throws MPIException
496496
private native void setInfo(long win, long info)
497497
throws MPIException;
498498

499+
/**
500+
* <p>Java binding of the MPI operation {@code MPI_RPUT}.
501+
* @param origin_addr initial address of origin buffer
502+
* @param origin_count number of entries in origin buffer
503+
* @param origin_datatype datatype of each entry in origin buffer
504+
* @param target_rank rank of target
505+
* @param target_disp displacement from start of window to target buffer
506+
* @param target_count number of entries in target buffer
507+
* @param target_datatype datatype of each entry in target buffer
508+
* @return RMA request
509+
* @throws MPIException
510+
*/
511+
public final Request rPut(Buffer origin_addr, int origin_count,
512+
Datatype origin_datatype, int target_rank, int target_disp,
513+
int target_count, Datatype target_datatype)
514+
throws MPIException
515+
{
516+
if(!origin_addr.isDirect())
517+
throw new IllegalArgumentException("The origin must be direct buffer.");
518+
519+
return new Request(rPut(handle, origin_addr, origin_count,
520+
origin_datatype.handle, target_rank, target_disp,
521+
target_count, target_datatype.handle, getBaseType(origin_datatype, target_datatype)));
522+
}
523+
524+
private native long rPut(long win, Buffer origin_addr, int origin_count,
525+
long origin_datatype, int target_rank, int target_disp,
526+
int target_count, long target_datatype, int baseType)
527+
throws MPIException;
528+
529+
/**
530+
* Java binding of {@code MPI_RGET}.
531+
* @param origin origin buffer
532+
* @param orgCount number of entries in origin buffer
533+
* @param orgType datatype of each entry in origin buffer
534+
* @param targetRank rank of target
535+
* @param targetDisp displacement from start of window to target buffer
536+
* @param targetCount number of entries in target buffer
537+
* @param targetType datatype of each entry in target buffer
538+
* @return RMA request
539+
* @throws MPIException
540+
*/
541+
public final Request rGet(Buffer origin, int orgCount, Datatype orgType,
542+
int targetRank, int targetDisp, int targetCount,
543+
Datatype targetType)
544+
throws MPIException
545+
{
546+
MPI.check();
547+
548+
if(!origin.isDirect())
549+
throw new IllegalArgumentException("The origin must be direct buffer.");
550+
551+
return new Request(rGet(handle, origin, orgCount, orgType.handle,
552+
targetRank, targetDisp, targetCount, targetType.handle,
553+
getBaseType(orgType, targetType)));
554+
}
555+
556+
private native long rGet(
557+
long win, Buffer origin, int orgCount, long orgType,
558+
int targetRank, int targetDisp, int targetCount, long targetType,
559+
int baseType) throws MPIException;
560+
499561
} // Win

0 commit comments

Comments
 (0)