@@ -135,6 +135,14 @@ static void *(*prev_malloc_hook)(size_t, const void *);
135
135
* memalign which will be called through __malloc_hook instead of malloc.
136
136
*/
137
137
static void * _opal_memory_linux_malloc_align_hook (size_t sz , const void * caller );
138
+
139
+ static mca_base_var_enum_value_t align_values [] = {
140
+ {-1 , "disabled" },
141
+ {0 , "0" },
142
+ {32 , "32" },
143
+ {64 , "64" },
144
+ {0 , NULL }
145
+ };
138
146
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
139
147
140
148
@@ -143,6 +151,9 @@ static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller)
143
151
*/
144
152
static int linux_register (void )
145
153
{
154
+ #if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
155
+ mca_base_var_enum_t * new_enum ;
156
+ #endif
146
157
int ret ;
147
158
/* Information only */
148
159
ret = mca_base_component_var_register (& mca_memory_linux_component .super .memoryc_version ,
@@ -205,17 +216,19 @@ static int linux_register(void)
205
216
}
206
217
207
218
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
219
+ (void )mca_base_var_enum_create ("memory_linux_memalign" , align_values , & new_enum );
208
220
mca_memory_linux_component .use_memalign = -1 ;
209
221
ret = mca_base_component_var_register (& mca_memory_linux_component .super .memoryc_version ,
210
222
"memalign" ,
211
- "[64 | 32 | 0] - Enable memory alignment for all malloc calls (default: disabled) ." ,
223
+ "[64 | 32 | 0] - Enable memory alignment for all malloc calls." ,
212
224
MCA_BASE_VAR_TYPE_INT ,
213
- NULL ,
225
+ new_enum ,
214
226
0 ,
215
227
0 ,
216
228
OPAL_INFO_LVL_5 ,
217
229
MCA_BASE_VAR_SCOPE_READONLY ,
218
230
& mca_memory_linux_component .use_memalign );
231
+ OBJ_RELEASE (new_enum );
219
232
if (0 > ret ) {
220
233
return ret ;
221
234
}
@@ -236,16 +249,6 @@ static int linux_register(void)
236
249
if (0 > ret ) {
237
250
return ret ;
238
251
}
239
-
240
- if (mca_memory_linux_component .use_memalign != -1
241
- && mca_memory_linux_component .use_memalign != 32
242
- && mca_memory_linux_component .use_memalign != 64
243
- && mca_memory_linux_component .use_memalign != 0 ){
244
- opal_show_help ("help-opal-memory-linux.txt" , "invalid mca param value" ,
245
- true, "Wrong memalign parameter value. Allowed values: 64, 32, 0." ,
246
- "memory_linux_memalign is reset to 32" );
247
- mca_memory_linux_component .use_memalign = 32 ;
248
- }
249
252
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
250
253
251
254
return (0 > ret ) ? ret : OPAL_SUCCESS ;
0 commit comments