jboolean ompi_java_exceptionCheck(JNIEnv *env, int rc) { if (rc < 0) { /* handle ompi error code */ rc = ompi_errcode_get_mpi_code (rc); /* ompi_mpi_errcode_get_class CAN NOT handle negative error codes. * all Open MPI MPI error codes should be > 0. */ assert (rc >= 0); } if(MPI_SUCCESS == rc) { return JNI_FALSE; } else if((*env)->ExceptionCheck(env)) { return JNI_TRUE; } else { int errClass = ompi_mpi_errcode_get_class(rc); char *message = ompi_mpi_errnum_get_string(rc); jstring jmessage = (*env)->NewStringUTF(env, (const char*)message); jobject mpiex = (*env)->NewObject(env, ompi_java.ExceptionClass, ompi_java.ExceptionInit, rc, errClass, jmessage); (*env)->Throw(env, mpiex); (*env)->DeleteLocalRef(env, mpiex); (*env)->DeleteLocalRef(env, jmessage); return JNI_TRUE; } }
int MPI_Init(int *argc, char ***argv) { int err; int provided; char *env; int required = MPI_THREAD_SINGLE; /* Ensure that we were not already initialized or finalized */ if (ompi_mpi_finalized) { if (0 == ompi_comm_rank(MPI_COMM_WORLD)) { orte_show_help("help-mpi-api.txt", "mpi-function-after-finalize", true, FUNC_NAME); } return ompi_errhandler_invoke(NULL, NULL, OMPI_ERRHANDLER_TYPE_COMM, MPI_ERR_OTHER, FUNC_NAME); } else if (ompi_mpi_initialized) { if (0 == ompi_comm_rank(MPI_COMM_WORLD)) { orte_show_help("help-mpi-api.txt", "mpi-initialize-twice", true, FUNC_NAME); } return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME); } /* check for environment overrides for required thread level. If there is, check to see that it is a valid/supported thread level. If not, default to MPI_THREAD_MULTIPLE. */ if (NULL != (env = getenv("OMPI_MPI_THREAD_LEVEL"))) { required = atoi(env); if (required < MPI_THREAD_SINGLE || required > MPI_THREAD_MULTIPLE) { required = MPI_THREAD_MULTIPLE; } } /* Call the back-end initialization function (we need to put as little in this function as possible so that if it's profiled, we don't lose anything) */ if (NULL != argc && NULL != argv) { err = ompi_mpi_init(*argc, *argv, required, &provided); } else { err = ompi_mpi_init(0, NULL, required, &provided); } /* Since we don't have a communicator to invoke an errorhandler on here, don't use the fancy-schmancy ERRHANDLER macros; they're really designed for real communicator objects. Just use the back-end function directly. */ if (MPI_SUCCESS != err) { return ompi_errhandler_invoke(NULL, NULL, OMPI_ERRHANDLER_TYPE_COMM, err < 0 ? ompi_errcode_get_mpi_code(err) : err, FUNC_NAME); } OPAL_CR_INIT_LIBRARY(); return MPI_SUCCESS; }
int MPI_Init_thread(int *argc, char ***argv, int required, int *provided) { int err; ompi_hook_base_mpi_init_thread_top(argc, argv, required, provided); if ( MPI_PARAM_CHECK ) { if (required < MPI_THREAD_SINGLE || required > MPI_THREAD_MULTIPLE) { ompi_mpi_errors_are_fatal_comm_handler(NULL, NULL, FUNC_NAME); } } *provided = required; /* Call the back-end initialization function (we need to put as little in this function as possible so that if it's profiled, we don't lose anything) */ if (NULL != argc && NULL != argv) { err = ompi_mpi_init(*argc, *argv, required, provided, false); } else { err = ompi_mpi_init(0, NULL, required, provided, false); } /* Since we don't have a communicator to invoke an errorhandler on here, don't use the fancy-schmancy ERRHANDLER macros; they're really designed for real communicator objects. Just use the back-end function directly. */ if (MPI_SUCCESS != err) { return ompi_errhandler_invoke(NULL, NULL, OMPI_ERRHANDLER_TYPE_COMM, err < 0 ? ompi_errcode_get_mpi_code(err) : err, FUNC_NAME); } OPAL_CR_INIT_LIBRARY(); SPC_INIT(); ompi_hook_base_mpi_init_thread_bottom(argc, argv, required, provided); return MPI_SUCCESS; }
int MPI_Finalized(int *flag) { OPAL_CR_NOOP_PROGRESS(); /* We must obtain the lock to guarnatee consistent values of ompi_mpi_initialized and ompi_mpi_finalized. Note, too, that this lock is held for the bulk of the duration of ompi_mpi_init() and ompi_mpi_finalize(), so when we get the lock, we are guaranteed that some other thread is not part way through initialization or finalization. */ opal_mutex_lock(&ompi_mpi_bootstrap_mutex); if (MPI_PARAM_CHECK) { if (NULL == flag) { /* If we have an error, the action that we take depends on whether we're currently (after MPI_Init and before MPI_Finalize) or not */ if (ompi_mpi_initialized && !ompi_mpi_finalized) { opal_mutex_unlock(&ompi_mpi_bootstrap_mutex); return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); } else { opal_mutex_unlock(&ompi_mpi_bootstrap_mutex); /* We have no MPI object here so call ompi_errhandle_invoke * directly */ return ompi_errhandler_invoke(NULL, NULL, -1, ompi_errcode_get_mpi_code(MPI_ERR_ARG), FUNC_NAME); } } } *flag = ompi_mpi_finalized; opal_mutex_unlock(&ompi_mpi_bootstrap_mutex); return MPI_SUCCESS; }
int MPI_Get_version(int *version, int *subversion) { OPAL_CR_NOOP_PROGRESS(); if (MPI_PARAM_CHECK) { /* Per MPI-2:3.1, this function can be invoked before MPI_INIT, so we don't invoke the normal MPI_ERR_INIT_FINALIZE() macro here */ if (NULL == version || NULL == subversion) { /* Note that we have to check and see if we have previously called MPI_INIT or not. If so, use the normal OMPI_ERRHANDLER_INVOKE, because the user may have changed the default errhandler on MPI_COMM_WORLD. If we have not invoked MPI_INIT, then just abort (i.e., use a NULL communicator, which will end up at the default errhandler, which is abort). */ if (ompi_mpi_initialized && !ompi_mpi_finalized) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); } else { /* We have no MPI object here so call ompi_errhandle_invoke * directly */ return ompi_errhandler_invoke(NULL, NULL, -1, ompi_errcode_get_mpi_code(MPI_ERR_ARG), FUNC_NAME); } } } /* According to the MPI-2 specification */ *version = MPI_VERSION; *subversion = MPI_SUBVERSION; return MPI_SUCCESS; }
int MPI_Init(int *argc, char ***argv) { int err; int provided; char *env; int required = MPI_THREAD_SINGLE; /* Ensure that we were not already initialized or finalized */ if (ompi_mpi_finalized) { if (0 == ompi_comm_rank(MPI_COMM_WORLD)) { opal_show_help("help-mpi-api.txt", "mpi-function-after-finalize", true, FUNC_NAME); } return ompi_errhandler_invoke(NULL, NULL, OMPI_ERRHANDLER_TYPE_COMM, MPI_ERR_OTHER, FUNC_NAME); } else if (ompi_mpi_initialized) { if (0 == ompi_comm_rank(MPI_COMM_WORLD)) { opal_show_help("help-mpi-api.txt", "mpi-initialize-twice", true, FUNC_NAME); } return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME); } /* check for environment overrides for required thread level. If there is, check to see that it is a valid/supported thread level. If not, default to MPI_THREAD_MULTIPLE. */ if (NULL != (env = getenv("OMPI_MPI_THREAD_LEVEL"))) { required = atoi(env); if (required < MPI_THREAD_SINGLE || required > MPI_THREAD_MULTIPLE) { required = MPI_THREAD_MULTIPLE; } } /* Call the back-end initialization function (we need to put as little in this function as possible so that if it's profiled, we don't lose anything) */ if (NULL != argc && NULL != argv) { err = ompi_mpi_init(*argc, *argv, required, &provided); } else { err = ompi_mpi_init(0, NULL, required, &provided); } /* Since we don't have a communicator to invoke an errorhandler on here, don't use the fancy-schmancy ERRHANDLER macros; they're really designed for real communicator objects. Just use the back-end function directly. */ if (MPI_SUCCESS != err) { return ompi_errhandler_invoke(NULL, NULL, OMPI_ERRHANDLER_TYPE_COMM, err < 0 ? ompi_errcode_get_mpi_code(err) : err, FUNC_NAME); } OPAL_CR_INIT_LIBRARY(); //Assume we have now the MPI_COMM_WORLD Communicator!!! void *dvMgmt_dlhandle; int (*commsBenchmark)(commsInfo*); char *error; dvMgmt_dlhandle = dlopen("libdvMgmt.so", RTLD_LAZY); if (!dvMgmt_dlhandle) { printf("Details:"); fputs(dlerror(), stderr); exit(1); } commsBenchmark = dlsym(dvMgmt_dlhandle, "commsBenchmark"); commsInfo cmf; cmf.BW_Mtx = NULL; char* profileFlag; int profilingEnabled = 0; profileFlag = getenv("XSCALA_PROFILING_APP"); if (profileFlag != NULL) { profilingEnabled = 1; } if (profilingEnabled) { (*commsBenchmark)(&cmf); } return MPI_SUCCESS; }