This source file includes following definitions.
- mca_memheap_base_mkey_is_shm
- mca_memheap_base_can_local_copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #ifndef MCA_MEMHEAP_H
15 #define MCA_MEMHEAP_H
16 #include "oshmem/mca/mca.h"
17 #include "oshmem/constants.h"
18 #include "oshmem/proc/proc.h"
19
20 #include "oshmem/mca/sshmem/sshmem.h"
21 #include "oshmem/mca/spml/spml.h"
22
23
24 BEGIN_C_DECLS
25 struct mca_memheap_base_module_t;
26
27 typedef struct memheap_context
28 {
29 void* user_base_addr;
30 void* private_base_addr;
31 size_t user_size;
32 size_t private_size;
33 } memheap_context_t;
34
35
36
37
38 typedef int (*mca_memheap_base_component_init_fn_t)(memheap_context_t *);
39
40
41
42
43 typedef int (*mca_memheap_base_module_alloc_fn_t)(size_t, void**);
44
45 typedef int (*mca_memheap_base_module_memalign_fn_t)(size_t align,
46 size_t size,
47 void**);
48
49 typedef int (*mca_memheap_base_module_realloc_fn_t)(size_t newsize,
50 void *,
51 void **);
52
53
54
55
56 typedef int (*mca_memheap_base_module_free_fn_t)(void*);
57
58
59
60
61
62 typedef sshmem_mkey_t * (*mca_memheap_base_module_get_local_mkey_fn_t)(void* va,
63 int transport_id);
64
65
66
67
68 typedef int (*mca_memheap_base_module_finalize_fn_t)(void);
69
70 typedef int (*mca_memheap_base_is_memheap_addr_fn_t)(const void* va);
71
72
73 typedef void (*mca_memheap_base_mkey_exchange_fn_t)(void);
74
75
76
77
78
79 struct mca_memheap_base_component_2_0_0_t {
80 mca_base_component_t memheap_version;
81 mca_base_component_data_t memheap_data;
82 mca_memheap_base_component_init_fn_t memheap_init;
83 };
84 typedef struct mca_memheap_base_component_2_0_0_t mca_memheap_base_component_2_0_0_t;
85 typedef struct mca_memheap_base_component_2_0_0_t mca_memheap_base_component_t;
86
87
88
89
90 struct mca_memheap_base_module_t {
91 mca_memheap_base_component_t *memheap_component;
92 mca_memheap_base_module_finalize_fn_t memheap_finalize;
93 mca_memheap_base_module_alloc_fn_t memheap_alloc;
94 mca_memheap_base_module_memalign_fn_t memheap_memalign;
95 mca_memheap_base_module_realloc_fn_t memheap_realloc;
96 mca_memheap_base_module_free_fn_t memheap_free;
97
98
99
100
101
102
103 mca_memheap_base_module_alloc_fn_t memheap_private_alloc;
104 mca_memheap_base_module_free_fn_t memheap_private_free;
105
106 mca_memheap_base_module_get_local_mkey_fn_t memheap_get_local_mkey;
107 mca_memheap_base_is_memheap_addr_fn_t memheap_is_symmetric_addr;
108 mca_memheap_base_mkey_exchange_fn_t memheap_get_all_mkeys;
109
110
111
112
113 long memheap_size;
114 };
115
116 typedef struct mca_memheap_base_module_t mca_memheap_base_module_t;
117
118
119
120
121 #define MCA_MEMHEAP_BASE_VERSION_2_0_0 \
122 OSHMEM_MCA_BASE_VERSION_2_1_0("memheap", 2, 0, 0)
123
124
125
126
127 #if MCA_oshmem_memheap_DIRECT_CALL
128
129 #include MCA_oshmem_memheap_DIRECT_CALL_HEADER
130
131 #define MCA_MEMHEAP_CALL_STAMP(a, b) mca_memheap_ ## a ## _ ## b
132 #define MCA_MEMHEAP_CALL_EXPANDER(a, b) MCA_MEMHEAP_CALL_STAMP(a,b)
133 #define MCA_MEMHEAP_CALL(a) MCA_MEMHEAP_CALL_EXPANDER(MCA_oshmem_memheap_DIRECT_CALL_COMPONENT, a)
134
135 #else
136 #define MCA_MEMHEAP_CALL(a) mca_memheap.memheap_ ## a
137 #endif
138
139 OSHMEM_DECLSPEC extern mca_memheap_base_module_t mca_memheap;
140
141 int mca_memheap_alloc_with_hint(size_t size, long hint, void**);
142
143 static inline int mca_memheap_base_mkey_is_shm(sshmem_mkey_t *mkey)
144 {
145 return (0 == mkey->len) && (MAP_SEGMENT_SHM_INVALID != (int)mkey->u.key);
146 }
147
148
149
150
151
152 static inline int mca_memheap_base_can_local_copy(sshmem_mkey_t *mkey, void *dst_addr) {
153 return mca_memheap.memheap_is_symmetric_addr(dst_addr) &&
154 mca_memheap_base_mkey_is_shm(mkey);
155 }
156
157
158 END_C_DECLS
159
160 #endif