root/oshmem/mca/memheap/base/memheap_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_memheap_base_register
  2. mca_memheap_base_close
  3. mca_memheap_base_open

   1 /*
   2  * Copyright (c) 2013      Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * Copyright (c) 2015-2016 Research Organization for Information Science
   5  *                         and Technology (RIST). All rights reserved.
   6  *
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 #include "oshmem_config.h"
  15 #include <stdio.h>
  16 
  17 #include "oshmem/mca/mca.h"
  18 #include "opal/util/output.h"
  19 #include "opal/mca/base/base.h"
  20 
  21 #include "oshmem/util/oshmem_util.h"
  22 #include "oshmem/mca/memheap/memheap.h"
  23 #include "oshmem/mca/memheap/base/base.h"
  24 
  25 /*
  26  * The following file was created by configure. It contains extern
  27  * statements and the definition of an array of pointers to each
  28  * component's public mca_base_component_t struct.
  29  */
  30 
  31 #include "oshmem/mca/memheap/base/static-components.h"
  32 
  33 
  34 int mca_memheap_base_output = -1;
  35 int mca_memheap_base_key_exchange = 1;
  36 opal_list_t mca_memheap_base_components_opened = {{0}};
  37 int mca_memheap_base_already_opened = 0;
  38 mca_memheap_map_t mca_memheap_base_map = {{{{0}}}};
  39 
  40 static int mca_memheap_base_register(mca_base_register_flag_t flags)
  41 {
  42     (void) mca_base_var_register("oshmem",
  43                                  "memheap",
  44                                  "base",
  45                                  "key_exchange",
  46                                  "0|1 - disabled, enabled(default) force memory keys exchange",
  47                                  MCA_BASE_VAR_TYPE_INT,
  48                                  NULL,
  49                                  0,
  50                                  MCA_BASE_VAR_FLAG_SETTABLE,
  51                                  OPAL_INFO_LVL_9,
  52                                  MCA_BASE_VAR_SCOPE_READONLY,
  53                                  &mca_memheap_base_key_exchange);
  54 
  55     mca_base_var_register("oshmem", "memheap", "base", "device_nic_mem_seg_size",
  56                           "Size of memory block used for allocations with hint SHMEM_HINT_DEVICE_NIC_MEM",
  57                           MCA_BASE_VAR_TYPE_LONG, NULL, 0,
  58                           MCA_BASE_VAR_FLAG_SETTABLE, OPAL_INFO_LVL_3,
  59                           MCA_BASE_VAR_SCOPE_LOCAL,
  60                           &mca_memheap_base_config.device_nic_mem_seg_size);
  61 
  62     return OSHMEM_SUCCESS;
  63 }
  64 
  65 static int mca_memheap_base_close(void)
  66 {
  67     if (mca_memheap_base_already_opened <= 0) {
  68         return OSHMEM_ERROR;
  69     }
  70     mca_memheap_base_already_opened--;
  71     if (mca_memheap_base_already_opened > 0) {
  72         return OSHMEM_SUCCESS;
  73     }
  74 
  75     memheap_oob_destruct();
  76 
  77     mca_memheap_base_dereg(&mca_memheap_base_map);
  78 
  79     mca_memheap_base_alloc_exit(&mca_memheap_base_map);
  80     mca_memheap_base_static_exit(&mca_memheap_base_map);
  81 
  82     /* Close all remaining available components */
  83     return mca_base_framework_components_close(&oshmem_memheap_base_framework, NULL);
  84 }
  85 
  86 static int mca_memheap_base_open(mca_base_open_flag_t flags)
  87 {
  88     mca_memheap_base_already_opened = mca_memheap_base_already_opened + 1;
  89     if (mca_memheap_base_already_opened > 1) {
  90         return OSHMEM_SUCCESS;
  91     }
  92 
  93     memset(&mca_memheap_base_map, 0, sizeof(mca_memheap_base_map));
  94     mca_memheap_base_map.n_segments = 0;
  95     mca_memheap_base_map.num_transports = 0;
  96 
  97     oshmem_framework_open_output(&oshmem_memheap_base_framework);
  98 
  99     /* Open up all available components */
 100     if (OPAL_SUCCESS !=
 101         mca_base_framework_components_open(&oshmem_memheap_base_framework, flags)) {
 102         return OSHMEM_ERROR;
 103     }
 104 
 105     return OSHMEM_SUCCESS;
 106 }
 107 
 108 MCA_BASE_FRAMEWORK_DECLARE(oshmem, memheap,
 109                            "OSHMEM MEMHEAP",
 110                            mca_memheap_base_register,
 111                            mca_memheap_base_open,
 112                            mca_memheap_base_close,
 113                            mca_memheap_base_static_components,
 114                            MCA_BASE_FRAMEWORK_FLAG_DEFAULT);

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