This source file includes following definitions.
- mca_memheap_base_register
- mca_memheap_base_close
- mca_memheap_base_open
1
2
3
4
5
6
7
8
9
10
11
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
27
28
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
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
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);