Skip to content

Commit 745872e

Browse files
author
Nathaniel Graham
authored
Merge pull request #2063 from nrgraham23/check_exceptionCheck
Error handling improvements
2 parents 7c8e769 + 5380427 commit 745872e

File tree

6 files changed

+185
-67
lines changed

6 files changed

+185
-67
lines changed

ompi/mpi/java/c/mpi_Comm.c

+22-9
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) 2016 Los Alamos National Security, LLC. All rights
15+
* reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -205,7 +207,10 @@ JNIEXPORT jlongArray JNICALL Java_mpi_Comm_iDup(
205207
MPI_Comm newcomm;
206208
MPI_Request request;
207209
int rc = MPI_Comm_idup((MPI_Comm)comm, &newcomm, &request);
208-
ompi_java_exceptionCheck(env, rc);
210+
211+
if(ompi_java_exceptionCheck(env, rc))
212+
return NULL;
213+
209214
jlongArray jcr = (*env)->NewLongArray(env, 2);
210215
jlong *cr = (jlong*)(*env)->GetPrimitiveArrayCritical(env, jcr, NULL);
211216
cr[0] = (jlong)newcomm;
@@ -332,6 +337,7 @@ JNIEXPORT void JNICALL Java_mpi_Comm_recv(
332337
jobject buf, jboolean db, jint offset, jint count,
333338
jlong jType, jint bType, jint source, jint tag, jlongArray jStatus)
334339
{
340+
jboolean exception;
335341
MPI_Comm comm = (MPI_Comm)jComm;
336342
MPI_Datatype type = (MPI_Datatype)jType;
337343

@@ -341,10 +347,12 @@ JNIEXPORT void JNICALL Java_mpi_Comm_recv(
341347

342348
MPI_Status status;
343349
int rc = MPI_Recv(ptr, count, type, source, tag, comm, &status);
344-
ompi_java_exceptionCheck(env, rc);
350+
exception = ompi_java_exceptionCheck(env, rc);
345351

346352
ompi_java_releaseWritePtr(ptr,item,env,buf,db,offset,count,type,bType);
347-
ompi_java_status_set(env, jStatus, &status);
353+
354+
if(!exception)
355+
ompi_java_status_set(env, jStatus, &status);
348356
}
349357

350358
JNIEXPORT void JNICALL Java_mpi_Comm_sendRecv(
@@ -355,6 +363,7 @@ JNIEXPORT void JNICALL Java_mpi_Comm_sendRecv(
355363
jlong rjType, jint rBType, jint source, jint rTag,
356364
jlongArray jStatus)
357365
{
366+
jboolean exception;
358367
MPI_Comm comm = (MPI_Comm)jComm;
359368
MPI_Datatype sType = (MPI_Datatype)sjType;
360369
MPI_Datatype rType = (MPI_Datatype)rjType;
@@ -369,10 +378,12 @@ JNIEXPORT void JNICALL Java_mpi_Comm_sendRecv(
369378
int rc = MPI_Sendrecv(sPtr, sCount, sType, dest, sTag,
370379
rPtr, rCount, rType, source, rTag, comm, &status);
371380

372-
ompi_java_exceptionCheck(env, rc);
381+
exception = ompi_java_exceptionCheck(env, rc);
373382
ompi_java_releaseReadPtr(sPtr, sItem, sBuf, sdb);
374383
ompi_java_releaseWritePtr(rPtr,rItem,env,rBuf,rdb,rOff,rCount,rType,rBType);
375-
ompi_java_status_set(env, jStatus, &status);
384+
385+
if(!exception)
386+
ompi_java_status_set(env, jStatus, &status);
376387
}
377388

378389
JNIEXPORT void JNICALL Java_mpi_Comm_sendRecvReplace(
@@ -392,8 +403,9 @@ JNIEXPORT void JNICALL Java_mpi_Comm_sendRecvReplace(
392403
int rc = MPI_Sendrecv_replace(ptr, count, type, dest,
393404
sTag, source, rTag, comm, &status);
394405

395-
ompi_java_exceptionCheck(env, rc);
396-
ompi_java_status_set(env, jStatus, &status);
406+
if(!ompi_java_exceptionCheck(env, rc))
407+
ompi_java_status_set(env, jStatus, &status);
408+
397409
ompi_java_releaseWritePtr(ptr,item,env,buf,db,offset,count,type,bType);
398410
}
399411

@@ -662,8 +674,9 @@ JNIEXPORT void JNICALL Java_mpi_Comm_probe(
662674
{
663675
MPI_Status status;
664676
int rc = MPI_Probe(source, tag, (MPI_Comm)comm, &status);
665-
ompi_java_exceptionCheck(env, rc);
666-
ompi_java_status_set(env, jStatus, &status);
677+
678+
if(!ompi_java_exceptionCheck(env, rc))
679+
ompi_java_status_set(env, jStatus, &status);
667680
}
668681

669682
JNIEXPORT jint JNICALL Java_mpi_Comm_getTopology(

ompi/mpi/java/c/mpi_Datatype.c

+6-2
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) 2016 Los Alamos National Security, LLC. All rights
13+
* reserved.
1214
* $COPYRIGHT$
1315
*
1416
* Additional copyrights may follow
@@ -92,7 +94,8 @@ JNIEXPORT void JNICALL Java_mpi_Datatype_getLbExtent(
9294
{
9395
MPI_Aint lb, extent;
9496
int rc = MPI_Type_get_extent((MPI_Datatype)type, &lb, &extent);
95-
ompi_java_exceptionCheck(env, rc);
97+
if(ompi_java_exceptionCheck(env, rc))
98+
return;
9699

97100
jint *lbExt = (*env)->GetIntArrayElements(env, jLbExt, NULL);
98101
lbExt[0] = (jint)lb;
@@ -105,7 +108,8 @@ JNIEXPORT void JNICALL Java_mpi_Datatype_getTrueLbExtent(
105108
{
106109
MPI_Aint lb, extent;
107110
int rc = MPI_Type_get_true_extent((MPI_Datatype)type, &lb, &extent);
108-
ompi_java_exceptionCheck(env, rc);
111+
if(ompi_java_exceptionCheck(env, rc))
112+
return;
109113

110114
jint *lbExt = (*env)->GetIntArrayElements(env, jLbExt, NULL);
111115
lbExt[0] = (jint)lb;

0 commit comments

Comments
 (0)