Ejemplo n.º 1
0
void shmem_init(void)
{
    int err = OSHMEM_SUCCESS;
    int provided;
    int required = SHMEM_THREAD_SINGLE;

    if (oshmem_shmem_initialized) {
        /*
         * SPEC: If start_pes() is called multiple times, subsequent calls have no effect.
         */
        return;
    }

    shmem_api_logger_output = opal_output_open(NULL);
    opal_output_set_verbosity(shmem_api_logger_output,
                              oshmem_shmem_api_verbose);

    err = oshmem_shmem_init(0, NULL, required, &provided);
    if (OSHMEM_SUCCESS != err) {
        /* since spec does not propagete error to user we can only abort */
        SHMEM_API_ERROR("SHMEM failed to initialize - aborting");
        oshmem_shmem_abort(-1);
    }

    OPAL_CR_INIT_LIBRARY();
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
static inline void _shmem_init(int required, int *provided)
{
    int err = OSHMEM_SUCCESS;

    if (oshmem_shmem_initialized) {
        /*
         * SPEC: If start_pes() is called multiple times, subsequent calls have no effect.
         */
        return;
    }

    err = oshmem_shmem_init(0, NULL, required, provided);
    if (OSHMEM_SUCCESS != err) {
        /* since spec does not propagete error to user we can only abort */
        SHMEM_API_ERROR("SHMEM failed to initialize - aborting");
        oshmem_shmem_abort(-1);
    }

    OPAL_CR_INIT_LIBRARY();
#if HAVE_ON_EXIT
    on_exit(shmem_onexit, NULL);
#endif
}
Ejemplo n.º 5
0
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;
}