This source file includes following definitions.
- mca_rcache_base_module_create
- mca_rcache_base_module_destroy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include "opal_config.h"
23
24 #include <stdio.h>
25 #include <string.h>
26
27 #include "opal/mca/mca.h"
28 #include "opal/mca/base/base.h"
29 #include "opal/mca/rcache/rcache.h"
30 #include "opal/mca/rcache/base/base.h"
31 #include "opal/mca/rcache/base/rcache_base_mem_cb.h"
32 #include "rcache_base_vma_tree.h"
33 #include "opal/util/show_help.h"
34 #include "opal/util/proc.h"
35
36 #include "opal/runtime/opal_params.h"
37 #include "opal/memoryhooks/memory.h"
38
39 mca_rcache_base_module_t* mca_rcache_base_module_create (const char* name, void *user_data,
40 struct mca_rcache_base_resources_t* resources)
41 {
42 mca_rcache_base_component_t* component = NULL;
43 mca_rcache_base_module_t* module = NULL;
44 mca_base_component_list_item_t *cli;
45 mca_rcache_base_selected_module_t *sm;
46
47
48
49 if (!mca_rcache_base_used_mem_hooks) {
50
51
52
53
54
55
56
57 if (opal_leave_pinned != 0 || opal_leave_pinned_pipeline) {
58
59
60
61
62 (void) mca_base_framework_open (&opal_memory_base_framework, 0);
63
64 if ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) ==
65 ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) &
66 opal_mem_hooks_support_level())) {
67 if (-1 == opal_leave_pinned) {
68 opal_leave_pinned = !opal_leave_pinned_pipeline;
69 }
70 opal_mem_hooks_register_release(mca_rcache_base_mem_cb, NULL);
71 } else if (1 == opal_leave_pinned || opal_leave_pinned_pipeline) {
72 opal_show_help("help-rcache-base.txt", "leave pinned failed",
73 true, name, OPAL_NAME_PRINT(OPAL_PROC_MY_NAME),
74 opal_proc_local_get()->proc_hostname);
75 return NULL;
76 }
77
78
79
80 mca_rcache_base_used_mem_hooks = 1;
81 }
82 }
83
84 OPAL_LIST_FOREACH(cli, &opal_rcache_base_framework.framework_components, mca_base_component_list_item_t) {
85 component = (mca_rcache_base_component_t *) cli->cli_component;
86 if(0 == strcmp(component->rcache_version.mca_component_name, name)) {
87 module = component->rcache_init (resources);
88 break;
89 }
90 }
91
92 if ( NULL == module ) {
93 return NULL;
94 }
95
96 sm = OBJ_NEW(mca_rcache_base_selected_module_t);
97 sm->rcache_component = component;
98 sm->rcache_module = module;
99 sm->user_data = user_data;
100 opal_list_append(&mca_rcache_base_modules, (opal_list_item_t*) sm);
101
102 return module;
103 }
104
105 int mca_rcache_base_module_destroy(mca_rcache_base_module_t *module)
106 {
107 mca_rcache_base_selected_module_t *sm, *next;
108
109 OPAL_LIST_FOREACH_SAFE(sm, next, &mca_rcache_base_modules, mca_rcache_base_selected_module_t) {
110 if (module == sm->rcache_module) {
111 opal_list_remove_item(&mca_rcache_base_modules, (opal_list_item_t*)sm);
112 if (NULL != sm->rcache_module->rcache_finalize) {
113 sm->rcache_module->rcache_finalize(sm->rcache_module);
114 }
115 OBJ_RELEASE(sm);
116 return OPAL_SUCCESS;
117 }
118 }
119
120 return OPAL_ERR_NOT_FOUND;
121 }