1
1

openib: only set the memory hook if it is enabled

Instead of unconditionally setting the memory hook, only set it when
the memory hooks are both available and have been enabled (e.g.,
opal/mca/memory/linux has decided that it *can* be enabled, and when
the mpi_leave_pinned MCA param is set to 1, or is set to -1 and some
component requested the memory hooks be enabled).

If we set the memory hook when memory hooks are not enabled,
__malloc_hook will be NULL, which will cause problems when
btl_openib_malloc_hook() tries to invoke it.

Fixes open-mpi/ompi#638.
Этот коммит содержится в:
Jeff Squyres 2015-06-12 19:58:48 -07:00
родитель 2de42c873d
Коммит 88c13adc8c

Просмотреть файл

@ -2521,7 +2521,9 @@ btl_openib_component_init(int *num_btl_modules,
we're most likely going to be using this component). The hook is to be set up
as early as possible in this function since we want most of the allocated resources
be aligned.*/
if (mca_btl_openib_component.use_memalign > 0) {
if (mca_btl_openib_component.use_memalign > 0 &&
(opal_mem_hooks_support_level() &
(OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_CHUNK_SUPPORT)) != 0) {
mca_btl_openib_component.previous_malloc_hook = __malloc_hook;
__malloc_hook = btl_openib_malloc_hook;
malloc_hook_set = true;