root/oshmem/mca/spml/base/spml_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_spml_base_register
  2. mca_spml_base_finalize
  3. mca_spml_base_close
  4. mca_spml_base_open

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2013      Mellanox Technologies, Inc.
   4  *                         All rights reserved.
   5  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
   6  *                         reserved.
   7  * Copyright (c) 2015      Research Organization for Information Science
   8  *                         and Technology (RIST). All rights reserved.
   9  * $COPYRIGHT$
  10  *
  11  * Additional copyrights may follow
  12  *
  13  * $HEADER$
  14  */
  15 
  16 #include "oshmem_config.h"
  17 #include <stdio.h>
  18 
  19 #include <string.h>
  20 #ifdef HAVE_UNISTD_H
  21 #include <unistd.h>
  22 #endif  /* HAVE_UNIST_H */
  23 #include "oshmem/mca/mca.h"
  24 #include "opal/util/output.h"
  25 #include "opal/mca/base/base.h"
  26 
  27 #include "oshmem/constants.h"
  28 #include "oshmem/util/oshmem_util.h"
  29 #include "oshmem/mca/spml/spml.h"
  30 #include "oshmem/mca/spml/base/base.h"
  31 #include "oshmem/mca/spml/base/spml_base_request.h"
  32 
  33 /*
  34  * The following file was created by configure.  It contains extern
  35  * statements and the definition of an array of pointers to each
  36  * component's public mca_base_component_t struct.
  37  */
  38 
  39 #include "oshmem/mca/spml/base/static-components.h"
  40 
  41 #define xstringify(spml) #spml
  42 #define stringify(spml) xstringify(spml)
  43 
  44 /*
  45  * Global variables
  46  */
  47 mca_spml_base_module_t mca_spml = {0};
  48 
  49 mca_spml_base_component_t mca_spml_base_selected_component = {{0}};
  50 opal_pointer_array_t mca_spml_base_spml = {{0}};
  51 
  52 
  53 static int mca_spml_base_register(mca_base_register_flag_t flags)
  54 {
  55     return OMPI_SUCCESS;
  56 }
  57 
  58 int mca_spml_base_finalize(void)
  59 {
  60     if (NULL != mca_spml_base_selected_component.spmlm_finalize) {
  61         return mca_spml_base_selected_component.spmlm_finalize();
  62     }
  63     return OSHMEM_SUCCESS;
  64 }
  65 
  66 static int mca_spml_base_close(void)
  67 {
  68     int i, j;
  69 
  70     /**
  71      * Destruct the send and receive queues. The opal_free_list_t destructor
  72      * will return the memory to the mpool, so this has to be done before the
  73      * mpool get released by the SPML close function.
  74      */
  75     OBJ_DESTRUCT(&mca_spml_base_put_requests);
  76     OBJ_DESTRUCT(&mca_spml_base_get_requests);
  77 
  78     /* Free all the strings in the array */
  79     j = opal_pointer_array_get_size(&mca_spml_base_spml);
  80     for (i = 0; i < j; i++) {
  81         char * tmp_val;
  82         tmp_val = (char *) opal_pointer_array_get_item(&mca_spml_base_spml, i);
  83         if (NULL == tmp_val) {
  84             continue;
  85         }
  86         free(tmp_val);
  87     }
  88     OBJ_DESTRUCT(&mca_spml_base_spml);
  89 
  90     /* Close all remaining available components */
  91     return mca_base_framework_components_close(&oshmem_spml_base_framework, NULL);
  92 }
  93 
  94 /**
  95  * Function for finding and opening either all MCA components, or the one
  96  * that was specifically requested via a MCA parameter.
  97  */
  98 static int mca_spml_base_open(mca_base_open_flag_t flags)
  99 {
 100     /**
 101      * Construct the send and receive request queues. There are 2 reasons to do it
 102      * here. First, as they are globals it's better to construct them in one common
 103      * place. Second, in order to be able to allow the external debuggers to show
 104      * their content, they should get constructed as soon as possible once the MPI
 105      * process is started.
 106      */
 107     OBJ_CONSTRUCT(&mca_spml_base_put_requests, opal_free_list_t);
 108     OBJ_CONSTRUCT(&mca_spml_base_get_requests, opal_free_list_t);
 109 
 110     OBJ_CONSTRUCT(&mca_spml_base_spml, opal_pointer_array_t);
 111 
 112     oshmem_framework_open_output(&oshmem_spml_base_framework);
 113 
 114     /* Open up all available components */
 115     if (OPAL_SUCCESS !=
 116         mca_base_framework_components_open(&oshmem_spml_base_framework, flags)) {
 117         return OSHMEM_ERROR;
 118     }
 119 
 120     /* Set a sentinel in case we don't select any components (e.g.,
 121        ompi_info) */
 122 
 123     mca_spml_base_selected_component.spmlm_finalize = NULL;
 124 
 125     /**
 126      * Right now our selection of BTLs is completely broken. If we have
 127      * multiple SPMLs that use BTLs than we will open all BTLs several times, leading to
 128      * undefined behaviors. The simplest solution, at least until we
 129      * figure out the correct way to do it, is to force a default SPML that
 130      * uses BTLs and any other SPMLs that do not in the mca_spml_base_spml array.
 131      */
 132 
 133 #if MCA_ompi_pml_DIRECT_CALL
 134     opal_pointer_array_add(&mca_spml_base_spml,
 135                            strdup(stringify(MCA_oshmem_spml_DIRECT_CALL_COMPONENT)));
 136 #else
 137     {
 138         const char **default_spml = NULL;
 139         int var_id;
 140 
 141         var_id = mca_base_var_find("oshmem", "spml", NULL, NULL);
 142         mca_base_var_get_value(var_id, &default_spml, NULL, NULL);
 143 
 144         if( (NULL == default_spml || NULL == default_spml[0] ||
 145              0 == strlen(default_spml[0])) || (default_spml[0][0] == '^') ) {
 146             opal_pointer_array_add(&mca_spml_base_spml, strdup("ikrit"));
 147             opal_pointer_array_add(&mca_spml_base_spml, strdup("ucx"));
 148         } else {
 149             opal_pointer_array_add(&mca_spml_base_spml, strdup(default_spml[0]));
 150         }
 151     }
 152 #endif
 153 
 154     return OSHMEM_SUCCESS;
 155 }
 156 
 157 MCA_BASE_FRAMEWORK_DECLARE(oshmem, spml,
 158                            "OSHMEM SPML",
 159                            mca_spml_base_register,
 160                            mca_spml_base_open,
 161                            mca_spml_base_close,
 162                            mca_spml_base_static_components,
 163                            MCA_BASE_FRAMEWORK_FLAG_DEFAULT);

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