Skip to content

Commit e9d6c7a

Browse files
committed
Merge pull request #693 from nrgraham23/additional_java_bindings
Additional java bindings
2 parents 337dda0 + 26c528a commit e9d6c7a

File tree

4 files changed

+346
-2
lines changed

4 files changed

+346
-2
lines changed

ompi/mpi/java/c/mpi_Op.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
13+
* reserved.
1214
* $COPYRIGHT$
1315
*
1416
* Additional copyrights may follow
@@ -69,7 +71,7 @@ JNIEXPORT void JNICALL Java_mpi_Op_getOp(JNIEnv *env, jobject jthis, jint type)
6971
static MPI_Op Ops[] = {
7072
MPI_OP_NULL, MPI_MAX, MPI_MIN, MPI_SUM,
7173
MPI_PROD, MPI_LAND, MPI_BAND, MPI_LOR, MPI_BOR, MPI_LXOR,
72-
MPI_BXOR, MPI_MINLOC, MPI_MAXLOC
74+
MPI_BXOR, MPI_MINLOC, MPI_MAXLOC, MPI_REPLACE, MPI_NO_OP
7375
};
7476
(*env)->SetLongField(env,jthis, ompi_java.OpHandle, (jlong)Ops[type]);
7577
}

ompi/mpi/java/c/mpi_Win.c

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* All rights reserved.
1212
* Copyright (c) 2015 Research Organization for Information Science
1313
* and Technology (RIST). All rights reserved.
14+
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
15+
* reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -329,3 +331,106 @@ JNIEXPORT jlong JNICALL Java_mpi_Win_rGet(JNIEnv *env, jobject jthis, jlong win,
329331
return (jlong)request;
330332
}
331333

334+
JNIEXPORT jlong JNICALL Java_mpi_Win_rAccumulate(JNIEnv *env, jobject jthis, jlong win,
335+
jobject origin, jint orgCount, jlong orgType, jint targetRank, jint targetDisp,
336+
jint targetCount, jlong targetType, jobject jOp, jlong hOp, jint baseType)
337+
{
338+
void *orgPtr = (*env)->GetDirectBufferAddress(env, origin);
339+
MPI_Op op = ompi_java_op_getHandle(env, jOp, hOp, baseType);
340+
MPI_Request request;
341+
342+
int rc = MPI_Raccumulate(orgPtr, orgCount, (MPI_Datatype)orgType,
343+
targetRank, (MPI_Aint)targetDisp, targetCount,
344+
(MPI_Datatype)targetType, op, (MPI_Win)win, &request);
345+
346+
ompi_java_exceptionCheck(env, rc);
347+
return (jlong)request;
348+
}
349+
350+
JNIEXPORT void JNICALL Java_mpi_Win_getAccumulate(JNIEnv *env, jobject jthis, jlong win,
351+
jobject origin, jint orgCount, jlong orgType, jobject resultBuff, jint resultCount,
352+
jlong resultType, jint targetRank, jint targetDisp, jint targetCount, jlong targetType,
353+
jobject jOp, jlong hOp, jint baseType)
354+
{
355+
void *orgPtr = (*env)->GetDirectBufferAddress(env, origin);
356+
void *resultPtr = (*env)->GetDirectBufferAddress(env, resultBuff);
357+
MPI_Op op = ompi_java_op_getHandle(env, jOp, hOp, baseType);
358+
359+
int rc = MPI_Get_accumulate(orgPtr, orgCount, (MPI_Datatype)orgType,
360+
resultPtr, resultCount, (MPI_Datatype)resultType,
361+
targetRank, (MPI_Aint)targetDisp, targetCount,
362+
(MPI_Datatype)targetType, op, (MPI_Win)win);
363+
364+
ompi_java_exceptionCheck(env, rc);
365+
}
366+
367+
JNIEXPORT jlong JNICALL Java_mpi_Win_rGetAccumulate(JNIEnv *env, jobject jthis, jlong win,
368+
jobject origin, jint orgCount, jlong orgType, jobject resultBuff, jint resultCount,
369+
jlong resultType, jint targetRank, jint targetDisp, jint targetCount, jlong targetType,
370+
jobject jOp, jlong hOp, jint baseType)
371+
{
372+
void *orgPtr = (*env)->GetDirectBufferAddress(env, origin);
373+
void *resultPtr = (*env)->GetDirectBufferAddress(env, resultBuff);
374+
MPI_Op op = ompi_java_op_getHandle(env, jOp, hOp, baseType);
375+
MPI_Request request;
376+
377+
int rc = MPI_Rget_accumulate(orgPtr, orgCount, (MPI_Datatype)orgType,
378+
resultPtr, resultCount, (MPI_Datatype)resultType,
379+
targetRank, (MPI_Aint)targetDisp, targetCount,
380+
(MPI_Datatype)targetType, op, (MPI_Win)win, &request);
381+
382+
ompi_java_exceptionCheck(env, rc);
383+
return (jlong)request;
384+
}
385+
386+
JNIEXPORT void JNICALL Java_mpi_Win_lockAll(JNIEnv *env, jobject jthis, jlong win, jint assertion)
387+
{
388+
int rc = MPI_Win_lock_all(assertion, (MPI_Win)win);
389+
ompi_java_exceptionCheck(env, rc);
390+
}
391+
392+
JNIEXPORT void JNICALL Java_mpi_Win_unlockAll(JNIEnv *env, jobject jthis, jlong win)
393+
{
394+
int rc = MPI_Win_unlock_all((MPI_Win)win);
395+
ompi_java_exceptionCheck(env, rc);
396+
}
397+
398+
JNIEXPORT void JNICALL Java_mpi_Win_sync(JNIEnv *env, jobject jthis, jlong win)
399+
{
400+
int rc = MPI_Win_sync((MPI_Win)win);
401+
ompi_java_exceptionCheck(env, rc);
402+
}
403+
404+
JNIEXPORT void JNICALL Java_mpi_Win_flush(JNIEnv *env, jobject jthis, jlong win, jint targetRank)
405+
{
406+
int rc = MPI_Win_flush(targetRank, (MPI_Win)win);
407+
ompi_java_exceptionCheck(env, rc);
408+
}
409+
410+
JNIEXPORT void JNICALL Java_mpi_Win_flushAll(JNIEnv *env, jobject jthis, jlong win)
411+
{
412+
int rc = MPI_Win_flush_all((MPI_Win)win);
413+
ompi_java_exceptionCheck(env, rc);
414+
}
415+
416+
JNIEXPORT void JNICALL Java_mpi_Win_compareAndSwap (JNIEnv *env, jobject jthis, jlong win, jobject origin,
417+
jobject compareAddr, jobject resultAddr, jlong dataType, jint targetRank, jint targetDisp)
418+
{
419+
void *orgPtr = (*env)->GetDirectBufferAddress(env, origin);
420+
void *compPtr = (*env)->GetDirectBufferAddress(env, compareAddr);
421+
void *resultPtr = (*env)->GetDirectBufferAddress(env, resultAddr);
422+
423+
int rc = MPI_Compare_and_swap(orgPtr, compPtr, resultPtr, dataType, targetRank, targetDisp, (MPI_Win)win);
424+
ompi_java_exceptionCheck(env, rc);
425+
}
426+
427+
JNIEXPORT void JNICALL Java_mpi_Win_fetchAndOp(JNIEnv *env, jobject jthis, jlong win, jobject origin,
428+
jobject resultAddr, jlong dataType, jint targetRank, jint targetDisp, jobject jOp, jlong hOp, jint baseType)
429+
{
430+
void *orgPtr = (*env)->GetDirectBufferAddress(env, origin);
431+
void *resultPtr = (*env)->GetDirectBufferAddress(env, resultAddr);
432+
MPI_Op op = ompi_java_op_getHandle(env, jOp, hOp, baseType);
433+
434+
int rc = MPI_Fetch_and_op(orgPtr, resultPtr, dataType, targetRank, targetDisp, op, (MPI_Win)win);
435+
ompi_java_exceptionCheck(env, rc);
436+
}

ompi/mpi/java/java/MPI.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
13+
* reserved.
1214
* $COPYRIGHT$
1315
*
1416
* Additional copyrights may follow
@@ -68,7 +70,7 @@ public final class MPI
6870
public static final int ANY_SOURCE, ANY_TAG;
6971

7072
public static final Op MAX, MIN, SUM, PROD, LAND, BAND,
71-
LOR, BOR, LXOR, BXOR;
73+
LOR, BOR, LXOR, BXOR, REPLACE, NO_OP;
7274

7375
/**
7476
* Global minimum operator.
@@ -241,6 +243,8 @@ public final class MPI
241243
BXOR = new Op(10);
242244
MINLOC = new Op(11);
243245
MAXLOC = new Op(12);
246+
REPLACE = new Op(13);
247+
NO_OP = new Op(14);
244248

245249
GROUP_EMPTY = new Group(Group.getEmpty());
246250
REQUEST_NULL = new Request(Request.getNull());

0 commit comments

Comments
 (0)