root/opal/mca/mpool/base/mpool_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_mpool_base_register
  2. mca_mpool_base_open
  3. mca_mpool_base_close

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 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) 2007-2009 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2013      NVIDIA Corporation.  All rights reserved.
  15  * Copyright (c) 2014-2017 Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
  18  *                         reserved.
  19  * $COPYRIGHT$
  20  *
  21  * Additional copyrights may follow
  22  *
  23  * $HEADER$
  24  */
  25 
  26 #include "opal_config.h"
  27 
  28 #include <stdio.h>
  29 #include <stdlib.h>
  30 #ifdef HAVE_UNISTD_H
  31 #include <unistd.h>
  32 #endif  /* HAVE_UNISTD_H */
  33 
  34 #include "opal/mca/mca.h"
  35 #include "opal/mca/base/base.h"
  36 #include "opal/mca/mpool/base/base.h"
  37 #include "opal/constants.h"
  38 #include "opal/util/sys_limits.h"
  39 
  40 /*
  41  * The following file was created by configure.  It contains extern
  42  * statements and the definition of an array of pointers to each
  43  * component's public mca_base_component_t struct.
  44  */
  45 #include "opal/mca/mpool/base/static-components.h"
  46 
  47 #include "mpool_base_tree.h"
  48 /*
  49  * Global variables
  50  */
  51 
  52 opal_list_t mca_mpool_base_modules = {{0}};
  53 static char *mca_mpool_base_default_hints;
  54 
  55 int mca_mpool_base_default_priority = 50;
  56 
  57 OBJ_CLASS_INSTANCE(mca_mpool_base_selected_module_t, opal_list_item_t, NULL, NULL);
  58 
  59 static int mca_mpool_base_register (mca_base_register_flag_t flags)
  60 {
  61     mca_mpool_base_default_hints = NULL;
  62     (void) mca_base_var_register ("opal", "mpool", "base", "default_hints",
  63                                   "Hints to use when selecting the default memory pool",
  64                                   MCA_BASE_VAR_TYPE_STRING, NULL, 0,
  65                                   MCA_BASE_VAR_FLAG_INTERNAL,
  66                                   OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL,
  67                                   &mca_mpool_base_default_hints);
  68 
  69     mca_mpool_base_default_priority = 50;
  70     (void) mca_base_var_register ("opal", "mpool", "base", "default_priority",
  71                                   "Priority of the default mpool module",
  72                                   MCA_BASE_VAR_TYPE_INT, NULL, 0,
  73                                   MCA_BASE_VAR_FLAG_INTERNAL,
  74                                   OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL,
  75                                   &mca_mpool_base_default_priority);
  76 
  77     return OPAL_SUCCESS;
  78 }
  79 
  80 /**
  81  * Function for finding and opening either all MCA components, or the one
  82  * that was specifically requested via a MCA parameter.
  83  */
  84 static int mca_mpool_base_open(mca_base_open_flag_t flags)
  85 {
  86     /* Open up all available components - and populate the
  87        opal_mpool_base_framework.framework_components list */
  88     if (OPAL_SUCCESS !=
  89         mca_base_framework_components_open(&opal_mpool_base_framework, flags)) {
  90         return OPAL_ERROR;
  91     }
  92 
  93     if (mca_mpool_base_default_hints) {
  94         mca_mpool_base_default_module = mca_mpool_base_module_lookup (mca_mpool_base_default_hints);
  95     }
  96 
  97      /* Initialize the list so that in mca_mpool_base_close(), we can
  98         iterate over it (even if it's empty, as in the case of opal_info) */
  99     OBJ_CONSTRUCT(&mca_mpool_base_modules, opal_list_t);
 100 
 101     /* setup tree for tracking MPI_Alloc_mem */
 102     mca_mpool_base_tree_init();
 103 
 104     return OPAL_SUCCESS;
 105 }
 106 
 107 static int mca_mpool_base_close(void)
 108 {
 109   opal_list_item_t *item;
 110   mca_mpool_base_selected_module_t *sm;
 111 
 112   /* Finalize all the mpool components and free their list items */
 113 
 114   while(NULL != (item = opal_list_remove_first(&mca_mpool_base_modules))) {
 115     sm = (mca_mpool_base_selected_module_t *) item;
 116 
 117     /* Blatently ignore the return code (what would we do to recover,
 118        anyway?  This component is going away, so errors don't matter
 119        anymore).  Note that it's legal for the module to have NULL for
 120        the finalize function. */
 121 
 122     if (NULL != sm->mpool_module->mpool_finalize) {
 123         sm->mpool_module->mpool_finalize(sm->mpool_module);
 124     }
 125     OBJ_RELEASE(sm);
 126   }
 127 
 128   /* Close all remaining available components (may be one if this is a
 129      OMPI RTE program, or [possibly] multiple if this is opal_info) */
 130   (void) mca_base_framework_components_close(&opal_mpool_base_framework, NULL);
 131 
 132   mca_mpool_base_tree_fini();
 133 
 134   return OPAL_SUCCESS;
 135 }
 136 
 137 MCA_BASE_FRAMEWORK_DECLARE(opal, mpool, "Memory pools", mca_mpool_base_register, mca_mpool_base_open,
 138                            mca_mpool_base_close, mca_mpool_base_static_components, 0);

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