@@ -129,6 +129,14 @@ static void *(*prev_malloc_hook)(size_t, const void *);
129129 * memalign which will be called through __malloc_hook instead of malloc.
130130 */
131131static void * _opal_memory_linux_malloc_align_hook (size_t sz , const void * caller );
132+
133+ static mca_base_var_enum_value_t align_values [] = {
134+ {-1 , "disabled" },
135+ {0 , "0" },
136+ {32 , "32" },
137+ {64 , "64" },
138+ {0 , NULL }
139+ };
132140#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
133141
134142
@@ -137,6 +145,9 @@ static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller)
137145 */
138146static int linux_register (void )
139147{
148+ #if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
149+ mca_base_var_enum_t * new_enum ;
150+ #endif
140151 int ret ;
141152 /* Information only */
142153 ret = mca_base_component_var_register (& mca_memory_linux_component .super .memoryc_version ,
@@ -199,17 +210,19 @@ static int linux_register(void)
199210 }
200211
201212#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
213+ (void )mca_base_var_enum_create ("memory_linux_memalign" , align_values , & new_enum );
202214 mca_memory_linux_component .use_memalign = -1 ;
203215 ret = mca_base_component_var_register (& mca_memory_linux_component .super .memoryc_version ,
204216 "memalign" ,
205- "[64 | 32 | 0] - Enable memory alignment for all malloc calls (default: disabled) ." ,
217+ "[64 | 32 | 0] - Enable memory alignment for all malloc calls." ,
206218 MCA_BASE_VAR_TYPE_INT ,
207- NULL ,
219+ new_enum ,
208220 0 ,
209221 0 ,
210222 OPAL_INFO_LVL_5 ,
211223 MCA_BASE_VAR_SCOPE_READONLY ,
212224 & mca_memory_linux_component .use_memalign );
225+ OBJ_RELEASE (new_enum );
213226 if (0 > ret ) {
214227 return ret ;
215228 }
@@ -230,16 +243,6 @@ static int linux_register(void)
230243 if (0 > ret ) {
231244 return ret ;
232245 }
233-
234- if (mca_memory_linux_component .use_memalign != -1
235- && mca_memory_linux_component .use_memalign != 32
236- && mca_memory_linux_component .use_memalign != 64
237- && mca_memory_linux_component .use_memalign != 0 ){
238- opal_show_help ("help-opal-memory-linux.txt" , "invalid mca param value" ,
239- true, "Wrong memalign parameter value. Allowed values: 64, 32, 0." ,
240- "memory_linux_memalign is reset to 32" );
241- mca_memory_linux_component .use_memalign = 32 ;
242- }
243246#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
244247
245248 return (0 > ret ) ? ret : OPAL_SUCCESS ;
0 commit comments