root/oshmem/shmem/c/shmem_init.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. shmem_init
  2. shmem_init_thread
  3. start_pes
  4. shmem_onexit
  5. _shmem_init

   1 /*
   2  * Copyright (c) 2013-2015 Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * Copyright (c) 2016-2019 Research Organization for Information Science
   5  *                         and Technology (RIST).  All rights reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 
  13 #include "oshmem_config.h"
  14 
  15 #include <stdlib.h>
  16 
  17 #include "opal/runtime/opal_cr.h"
  18 #include "opal/util/output.h"
  19 
  20 #include "oshmem/constants.h"
  21 #include "oshmem/include/shmem.h"
  22 #include "oshmem/runtime/params.h"
  23 #include "oshmem/runtime/runtime.h"
  24 #include "oshmem/shmem/shmem_api_logger.h"
  25 
  26 #if OSHMEM_PROFILING
  27 #include "oshmem/include/pshmem.h"
  28 #pragma weak shmem_init = pshmem_init
  29 #pragma weak shmem_init_thread = pshmem_init_thread
  30 #pragma weak start_pes = pstart_pes
  31 #include "oshmem/shmem/c/profile/defines.h"
  32 #endif
  33 
  34 extern int oshmem_shmem_globalexit_status;
  35 
  36 static inline void _shmem_init(int required, int *provided);
  37 
  38 void shmem_init(void)
  39 {
  40     int provided;
  41     /* spec says that npes are ignored for now */
  42     _shmem_init(SHMEM_THREAD_SINGLE, &provided);
  43 }
  44 
  45 int shmem_init_thread(int requested, int *provided)
  46 {
  47     _shmem_init(requested, provided);
  48     return 0;
  49 }
  50 
  51 void start_pes(int npes)
  52 {
  53     int provided;
  54     /* spec says that npes are ignored for now */
  55     _shmem_init(SHMEM_THREAD_SINGLE, &provided);
  56 }
  57 
  58 static void shmem_onexit(int exitcode, void *arg)
  59 {
  60     oshmem_shmem_globalexit_status = exitcode;
  61     shmem_finalize();
  62 }
  63 
  64 static inline void _shmem_init(int required, int *provided)
  65 {
  66     int err = OSHMEM_SUCCESS;
  67 
  68     if (oshmem_shmem_initialized) {
  69         /*
  70          * SPEC: If start_pes() is called multiple times, subsequent calls have no effect.
  71          */
  72         return;
  73     }
  74 
  75     err = oshmem_shmem_init(0, NULL, required, provided);
  76     if (OSHMEM_SUCCESS != err) {
  77         /* since spec does not propagete error to user we can only abort */
  78         SHMEM_API_ERROR("SHMEM failed to initialize - aborting");
  79         oshmem_shmem_abort(-1);
  80     }
  81 
  82     OPAL_CR_INIT_LIBRARY();
  83 #if HAVE_ON_EXIT
  84     on_exit(shmem_onexit, NULL);
  85 #endif
  86 }
  87 

/* [<][>][^][v][top][bottom][index][help] */