root/ompi/mca/pml/base/pml_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_pml_base_progress
  2. mca_pml_base_register
  3. mca_pml_base_finalize
  4. mca_pml_base_close
  5. mca_pml_base_open

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2007 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2009      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
  15  *                         reserved.
  16  * Copyright (c) 2015      Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 
  25 
  26 #include "ompi_config.h"
  27 #include <stdio.h>
  28 
  29 #include <string.h>
  30 #ifdef HAVE_UNISTD_H
  31 #include <unistd.h>
  32 #endif  /* HAVE_UNIST_H */
  33 #include "ompi/mca/mca.h"
  34 #include "opal/util/output.h"
  35 #include "opal/mca/base/base.h"
  36 
  37 
  38 #include "ompi/constants.h"
  39 #include "ompi/mca/pml/pml.h"
  40 #include "ompi/mca/pml/base/base.h"
  41 #include "ompi/mca/pml/base/pml_base_request.h"
  42 
  43 /*
  44  * The following file was created by configure.  It contains extern
  45  * statements and the definition of an array of pointers to each
  46  * component's public mca_base_component_t struct.
  47  */
  48 
  49 #include "ompi/mca/pml/base/static-components.h"
  50 
  51 int mca_pml_base_progress(void)
  52 {
  53     return OMPI_SUCCESS;
  54 }
  55 
  56 #define xstringify(pml) #pml
  57 #define stringify(pml) xstringify(pml)
  58 
  59 /*
  60  * Global variables
  61  */
  62 mca_pml_base_module_t mca_pml = {
  63     NULL,                    /* pml_add_procs */
  64     NULL,                    /* pml_del_procs */
  65     NULL,                    /* pml_enable */
  66     mca_pml_base_progress,   /* pml_progress */
  67     NULL,                    /* pml_add_comm */
  68     NULL,                    /* pml_del_comm */
  69     NULL,                    /* pml_irecv_init */
  70     NULL,                    /* pml_irecv */
  71     NULL,                    /* pml_recv */
  72     NULL,                    /* pml_isend_init */
  73     NULL,                    /* pml_isend */
  74     NULL,                    /* pml_send */
  75     NULL,                    /* pml_iprobe */
  76     NULL,                    /* pml_probe */
  77     NULL,                    /* pml_start */
  78     NULL,                    /* pml_dump */
  79     NULL,                    /* pml_ft_event */
  80     0,                       /* pml_max_contextid */
  81     0                        /* pml_max_tag */
  82 };
  83 
  84 mca_pml_base_component_t mca_pml_base_selected_component = {{0}};
  85 opal_pointer_array_t mca_pml_base_pml = {{0}};
  86 char *ompi_pml_base_bsend_allocator_name = NULL;
  87 
  88 #if !MCA_ompi_pml_DIRECT_CALL && OPAL_ENABLE_FT_CR == 1
  89 static char *ompi_pml_base_wrapper = NULL;
  90 #endif
  91 
  92 static int mca_pml_base_register(mca_base_register_flag_t flags)
  93 {
  94 #if !MCA_ompi_pml_DIRECT_CALL && OPAL_ENABLE_FT_CR == 1
  95     int var_id;
  96 #endif
  97 
  98     ompi_pml_base_bsend_allocator_name = "basic";
  99     (void) mca_base_var_register("ompi", "pml", "base", "bsend_allocator", NULL,
 100                                  MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
 101                                  OPAL_INFO_LVL_9,
 102                                  MCA_BASE_VAR_SCOPE_READONLY,
 103                                  &ompi_pml_base_bsend_allocator_name);
 104 
 105 #if !MCA_ompi_pml_DIRECT_CALL && OPAL_ENABLE_FT_CR == 1
 106     ompi_pml_base_wrapper = NULL;
 107     var_id = mca_base_var_register("ompi", "pml", "base", "wrapper",
 108                                    "Use a Wrapper component around the selected PML component",
 109                                    MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
 110                                    OPAL_INFO_LVL_9,
 111                                    MCA_BASE_VAR_SCOPE_READONLY,
 112                                    &ompi_pml_base_wrapper);
 113     (void) mca_base_var_register_synonym(var_id, "ompi", "pml", NULL, "wrapper", 0);
 114 #endif
 115 
 116     return OMPI_SUCCESS;
 117 }
 118 
 119 int mca_pml_base_finalize(void) {
 120   if (NULL != mca_pml_base_selected_component.pmlm_finalize) {
 121     return mca_pml_base_selected_component.pmlm_finalize();
 122   }
 123   return OMPI_SUCCESS;
 124 }
 125 
 126 
 127 static int mca_pml_base_close(void)
 128 {
 129     int i, j;
 130 
 131     /* turn off the progress code for the pml */
 132     if( NULL != mca_pml.pml_progress ) {
 133         opal_progress_unregister(mca_pml.pml_progress);
 134     }
 135 
 136     /* Blatently ignore the return code (what would we do to recover,
 137        anyway?  This module is going away, so errors don't matter
 138        anymore) */
 139 
 140     /**
 141      * Destruct the send and receive queues. The opal_free_list_t destructor
 142      * will return the memory to the mpool, so this has to be done before the
 143      * mpool get released by the PML close function.
 144      */
 145     OBJ_DESTRUCT(&mca_pml_base_send_requests);
 146     OBJ_DESTRUCT(&mca_pml_base_recv_requests);
 147 
 148     mca_pml.pml_progress = mca_pml_base_progress;
 149 
 150     /* Free all the strings in the array */
 151     j = opal_pointer_array_get_size(&mca_pml_base_pml);
 152     for (i = 0; i < j; ++i) {
 153         char *str;
 154         str = (char*) opal_pointer_array_get_item(&mca_pml_base_pml, i);
 155         free(str);
 156     }
 157     OBJ_DESTRUCT(&mca_pml_base_pml);
 158 
 159     /* Close all remaining available components */
 160     return mca_base_framework_components_close(&ompi_pml_base_framework, NULL);
 161 }
 162 
 163 /**
 164  * Function for finding and opening either all MCA components, or the one
 165  * that was specifically requested via a MCA parameter.
 166  */
 167 static int mca_pml_base_open(mca_base_open_flag_t flags)
 168 {
 169     /**
 170      * Construct the send and receive request queues. There are 2 reasons to do it
 171      * here. First, as they are globals it's better to construct them in one common
 172      * place. Second, in order to be able to allow the external debuggers to show
 173      * their content, they should get constructed as soon as possible once the MPI
 174      * process is started.
 175      */
 176     OBJ_CONSTRUCT(&mca_pml_base_send_requests, opal_free_list_t);
 177     OBJ_CONSTRUCT(&mca_pml_base_recv_requests, opal_free_list_t);
 178 
 179     OBJ_CONSTRUCT(&mca_pml_base_pml, opal_pointer_array_t);
 180 
 181     /* Open up all available components */
 182 
 183     if (OPAL_SUCCESS !=
 184         mca_base_framework_components_open(&ompi_pml_base_framework, flags)) {
 185         return OMPI_ERROR;
 186     }
 187 
 188     /* Set a sentinel in case we don't select any components (e.g.,
 189        ompi_info) */
 190 
 191     mca_pml_base_selected_component.pmlm_finalize = NULL;
 192 
 193     /**
 194      * Right now our selection of BTLs is completely broken. If we have
 195      * multiple PMLs that use BTLs than we will open all BTLs several times, leading to
 196      * undefined behaviors. The simplest solution, at least until we
 197      * figure out the correct way to do it, is to force a default PML that
 198      * uses BTLs and any other PMLs that do not in the mca_pml_base_pml array.
 199      */
 200 
 201 #if MCA_ompi_pml_DIRECT_CALL
 202     opal_pointer_array_add(&mca_pml_base_pml,
 203                            strdup(stringify(MCA_ompi_pml_DIRECT_CALL_COMPONENT)));
 204 #else
 205     {
 206         const char **default_pml = NULL;
 207         int var_id;
 208 
 209         var_id = mca_base_var_find("ompi", "pml", NULL, NULL);
 210         mca_base_var_get_value(var_id, &default_pml, NULL, NULL);
 211 
 212         if( (NULL == default_pml || NULL == default_pml[0] ||
 213              0 == strlen(default_pml[0])) || (default_pml[0][0] == '^') ) {
 214             opal_pointer_array_add(&mca_pml_base_pml, strdup("ob1"));
 215             opal_pointer_array_add(&mca_pml_base_pml, strdup("yalla"));
 216             opal_pointer_array_add(&mca_pml_base_pml, strdup("ucx"));
 217             opal_pointer_array_add(&mca_pml_base_pml, strdup("cm"));
 218         } else {
 219             opal_pointer_array_add(&mca_pml_base_pml, strdup(default_pml[0]));
 220         }
 221     }
 222 #if OPAL_ENABLE_FT_CR == 1
 223     /*
 224      * Which PML Wrapper component to use, if any
 225      *  - NULL or "" = No wrapper
 226      *  - ow. select that specific wrapper component
 227      */
 228     if( NULL != ompi_pml_base_wrapper) {
 229         opal_pointer_array_add(&mca_pml_base_pml, ompi_pml_base_wrapper);
 230     }
 231 #endif
 232 
 233 #endif
 234 
 235     return OMPI_SUCCESS;
 236 
 237 }
 238 
 239 MCA_BASE_FRAMEWORK_DECLARE(ompi, pml, "OMPI PML", mca_pml_base_register,
 240                            mca_pml_base_open, mca_pml_base_close,
 241                            mca_pml_base_static_components, 0);

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