int main( int argc, char *argv[] ) { int buf[2]; MPI_Win win; MPI_Errhandler newerr; int i; MTest_Init( &argc, &argv ); /* Run this test multiple times to expose storage leaks (we found a leak of error handlers with this test) */ for (i=0;i<1000; i++) { calls = 0; MPI_Win_create( buf, 2*sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win ); mywin = win; MPI_Win_create_errhandler( eh, &newerr ); MPI_Win_set_errhandler( win, newerr ); MPI_Win_call_errhandler( win, MPI_ERR_OTHER ); MPI_Errhandler_free( &newerr ); if (calls != 1) { errs++; printf( "Error handler not called\n" ); } MPI_Win_free( &win ); } MTest_Finalize( errs ); MPI_Finalize(); return 0; }
int main(int argc, char *argv[]) { int err; int buf[2]; MPI_Win win; MPI_Comm comm; MPI_Errhandler newerr, olderr; MTEST_VG_MEM_INIT(buf, 2 * sizeof(int)); MTest_Init(&argc, &argv); comm = MPI_COMM_WORLD; MPI_Win_create_errhandler(weh, &newerr); MPI_Win_create(buf, 2 * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win); mywin = win; MPI_Win_get_errhandler(win, &olderr); if (olderr != MPI_ERRORS_ARE_FATAL) { errs++; printf("Expected errors are fatal\n"); } MPI_Win_set_errhandler(win, newerr); expected_err_class = MPI_ERR_RANK; err = MPI_Put(buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win); if (calls != 1) { errs++; printf("newerr not called\n"); calls = 1; } expected_err_class = MPI_ERR_OTHER; MPI_Win_call_errhandler(win, MPI_ERR_OTHER); if (calls != 2) { errs++; printf("newerr not called (2)\n"); } MPI_Win_free(&win); MPI_Errhandler_free(&newerr); MTest_Finalize(errs); return MTestReturnValue(errs); }
/* * Class: mpi_Win * Method: callErrhandler * Signature: (JI)V */ JNIEXPORT void JNICALL Java_mpi_Win_callErrhandler( JNIEnv *env, jobject jthis, jlong win, jint errorCode) { int rc = MPI_Win_call_errhandler((MPI_Win)win, errorCode); ompi_java_exceptionCheck(env, rc); }
int main( int argc, char *argv[] ) { int err; int buf[2]; MPI_Win win; MPI_Comm comm; MPI_Errhandler newerr1, newerr2, olderr; MTest_Init( &argc, &argv ); comm = MPI_COMM_WORLD; MPI_Win_create_errhandler( weh1, &newerr1 ); MPI_Win_create_errhandler( weh2, &newerr2 ); MPI_Win_create( buf, 2*sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win ); mywin = win; MPI_Win_get_errhandler( win, &olderr ); if (olderr != MPI_ERRORS_ARE_FATAL) { errs++; printf( "Expected errors are fatal\n" ); } MPI_Win_set_errhandler( win, newerr1 ); /* We should be able to free the error handler now since the window is using it */ MPI_Errhandler_free( &newerr1 ); expected_err_class = MPI_ERR_RANK; err = MPI_Put( buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win ); if (w1Called != 1) { errs ++; printf( "newerr1 not called\n" ); w1Called = 1; } expected_err_class = MPI_ERR_OTHER; MPI_Win_call_errhandler( win, MPI_ERR_OTHER ); if (w1Called != 2) { errs ++; printf( "newerr1 not called (2)\n" ); } if (w1Called != 2 || w2Called != 0) { errs++; printf( "Error handler weh1 not called the expected number of times\n" ); } /* Try another error handler. This should allow the MPI implementation to free the first error handler */ MPI_Win_set_errhandler( win, newerr2 ); MPI_Errhandler_free( &newerr2 ); expected_err_class = MPI_ERR_RANK; err = MPI_Put( buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win ); if (w2Called != 1) { errs ++; printf( "newerr2 not called\n" ); calls = 1; } expected_err_class = MPI_ERR_OTHER; MPI_Win_call_errhandler( win, MPI_ERR_OTHER ); if (w2Called != 2) { errs ++; printf( "newerr2 not called (2)\n" ); } if (w1Called != 2 || w2Called != 2) { errs++; printf( "Error handler weh1 not called the expected number of times\n" ); } MPI_Win_free( &win ); MTest_Finalize( errs ); MPI_Finalize(); return 0; }