1
1

mpi.Comm: java object members as parameters

This commit was SVN r30741.
Этот коммит содержится в:
Oscar Vega-Gisbert 2014-02-16 18:51:14 +00:00
родитель 14bb7a117c
Коммит ecfca4c5f9
2 изменённых файлов: 174 добавлений и 217 удалений

Просмотреть файл

@ -1213,14 +1213,13 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iScatter(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_scatterv( JNIEXPORT void JNICALL Java_mpi_Comm_scatterv(
JNIEnv *env, jobject jthis, JNIEnv *env, jobject jthis, jlong jComm,
jobject sendBuf, jint sOffset, jintArray sCounts, jobject sendBuf, jint sOffset, jintArray sCounts,
jintArray displs, jobject sJType, jintArray displs, jlong sjType, jint sBType,
jobject recvBuf, jint rOffset, jint rCount, jobject rJType, jobject recvBuf, jint rOffset, jint rCount,
jint root) jlong rjType, jint rBType, jint root)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle));
int id; int id;
int rc = MPI_Comm_rank(comm, &id); int rc = MPI_Comm_rank(comm, &id);
int rootOrInter = id == root || isInter(env, comm); int rootOrInter = id == root || isInter(env, comm);
@ -1230,40 +1229,31 @@ JNIEXPORT void JNICALL Java_mpi_Comm_scatterv(
void *sPtr = NULL, *sBase, *rPtr, *rBase; void *sPtr = NULL, *sBase, *rPtr, *rBase;
MPI_Datatype rType; MPI_Datatype rType;
int rBType;
if(rJType == NULL) if(rjType == 0)
{ {
assert(recvBuf == NULL); assert(recvBuf == NULL);
rType = MPI_DATATYPE_NULL; rType = MPI_DATATYPE_NULL;
rBType = 0; rPtr = MPI_IN_PLACE;
rPtr = MPI_IN_PLACE; rBase = NULL;
rBase = NULL;
} }
else else
{ {
rType = (MPI_Datatype)((*env)->GetLongField( rType = (MPI_Datatype)rjType;
env, rJType, ompi_java.DatatypeHandle)); rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, rBType, rOffset);
rBType = (*env)->GetIntField(env, rJType, ompi_java.DatatypeBaseType);
rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, rBType, rOffset);
} }
jint *jSCounts = NULL, *jDispls = NULL; jint *jSCounts = NULL, *jDispls = NULL;
int *cSCounts = NULL, *cDispls = NULL; int *cSCounts = NULL, *cDispls = NULL;
MPI_Datatype sType = rType; MPI_Datatype sType = rType;
int sBType;
if(rootOrInter) if(rootOrInter)
{ {
ompi_java_getIntArray(env, sCounts, &jSCounts, &cSCounts); ompi_java_getIntArray(env, sCounts, &jSCounts, &cSCounts);
ompi_java_getIntArray(env, displs, &jDispls, &cDispls); ompi_java_getIntArray(env, displs, &jDispls, &cDispls);
sType = (MPI_Datatype)((*env)->GetLongField( sType = (MPI_Datatype)sjType;
env, sJType, ompi_java.DatatypeHandle)); sPtr = ompi_java_getBufPtr(&sBase, env, sendBuf, sBType, sOffset);
sBType = (*env)->GetIntField(env, sJType, ompi_java.DatatypeBaseType);
sPtr = ompi_java_getBufPtr(&sBase, env, sendBuf, sBType, sOffset);
} }
rc = MPI_Scatterv(sPtr, cSCounts, cDispls, sType, rc = MPI_Scatterv(sPtr, cSCounts, cDispls, sType,
@ -1340,41 +1330,28 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iScatterv(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_allGather( JNIEXPORT void JNICALL Java_mpi_Comm_allGather(
JNIEnv *env, jobject jthis, JNIEnv *env, jobject jthis, jlong jComm,
jobject sendBuf, jint sOffset, jint sCount, jobject sendtype, jobject sendBuf, jint sOffset, jint sCount, jlong sjType, jint sBType,
jobject recvBuf, jint rOffset, jint rCount, jobject recvtype) jobject recvBuf, jint rOffset, jint rCount, jlong rjType, jint rBType)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle));
int sBType;
MPI_Datatype sType; MPI_Datatype sType;
void *sPtr, *sBase, *rPtr, *rBase; void *sPtr, *sBase, *rPtr, *rBase;
if(sendtype == NULL) if(sjType == 0)
{ {
assert(sendBuf == NULL); assert(sendBuf == NULL);
sType = MPI_DATATYPE_NULL; sType = MPI_DATATYPE_NULL;
sBType = 0; sPtr = MPI_IN_PLACE;
sPtr = MPI_IN_PLACE; sBase = NULL;
sBase = NULL;
} }
else else
{ {
sType = (MPI_Datatype)((*env)->GetLongField( sType = (MPI_Datatype)sjType;
env, sendtype, ompi_java.DatatypeHandle)); sPtr = ompi_java_getBufPtr(&sBase, env, sendBuf, sBType, sOffset);
sBType = (*env)->GetIntField(env,
sendtype, ompi_java.DatatypeBaseType);
sPtr = ompi_java_getBufPtr(&sBase, env, sendBuf, sBType, sOffset);
} }
MPI_Datatype rType = (MPI_Datatype)((*env)->GetLongField( MPI_Datatype rType = (MPI_Datatype)rjType;
env, recvtype, ompi_java.DatatypeHandle));
int rBType = (*env)->GetIntField(env,
recvtype, ompi_java.DatatypeBaseType);
rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, rBType, rOffset); rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, rBType, rOffset);
int rc = MPI_Allgather(sPtr, sCount, sType, rPtr, rCount, rType, comm); int rc = MPI_Allgather(sPtr, sCount, sType, rPtr, rCount, rType, comm);
ompi_java_exceptionCheck(env, rc); ompi_java_exceptionCheck(env, rc);
@ -1415,40 +1392,29 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iAllGather(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_allGatherv( JNIEXPORT void JNICALL Java_mpi_Comm_allGatherv(
JNIEnv *env, jobject jthis, JNIEnv *env, jobject jthis, jlong jComm,
jobject sendBuf, jint sOffset, jint sCount, jobject sJType, jobject sendBuf, jint sOffset, jint sCount, jlong sjType, jint sBType,
jobject recvBuf, jint rOffset, jintArray rCounts, jobject recvBuf, jint rOffset, jintArray rCounts, jintArray displs,
jintArray displs, jobject rJType) jlong rjType, jint rBType)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle));
void *sPtr, *sBase, *rPtr, *rBase; void *sPtr, *sBase, *rPtr, *rBase;
MPI_Datatype sType; MPI_Datatype sType;
int sBType;
if(sJType == NULL) if(sjType == 0)
{ {
assert(sendBuf == NULL); assert(sendBuf == NULL);
sType = MPI_DATATYPE_NULL; sType = MPI_DATATYPE_NULL;
sBType = 0; sPtr = MPI_IN_PLACE;
sPtr = MPI_IN_PLACE; sBase = NULL;
sBase = NULL;
} }
else else
{ {
sType = (MPI_Datatype)((*env)->GetLongField( sType = (MPI_Datatype)sjType;
env, sJType, ompi_java.DatatypeHandle)); sPtr = ompi_java_getBufPtr(&sBase, env, sendBuf, sBType, sOffset);
sBType = (*env)->GetIntField(env, sJType, ompi_java.DatatypeBaseType);
sPtr = ompi_java_getBufPtr(&sBase, env, sendBuf, sBType, sOffset);
} }
MPI_Datatype rType = (MPI_Datatype)((*env)->GetLongField( MPI_Datatype rType = (MPI_Datatype)rjType;
env, rJType, ompi_java.DatatypeHandle));
int rBType = (*env)->GetIntField(env, rJType, ompi_java.DatatypeBaseType);
jint *jRCounts, *jDispls; jint *jRCounts, *jDispls;
int *cRCounts, *cDispls; int *cRCounts, *cDispls;
ompi_java_getIntArray(env, rCounts, &jRCounts, &cRCounts); ompi_java_getIntArray(env, rCounts, &jRCounts, &cRCounts);
@ -1506,20 +1472,13 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iAllGatherv(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_allToAll( JNIEXPORT void JNICALL Java_mpi_Comm_allToAll(
JNIEnv *env, jobject jthis, JNIEnv *env, jobject jthis, jlong jComm,
jobject sendBuf, jint sOffset, jint sCount, jobject sJType, jobject sendBuf, jint sOffset, jint sCount, jlong sjType, jint sBType,
jobject recvBuf, jint rOffset, jint rCount, jobject rJType) jobject recvBuf, jint rOffset, jint rCount, jlong rjType, jint rBType)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle)); MPI_Datatype sType = (MPI_Datatype)sjType;
MPI_Datatype rType = (MPI_Datatype)rjType;
MPI_Datatype sType = (MPI_Datatype)((*env)->GetLongField(
env, sJType, ompi_java.DatatypeHandle));
MPI_Datatype rType = (MPI_Datatype)((*env)->GetLongField(
env, rJType, ompi_java.DatatypeHandle));
int sBType = (*env)->GetIntField(env, sJType, ompi_java.DatatypeBaseType);
int rBType = (*env)->GetIntField(env, rJType, ompi_java.DatatypeBaseType);
void *sPtr, *sBase, *rPtr, *rBase; void *sPtr, *sBase, *rPtr, *rBase;
rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, rBType, rOffset); rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, rBType, rOffset);
@ -1551,22 +1510,15 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iAllToAll(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_allToAllv( JNIEXPORT void JNICALL Java_mpi_Comm_allToAllv(
JNIEnv *env, jobject jthis, JNIEnv *env, jobject jthis, jlong jComm,
jobject sendBuf, jint sOffset, jintArray sCount, jobject sendBuf, jint sOffset, jintArray sCount,
jintArray sDispls, jobject sJType, jintArray sDispls, jlong sjType, jint sBType,
jobject recvBuf, jint rOffset, jintArray rCount, jobject recvBuf, jint rOffset, jintArray rCount,
jintArray rDispls, jobject rJType) jintArray rDispls, jlong rjType, jint rBType)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle)); MPI_Datatype sType = (MPI_Datatype)sjType;
MPI_Datatype rType = (MPI_Datatype)rjType;
MPI_Datatype sType = (MPI_Datatype)((*env)->GetLongField(
env, sJType, ompi_java.DatatypeHandle));
MPI_Datatype rType = (MPI_Datatype)((*env)->GetLongField(
env, rJType, ompi_java.DatatypeHandle));
int sBType = (*env)->GetIntField(env, sJType, ompi_java.DatatypeBaseType),
rBType = (*env)->GetIntField(env, rJType, ompi_java.DatatypeBaseType);
jint *jSCount, *jRCount, *jSDispls, *jRDispls; jint *jSCount, *jRCount, *jSDispls, *jRDispls;
int *cSCount, *cRCount, *cSDispls, *cRDispls; int *cSCount, *cRCount, *cSDispls, *cRDispls;
@ -1622,12 +1574,11 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iAllToAllv(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_reduce( JNIEXPORT void JNICALL Java_mpi_Comm_reduce(
JNIEnv *env, jobject jthis, jobject sendBuf, jint sOffset, JNIEnv *env, jobject jthis, jlong jComm,
jobject recvBuf, jint rOffset, jint count, jobject type, jobject sendBuf, jint sOffset, jobject recvBuf, jint rOffset,
jobject op, jint root) jint count, jlong jType, jint baseType, jobject op, jint root)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle));
int id; int id;
int rc = MPI_Comm_rank(comm, &id); int rc = MPI_Comm_rank(comm, &id);
int rootOrInter = id == root || isInter(env, comm); int rootOrInter = id == root || isInter(env, comm);
@ -1635,10 +1586,7 @@ JNIEXPORT void JNICALL Java_mpi_Comm_reduce(
if(ompi_java_exceptionCheck(env, rc)) if(ompi_java_exceptionCheck(env, rc))
return; return;
MPI_Datatype mpiType = (MPI_Datatype)((*env)->GetLongField( MPI_Datatype type = (MPI_Datatype)jType;
env, type, ompi_java.DatatypeHandle));
int baseType = (*env)->GetIntField(env, type, ompi_java.DatatypeBaseType);
void *sPtr, *sBase, *rPtr = NULL, *rBase; void *sPtr, *sBase, *rPtr = NULL, *rBase;
if(sendBuf == NULL) if(sendBuf == NULL)
@ -1662,7 +1610,7 @@ JNIEXPORT void JNICALL Java_mpi_Comm_reduce(
} }
MPI_Op mpiOp = ompi_java_op_getHandle(env, op, baseType); MPI_Op mpiOp = ompi_java_op_getHandle(env, op, baseType);
rc = MPI_Reduce(sPtr, rPtr, count, mpiType, mpiOp, root, comm); rc = MPI_Reduce(sPtr, rPtr, count, type, mpiOp, root, comm);
ompi_java_exceptionCheck(env, rc); ompi_java_exceptionCheck(env, rc);
if(sendBuf != NULL) if(sendBuf != NULL)
@ -1717,18 +1665,12 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iReduce(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_allReduce( JNIEXPORT void JNICALL Java_mpi_Comm_allReduce(
JNIEnv *env, jobject jthis, JNIEnv *env, jobject jthis, jlong jComm,
jobject sendBuf, jint sendOffset, jobject sendBuf, jint sendOffset, jobject recvBuf, jint recvOffset,
jobject recvBuf, jint recvOffset, jint count, jlong jType, jint baseType, jobject op)
jint count, jobject type, jobject op)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle)); MPI_Datatype type = (MPI_Datatype)jType;
MPI_Datatype mpiType = (MPI_Datatype)((*env)->GetLongField(
env, type, ompi_java.DatatypeHandle));
int baseType = (*env)->GetIntField(env, type, ompi_java.DatatypeBaseType);
void *sPtr, *sBase, *rPtr, *rBase; void *sPtr, *sBase, *rPtr, *rBase;
if(sendBuf == NULL) if(sendBuf == NULL)
@ -1738,7 +1680,7 @@ JNIEXPORT void JNICALL Java_mpi_Comm_allReduce(
rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, baseType, recvOffset); rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, baseType, recvOffset);
MPI_Op mpiOp = ompi_java_op_getHandle(env, op, baseType); MPI_Op mpiOp = ompi_java_op_getHandle(env, op, baseType);
int rc = MPI_Allreduce(sPtr, rPtr, count, mpiType, mpiOp, comm); int rc = MPI_Allreduce(sPtr, rPtr, count, type, mpiOp, comm);
ompi_java_exceptionCheck(env, rc); ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, recvBuf, rBase, baseType); ompi_java_releaseBufPtr(env, recvBuf, rBase, baseType);
@ -1771,17 +1713,12 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iAllReduce(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_reduceScatter( JNIEXPORT void JNICALL Java_mpi_Comm_reduceScatter(
JNIEnv *env, jobject jthis, jobject sendBuf, jint sOffset, JNIEnv *env, jobject jthis, jlong jComm,
jobject recvBuf, jint rOffset, jintArray rCounts, jobject sendBuf, jint sOffset, jobject recvBuf, jint rOffset,
jobject jType, jobject op) jintArray rCounts, jlong jType, jint bType, jobject op)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle)); MPI_Datatype type = (MPI_Datatype)jType;
MPI_Datatype type = (MPI_Datatype)((*env)->GetLongField(
env, jType, ompi_java.DatatypeHandle));
int bType = (*env)->GetIntField(env, jType, ompi_java.DatatypeBaseType);
void *sPtr, *sBase, *rPtr, *rBase; void *sPtr, *sBase, *rPtr, *rBase;
if(sendBuf == NULL) if(sendBuf == NULL)
@ -1835,16 +1772,12 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iReduceScatter(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_reduceScatterBlock( JNIEXPORT void JNICALL Java_mpi_Comm_reduceScatterBlock(
JNIEnv *env, jobject jthis, jobject sendBuf, jint sOffset, JNIEnv *env, jobject jthis, jlong jComm,
jobject recvBuf, jint rOffset, jint count, jobject jType, jobject op) jobject sendBuf, jint sOffset, jobject recvBuf, jint rOffset,
jint count, jlong jType, jint bType, jobject op)
{ {
MPI_Comm comm = (MPI_Comm)((*env)->GetLongField( MPI_Comm comm = (MPI_Comm)jComm;
env, jthis, ompi_java.CommHandle)); MPI_Datatype type = (MPI_Datatype)jType;
MPI_Datatype type = (MPI_Datatype)((*env)->GetLongField(
env, jType, ompi_java.DatatypeHandle));
int bType = (*env)->GetIntField(env, jType, ompi_java.DatatypeBaseType);
void *sPtr, *sBase, *rPtr, *rBase; void *sPtr, *sBase, *rPtr, *rBase;
if(sendBuf == NULL) if(sendBuf == NULL)
@ -1887,23 +1820,21 @@ JNIEXPORT jlong JNICALL Java_mpi_Comm_iReduceScatterBlock(
} }
JNIEXPORT void JNICALL Java_mpi_Comm_reduceLocal( JNIEXPORT void JNICALL Java_mpi_Comm_reduceLocal(
JNIEnv *env, jobject jthis, jobject inbuf, jint inoff, JNIEnv *env, jclass clazz, jobject inBuf, jint inOff,
jobject inoutbuf, jint inoutoff, jint count, jobject type, jobject op) jobject inOutBuf, jint inOutOff, jint count,
jlong jType, jint bType, jobject op)
{ {
MPI_Datatype mpi_type = MPI_Datatype type = (MPI_Datatype)jType;
(MPI_Datatype)((*env)->GetLongField(env,type,ompi_java.DatatypeHandle)); void *inPtr, *inBase, *inOutPtr, *inOutBase;
inPtr = getBufCritical(&inBase, env, inBuf, bType, inOff);
inOutPtr = getBufCritical(&inOutBase, env, inOutBuf, bType, inOutOff);
int baseType = (*env)->GetIntField(env, type, ompi_java.DatatypeBaseType); int rc = MPI_Reduce_local(inPtr, inOutPtr, count, type,
void *inptr, *inbase, *inoutptr, *inoutbase; ompi_java_op_getHandle(env, op, bType));
inptr = ompi_java_getBufPtr(&inbase, env, inbuf, baseType, inoff);
inoutptr = ompi_java_getBufPtr(&inoutbase, env, inoutbuf, baseType, inoutoff);
int rc = MPI_Reduce_local(inptr, inoutptr, count, mpi_type,
ompi_java_op_getHandle(env, op, baseType));
ompi_java_exceptionCheck(env, rc); ompi_java_exceptionCheck(env, rc);
ompi_java_releaseReadBufPtr(env, inbuf, inbase, baseType); releaseBufCritical(env, inBuf, inBase);
ompi_java_releaseBufPtr(env, inoutbuf, inoutbase, baseType); releaseBufCritical(env, inOutBuf, inOutBase);
} }
JNIEXPORT void JNICALL Java_mpi_Comm_setName( JNIEXPORT void JNICALL Java_mpi_Comm_setName(

Просмотреть файл

@ -1613,8 +1613,10 @@ public final void scatterv(
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
scatterv(sendbuf, sendoff, sendcount, displs, sendtype, scatterv(handle, sendbuf, sendoff, sendcount, displs,
recvbuf, recvoff, recvcount, recvtype, root); sendtype.handle, sendtype.baseType,
recvbuf, recvoff, recvcount,
recvtype.handle, recvtype.baseType, root);
} }
/** /**
@ -1642,8 +1644,9 @@ public final void scatterv(Object sendbuf, int[] sendcount, int[] displs,
sendbuf = ((Buffer)sendbuf).array(); sendbuf = ((Buffer)sendbuf).array();
} }
scatterv(sendbuf, sendoff, sendcount, displs, sendtype, scatterv(handle, sendbuf, sendoff, sendcount, displs,
null, 0, 0, null, root); sendtype.handle, sendtype.baseType,
null, 0, 0, 0, 0, root);
} }
/** /**
@ -1670,15 +1673,16 @@ public final void scatterv(Object recvbuf, int recvcount,
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
scatterv(null, 0, null, null, null, scatterv(handle, null, 0, null, null, 0, 0,
recvbuf, recvoff, recvcount, recvtype, root); recvbuf, recvoff, recvcount,
recvtype.handle, recvtype.baseType, root);
} }
private native void scatterv( private native void scatterv(
Object sendbuf, int sendoffset, long comm, Object sendBuf, int sendOffset,
int[] sendcount, int[] displs, Datatype sendtype, int[] sendCount, int[] displs, long sendType, int sendBaseType,
Object recvbuf, int recvoffset, int recvcount, Object recvBuf, int recvOffset, int recvCount,
Datatype recvtype, int root) long recvType, int recvBaseType, int root)
throws MPIException; throws MPIException;
/** /**
@ -1792,8 +1796,10 @@ public final void allGather(Object sendbuf, int sendcount, Datatype sendtype,
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
allGather(sendbuf, sendoff, sendcount, sendtype, allGather(handle, sendbuf, sendoff, sendcount,
recvbuf, recvoff, recvcount, recvtype); sendtype.handle, sendtype.baseType,
recvbuf, recvoff, recvcount,
recvtype.handle, recvtype.baseType);
} }
/** /**
@ -1817,13 +1823,15 @@ public final void allGather(Object buf, int count, Datatype type)
buf = ((Buffer)buf).array(); buf = ((Buffer)buf).array();
} }
allGather(null, 0, 0, null, buf, off, count, type); allGather(handle, null, 0, 0, 0, 0,
buf, off, count, type.handle, type.baseType);
} }
private native void allGather( private native void allGather(
Object sendbuf, int sendoffset, int sendcount, Datatype sendtype, long comm, Object sendBuf, int sendOffset, int sendCount,
Object recvbuf, int recvoffset, int recvcount, Datatype recvtype) long sendType, int sendBaseType,
throws MPIException; Object recvBuf, int recvOffset, int recvCount,
long recvType, int recvBaseType) throws MPIException;
/** /**
* Similar to {@code gather}, but all processes receive the result. * Similar to {@code gather}, but all processes receive the result.
@ -1905,8 +1913,10 @@ public final void allGatherv(
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
allGatherv(sendbuf, sendoff, sendcount, sendtype, allGatherv(handle, sendbuf, sendoff, sendcount,
recvbuf, recvoff, recvcount, displs, recvtype); sendtype.handle, sendtype.baseType,
recvbuf, recvoff, recvcount, displs,
recvtype.handle, recvtype.baseType);
} }
/** /**
@ -1932,13 +1942,15 @@ public final void allGatherv(Object recvbuf, int[] recvcount,
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
allGatherv(null, 0, 0, null, recvbuf, recvoff, recvcount, displs, recvtype); allGatherv(handle, null, 0, 0, 0, 0, recvbuf, recvoff, recvcount,
displs, recvtype.handle, recvtype.baseType);
} }
private native void allGatherv( private native void allGatherv(
Object sendbuf, int sendoffset, int sendcount, Datatype sendtype, long comm, Object sendBuf, int sendOffset, int sendCount,
Object recvbuf, int recvoffset, int[] recvcount, int[] displs, long sendType, int sendBaseType,
Datatype recvtype) throws MPIException; Object recvBuf, int recvOffset, int[] recvCount, int[] displs,
long recvType, int recvBasetype) throws MPIException;
/** /**
* Similar to {@code gatherv}, but all processes receive the result. * Similar to {@code gatherv}, but all processes receive the result.
@ -2026,14 +2038,17 @@ public final void allToAll(Object sendbuf, int sendcount, Datatype sendtype,
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
allToAll(sendbuf, sendoff, sendcount, sendtype, allToAll(handle, sendbuf, sendoff, sendcount,
recvbuf, recvoff, recvcount, recvtype); sendtype.handle, sendtype.baseType,
recvbuf, recvoff, recvcount,
recvtype.handle, recvtype.baseType);
} }
private native void allToAll( private native void allToAll(
Object sendbuf, int sendoffset, int sendcount, Datatype sendtype, long comm, Object sendBuf, int sendOffset, int sendCount,
Object recvbuf, int recvoffset, int recvcount, Datatype recvtype) long sendType, int sendBaseType,
throws MPIException; Object recvBuf, int recvOffset, int recvCount,
long recvType, int recvBaseType) throws MPIException;
/** /**
* Extension of {@code allGather} to the case where each process sends * Extension of {@code allGather} to the case where each process sends
@ -2100,15 +2115,17 @@ public final void allToAllv(
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
allToAllv(sendbuf, sendoff, sendcount, sdispls, sendtype, allToAllv(handle, sendbuf, sendoff, sendcount, sdispls,
recvbuf, recvoff, recvcount, rdispls, recvtype); sendtype.handle, sendtype.baseType,
recvbuf, recvoff, recvcount, rdispls,
recvtype.handle, recvtype.baseType);
} }
private native void allToAllv( private native void allToAllv(
Object sendbuf, int sendoffset, long comm, Object sendBuf, int sendOffset,
int[] sendcount, int[] sdispls, Datatype sendtype, int[] sendCount, int[] sdispls, long sendType, int sendBaseType,
Object recvbuf, int recvoffset, Object recvBuf, int recvOffset,
int[] recvcount, int[] rdispls, Datatype recvtype) int[] recvCount, int[] rdispls, long recvType, int recvBaseType)
throws MPIException; throws MPIException;
/** /**
@ -2186,7 +2203,8 @@ public final void reduce(Object sendbuf, Object recvbuf, int count,
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
reduce(sendbuf, sendoff, recvbuf, recvoff, count, type, op, root); reduce(handle, sendbuf, sendoff, recvbuf, recvoff, count,
type.handle, type.baseType, op, root);
} }
/** /**
@ -2215,12 +2233,14 @@ public final void reduce(Object buf, int count, Datatype type, Op op, int root)
buf = ((Buffer)buf).array(); buf = ((Buffer)buf).array();
} }
reduce(null, 0, buf, off, count, type, op, root); reduce(handle, null, 0, buf, off, count,
type.handle, type.baseType, op, root);
} }
private native void reduce( private native void reduce(
Object sendbuf, int sendoff, Object recvbuf, int recvoff, long comm, Object sendbuf, int sendoff, Object recvbuf, int recvoff,
int count, Datatype type, Op op, int root) throws MPIException; int count, long type, int baseType, Op op, int root)
throws MPIException;
/** /**
* Combine elements in input buffer of each process using the reduce * Combine elements in input buffer of each process using the reduce
@ -2311,7 +2331,8 @@ public final void allReduce(Object sendbuf, Object recvbuf,
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
allReduce(sendbuf, sendoff, recvbuf, recvoff, count, type, op); allReduce(handle, sendbuf, sendoff, recvbuf, recvoff, count,
type.handle, type.baseType, op);
} }
/** /**
@ -2338,12 +2359,12 @@ public final void allReduce(Object buf, int count, Datatype type, Op op)
buf = ((Buffer)buf).array(); buf = ((Buffer)buf).array();
} }
allReduce(null, 0, buf, off, count, type, op); allReduce(handle, null, 0, buf, off, count, type.handle, type.baseType, op);
} }
private native void allReduce( private native void allReduce(
Object sendbuf, int sendoff, Object recvbuf, int recvoff, long comm, Object sendbuf, int sendoff, Object recvbuf, int recvoff,
int count, Datatype type, Op op) throws MPIException; int count, long type, int baseType, Op op) throws MPIException;
/** /**
* Same as {@code reduce} except that the result appears in receive * Same as {@code reduce} except that the result appears in receive
@ -2430,7 +2451,8 @@ public final void reduceScatter(Object sendbuf, Object recvbuf,
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
reduceScatter(sendbuf, sendoff, recvbuf, recvoff, recvcounts, type, op); reduceScatter(handle, sendbuf, sendoff, recvbuf, recvoff, recvcounts,
type.handle, type.baseType, op);
} }
/** /**
@ -2458,12 +2480,13 @@ public final void reduceScatter(Object buf, int[] counts, Datatype type, Op op)
buf = ((Buffer)buf).array(); buf = ((Buffer)buf).array();
} }
reduceScatter(null, 0, buf, off, counts, type, op); reduceScatter(handle, null, 0, buf, off, counts,
type.handle, type.baseType, op);
} }
private native void reduceScatter( private native void reduceScatter(
Object sendbuf, int sendoff, Object recvbuf, int recvoff, long comm, Object sendbuf, int sendoff, Object recvbuf, int recvoff,
int[] recvcounts, Datatype type, Op op) throws MPIException; int[] recvcounts, long type, int baseType, Op op) throws MPIException;
/** /**
* Combine elements in input buffer of each process using the reduce * Combine elements in input buffer of each process using the reduce
@ -2551,7 +2574,8 @@ public final void reduceScatterBlock(Object sendbuf, Object recvbuf,
recvbuf = ((Buffer)recvbuf).array(); recvbuf = ((Buffer)recvbuf).array();
} }
reduceScatterBlock(sendbuf, sendoff, recvbuf, recvoff, recvcount, type, op); reduceScatterBlock(handle, sendbuf, sendoff, recvbuf, recvoff, recvcount,
type.handle, type.baseType, op);
} }
/** /**
@ -2578,12 +2602,13 @@ public final void reduceScatterBlock(
buf = ((Buffer)buf).array(); buf = ((Buffer)buf).array();
} }
reduceScatterBlock(null, 0, buf, off, count, type, op); reduceScatterBlock(handle, null, 0, buf, off, count,
type.handle, type.baseType, op);
} }
private native void reduceScatterBlock( private native void reduceScatterBlock(
Object sendbuf, int sendoffset, Object recvbuf, int recvoffset, long comm, Object sendBuf, int sOffset, Object recvBuf, int rOffset,
int recvcount, Datatype type, Op op) throws MPIException; int rCount, long type, int baseType, Op op) throws MPIException;
/** /**
* Combine values and scatter the results. * Combine values and scatter the results.
@ -2637,44 +2662,45 @@ private native long iReduceScatterBlock(
/** /**
* Apply the operation given by {@code op} element-wise to the * Apply the operation given by {@code op} element-wise to the
* elements of {@code inbuf} and {@code inoutbuf} with the result * elements of {@code inBuf} and {@code inOutBuf} with the result
* stored element-wise in {@code inoutbuf}. * stored element-wise in {@code inOutBuf}.
* <p>Java binding of the MPI operation {@code MPI_REDUCE_LOCAL}. * <p>Java binding of the MPI operation {@code MPI_REDUCE_LOCAL}.
* @param inbuf input buffer array * @param inBuf input buffer array
* @param inoutbuf input buffer array, will contain combined output * @param inOutBuf input buffer array, will contain combined output
* @param count number of elements * @param count number of elements
* @param type data type of each item * @param type data type of each item
* @param op reduce operation * @param op reduce operation
* @throws MPIException * @throws MPIException
*/ */
public final void reduceLocal(Object inbuf, Object inoutbuf, int count, public static void reduceLocal(
Datatype type, Op op) Object inBuf, Object inOutBuf, int count, Datatype type, Op op)
throws MPIException throws MPIException
{ {
MPI.check(); MPI.check();
op.setDatatype(type); op.setDatatype(type);
int inoff = 0, int inOff = 0,
inoutoff = 0; inOutOff = 0;
if(isHeapBuffer(inbuf)) if(isHeapBuffer(inBuf))
{ {
inoff = ((Buffer)inbuf).arrayOffset(); inOff = ((Buffer)inBuf).arrayOffset();
inbuf = ((Buffer)inbuf).array(); inBuf = ((Buffer)inBuf).array();
} }
if(isHeapBuffer(inoutbuf)) if(isHeapBuffer(inOutBuf))
{ {
inoutoff = ((Buffer)inoutbuf).arrayOffset(); inOutOff = ((Buffer)inOutBuf).arrayOffset();
inoutbuf = ((Buffer)inoutbuf).array(); inOutBuf = ((Buffer)inOutBuf).array();
} }
reduceLocal(inbuf, inoff, inoutbuf, inoutoff, count, type, op); reduceLocal(inBuf, inOff, inOutBuf, inOutOff, count,
type.handle, type.baseType, op);
} }
private native void reduceLocal( private static native void reduceLocal(
Object inbuf, int inoff, Object inoutbuf, int inoutoff, Object inBuf, int inOff, Object inOutBuf, int inOutOff,
int count, Datatype datatype, Op op) throws MPIException; int count, long type, int baseType, Op op) throws MPIException;
/** /**
* Sets the print name for the communicator. * Sets the print name for the communicator.