diff --git a/ompi/mpi/java/c/mpiJava.h b/ompi/mpi/java/c/mpiJava.h index 3b9303ac86..48c4e3e6ee 100644 --- a/ompi/mpi/java/c/mpiJava.h +++ b/ompi/mpi/java/c/mpiJava.h @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -133,6 +135,11 @@ void ompi_java_releaseIntArray( void ompi_java_forgetIntArray( JNIEnv *env, jintArray array, jint *jptr, int *cptr); +void ompi_java_getDatatypeArray( + JNIEnv *env, jlongArray array, jlong **jptr, MPI_Datatype **cptr); +void ompi_java_forgetDatatypeArray( + JNIEnv *env, jlongArray array, jlong *jptr, MPI_Datatype *cptr); + void ompi_java_getBooleanArray( JNIEnv *env, jbooleanArray array, jboolean **jptr, int **cptr); void ompi_java_releaseBooleanArray( diff --git a/ompi/mpi/java/c/mpi_Comm.c b/ompi/mpi/java/c/mpi_Comm.c index edabfed97b..b086f23a46 100644 --- a/ompi/mpi/java/c/mpi_Comm.c +++ b/ompi/mpi/java/c/mpi_Comm.c @@ -1581,6 +1581,82 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iAllToAllv( return (jlong)request; } +JNIEXPORT void JNICALL Java_mpi_Comm_allToAllw( + JNIEnv *env, jobject jthis, jlong jComm, + jobject sendBuf, jintArray sCount, jintArray sDispls, jlongArray sTypes, + jobject recvBuf, jintArray rCount, jintArray rDispls, jlongArray rTypes) +{ + MPI_Comm comm = (MPI_Comm)jComm; + + jlong* jSTypes, *jRTypes; + MPI_Datatype *cSTypes, *cRTypes; + + ompi_java_getDatatypeArray(env, sTypes, &jSTypes, &cSTypes); + ompi_java_getDatatypeArray(env, rTypes, &jRTypes, &cRTypes); + + jint *jSCount, *jRCount, *jSDispls, *jRDispls; + int *cSCount, *cRCount, *cSDispls, *cRDispls; + ompi_java_getIntArray(env, sCount, &jSCount, &cSCount); + ompi_java_getIntArray(env, rCount, &jRCount, &cRCount); + ompi_java_getIntArray(env, sDispls, &jSDispls, &cSDispls); + ompi_java_getIntArray(env, rDispls, &jRDispls, &cRDispls); + + void *sPtr = ompi_java_getDirectBufferAddress(env, sendBuf), + *rPtr = ompi_java_getDirectBufferAddress(env, recvBuf); + + int rc = MPI_Alltoallw( + sPtr, cSCount, cSDispls, cSTypes, + rPtr, cRCount, cRDispls, cRTypes, comm); + + ompi_java_exceptionCheck(env, rc); + ompi_java_forgetIntArray(env, sCount, jSCount, cSCount); + ompi_java_forgetIntArray(env, rCount, jRCount, cRCount); + ompi_java_forgetIntArray(env, sDispls, jSDispls, cSDispls); + ompi_java_forgetIntArray(env, rDispls, jRDispls, cRDispls); + ompi_java_forgetDatatypeArray(env, sTypes, jSTypes, cSTypes); + ompi_java_forgetDatatypeArray(env, rTypes, jRTypes, cRTypes); +} + +JNIEXPORT jlong JNICALL Java_mpi_Comm_iAllToAllw( + JNIEnv *env, jobject jthis, jlong jComm, + jobject sendBuf, jintArray sCount, jintArray sDispls, jlongArray sTypes, + jobject recvBuf, jintArray rCount, jintArray rDispls, jlongArray rTypes) +{ + MPI_Comm comm = (MPI_Comm)jComm; + + jlong* jSTypes, *jRTypes; + MPI_Datatype *cSTypes, *cRTypes; + + ompi_java_getDatatypeArray(env, sTypes, &jSTypes, &cSTypes); + ompi_java_getDatatypeArray(env, rTypes, &jRTypes, &cRTypes); + + jint *jSCount, *jRCount, *jSDispls, *jRDispls; + int *cSCount, *cRCount, *cSDispls, *cRDispls; + ompi_java_getIntArray(env, sCount, &jSCount, &cSCount); + ompi_java_getIntArray(env, rCount, &jRCount, &cRCount); + ompi_java_getIntArray(env, sDispls, &jSDispls, &cSDispls); + ompi_java_getIntArray(env, rDispls, &jRDispls, &cRDispls); + + void *sPtr = ompi_java_getDirectBufferAddress(env, sendBuf), + *rPtr = ompi_java_getDirectBufferAddress(env, recvBuf); + + MPI_Request request; + + int rc = MPI_Ialltoallw( + sPtr, cSCount, cSDispls, cSTypes, + rPtr, cRCount, cRDispls, cRTypes, comm, &request); + + ompi_java_exceptionCheck(env, rc); + ompi_java_forgetIntArray(env, sCount, jSCount, cSCount); + ompi_java_forgetIntArray(env, rCount, jRCount, cRCount); + ompi_java_forgetIntArray(env, sDispls, jSDispls, cSDispls); + ompi_java_forgetIntArray(env, rDispls, jRDispls, cRDispls); + ompi_java_forgetDatatypeArray(env, sTypes, jSTypes, cSTypes); + ompi_java_forgetDatatypeArray(env, rTypes, jRTypes, cRTypes); + + return (jlong)request; +} + JNIEXPORT void JNICALL Java_mpi_Comm_neighborAllGather( JNIEnv *env, jobject jthis, jlong jComm, jobject sBuf, jboolean sdb, jint sOff, diff --git a/ompi/mpi/java/c/mpi_MPI.c b/ompi/mpi/java/c/mpi_MPI.c index e856bbfa3b..f2f0ff62e5 100644 --- a/ompi/mpi/java/c/mpi_MPI.c +++ b/ompi/mpi/java/c/mpi_MPI.c @@ -979,6 +979,30 @@ void ompi_java_forgetIntArray(JNIEnv *env, jintArray array, (*env)->ReleaseIntArrayElements(env, array, jptr, JNI_ABORT); } +void ompi_java_getDatatypeArray(JNIEnv *env, jlongArray array, + jlong **jptr, MPI_Datatype **cptr) +{ + jlong *jLongs = (*env)->GetLongArrayElements(env, array, NULL); + *jptr = jLongs; + + int i, length = (*env)->GetArrayLength(env, array); + MPI_Datatype *cDatatypes = calloc(length, sizeof(MPI_Datatype)); + + for(i = 0; i < length; i++){ + cDatatypes[i] = (MPI_Datatype)jLongs[i]; + } + *cptr = cDatatypes; +} + +void ompi_java_forgetDatatypeArray(JNIEnv *env, jlongArray array, + jlong *jptr, MPI_Datatype *cptr) +{ + if(jptr != cptr) + free(cptr); + + (*env)->ReleaseLongArrayElements(env, array, jptr, JNI_ABORT); +} + void ompi_java_getBooleanArray(JNIEnv *env, jbooleanArray array, jboolean **jptr, int **cptr) { diff --git a/ompi/mpi/java/java/CartComm.java b/ompi/mpi/java/java/CartComm.java index e5c8ca970f..665e5ff35a 100644 --- a/ompi/mpi/java/java/CartComm.java +++ b/ompi/mpi/java/java/CartComm.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Comm.java b/ompi/mpi/java/java/Comm.java index 060402f233..2bf8071601 100644 --- a/ompi/mpi/java/java/Comm.java +++ b/ompi/mpi/java/java/Comm.java @@ -229,6 +229,7 @@ public static int compare(Comm comm1, Comm comm2) throws MPIException /** * Test if communicator object is null (has been freed). + * Java binding of {@code MPI_COMM_NULL}. * @return true if the comm object is null, false otherwise */ public final boolean isNull() @@ -2307,6 +2308,79 @@ private native long iAllToAllv(long comm, Buffer recvbuf, int[] recvcount, int[] rdispls, long recvtype) throws MPIException; +/** + * Adds flexibility to {@code allToAll}: location of data for send is //here + * specified by {@code sDispls} and location to place data on receive + * side is specified by {@code rDispls}. + *

Java binding of the MPI operation {@code MPI_ALLTOALLW}. + * @param sendBuf send buffer + * @param sendCount number of items sent to each buffer + * @param sDispls displacements from which to take outgoing data + * @param sendTypes datatypes of send buffer items + * @param recvBuf receive buffer + * @param recvCount number of elements received from each process + * @param rDispls displacements at which to place incoming data + * @param recvTypes datatype of each item in receive buffer + * @throws MPIException Signals that an MPI exception of some sort has occurred. + */ +public final void allToAllw( + Buffer sendBuf, int[] sendCount, int[] sDispls, Datatype[] sendTypes, + Buffer recvBuf, int[] recvCount, int[] rDispls, Datatype[] recvTypes) + throws MPIException +{ + MPI.check(); + assertDirectBuffer(sendBuf, recvBuf); + + long[] sendHandles = convertTypeArray(sendTypes); + long[] recvHandles = convertTypeArray(recvTypes); + + allToAllw(handle, sendBuf, sendCount, sDispls, + sendHandles, recvBuf, recvCount, rDispls, + recvHandles); +} + +private native void allToAllw(long comm, + Buffer sendBuf, int[] sendCount, int[] sDispls, long[] sendTypes, + Buffer recvBuf, int[] recvCount, int[] rDispls, long[] recvTypes) + throws MPIException; + +/** + * Adds flexibility to {@code iAllToAll}: location of data for send is + * specified by {@code sDispls} and location to place data on receive + * side is specified by {@code rDispls}. + *

Java binding of the MPI operation {@code MPI_IALLTOALLW}. + * @param sendBuf send buffer + * @param sendCount number of items sent to each buffer + * @param sDispls displacements from which to take outgoing data + * @param sendTypes datatype send buffer items + * @param recvBuf receive buffer + * @param recvCount number of elements received from each process + * @param rDispls displacements at which to place incoming data + * @param recvTypes datatype of each item in receive buffer + * @return communication request + * @throws MPIException Signals that an MPI exception of some sort has occurred. + */ +public final Request iAllToAllw( + Buffer sendBuf, int[] sendCount, int[] sDispls, Datatype[] sendTypes, + Buffer recvBuf, int[] recvCount, int[] rDispls, Datatype[] recvTypes) + throws MPIException +{ + MPI.check(); + assertDirectBuffer(sendBuf, recvBuf); + + long[] sendHandles = convertTypeArray(sendTypes); + long[] recvHandles = convertTypeArray(recvTypes); + + return new Request(iAllToAllw( + handle, sendBuf, sendCount, sDispls, sendHandles, + recvBuf, recvCount, rDispls, recvHandles)); +} + +private native long iAllToAllw(long comm, + Buffer sendBuf, int[] sendCount, int[] sDispls, long[] sendTypes, + Buffer recvBuf, int[] recvCount, int[] rDispls, long[] recvTypes) + throws MPIException; + /** * Java binding of {@code MPI_NEIGHBOR_ALLGATHER}. * @param sendbuf send buffer @@ -3232,4 +3306,21 @@ public final String getName() throws MPIException private native String getName(long handle) throws MPIException; +/** + * A helper method to convert an array of Datatypes to + * an array of longs (handles). + * @param dArray Array of Datatypes + * @return converted Datatypes + */ +private long[] convertTypeArray(Datatype[] dArray) { + long[] lArray = new long[dArray.length]; + + for(int i = 0; i < lArray.length; i++) { + if(dArray[i] != null) { + lArray[i] = dArray[i].handle; + } + } + return lArray; +} + } // Comm diff --git a/ompi/mpi/java/java/Datatype.java b/ompi/mpi/java/java/Datatype.java index 5a96889140..be3c9b80e4 100644 --- a/ompi/mpi/java/java/Datatype.java +++ b/ompi/mpi/java/java/Datatype.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/DoubleInt.java b/ompi/mpi/java/java/DoubleInt.java index eb6ada66fb..b122afc68b 100644 --- a/ompi/mpi/java/java/DoubleInt.java +++ b/ompi/mpi/java/java/DoubleInt.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/File.java b/ompi/mpi/java/java/File.java index 5a2b453066..9777895af2 100644 --- a/ompi/mpi/java/java/File.java +++ b/ompi/mpi/java/java/File.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/FloatInt.java b/ompi/mpi/java/java/FloatInt.java index 5950440c93..b2c0a584f3 100644 --- a/ompi/mpi/java/java/FloatInt.java +++ b/ompi/mpi/java/java/FloatInt.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Freeable.java b/ompi/mpi/java/java/Freeable.java index 7b9c0697e7..e889720ccf 100644 --- a/ompi/mpi/java/java/Freeable.java +++ b/ompi/mpi/java/java/Freeable.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/GraphComm.java b/ompi/mpi/java/java/GraphComm.java index 65639334f8..d40d21422d 100644 --- a/ompi/mpi/java/java/GraphComm.java +++ b/ompi/mpi/java/java/GraphComm.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Group.java b/ompi/mpi/java/java/Group.java index 0b225cd98b..1eaf3042af 100644 --- a/ompi/mpi/java/java/Group.java +++ b/ompi/mpi/java/java/Group.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Info.java b/ompi/mpi/java/java/Info.java index 04ff3acfbe..3d1b2f7a67 100644 --- a/ompi/mpi/java/java/Info.java +++ b/ompi/mpi/java/java/Info.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Int2.java b/ompi/mpi/java/java/Int2.java index 73c93a6fec..2f3a585405 100644 --- a/ompi/mpi/java/java/Int2.java +++ b/ompi/mpi/java/java/Int2.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Intercomm.java b/ompi/mpi/java/java/Intercomm.java index f36f21295c..1b206f5e6a 100644 --- a/ompi/mpi/java/java/Intercomm.java +++ b/ompi/mpi/java/java/Intercomm.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/LongInt.java b/ompi/mpi/java/java/LongInt.java index fcde87c236..fd5f85cf0a 100644 --- a/ompi/mpi/java/java/LongInt.java +++ b/ompi/mpi/java/java/LongInt.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Message.java b/ompi/mpi/java/java/Message.java index 2a429bd46e..b4efbec6f7 100644 --- a/ompi/mpi/java/java/Message.java +++ b/ompi/mpi/java/java/Message.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Op.java b/ompi/mpi/java/java/Op.java index f680449a44..ffd3ffbf6d 100644 --- a/ompi/mpi/java/java/Op.java +++ b/ompi/mpi/java/java/Op.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Prequest.java b/ompi/mpi/java/java/Prequest.java index 2ddd018d16..fd7b88706b 100644 --- a/ompi/mpi/java/java/Prequest.java +++ b/ompi/mpi/java/java/Prequest.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Request.java b/ompi/mpi/java/java/Request.java index afe2a80091..dd86880ca7 100644 --- a/ompi/mpi/java/java/Request.java +++ b/ompi/mpi/java/java/Request.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/ShortInt.java b/ompi/mpi/java/java/ShortInt.java index 6e81f9baa1..c335e10c6e 100644 --- a/ompi/mpi/java/java/ShortInt.java +++ b/ompi/mpi/java/java/ShortInt.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Status.java b/ompi/mpi/java/java/Status.java index 4830e05e5f..81ed8efebf 100644 --- a/ompi/mpi/java/java/Status.java +++ b/ompi/mpi/java/java/Status.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/Struct.java b/ompi/mpi/java/java/Struct.java index e7d4fa1a90..65695cb9d6 100644 --- a/ompi/mpi/java/java/Struct.java +++ b/ompi/mpi/java/java/Struct.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mpi/java/java/UserFunction.java b/ompi/mpi/java/java/UserFunction.java index 65e4cf2f6f..e3630413d8 100644 --- a/ompi/mpi/java/java/UserFunction.java +++ b/ompi/mpi/java/java/UserFunction.java @@ -9,6 +9,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow