1919 * Copyright (c) 2011-2015 NVIDIA Corporation. All rights reserved.
2020 * Copyright (c) 2012 Oak Ridge National Laboratory. All rights reserved
2121 * Copyright (c) 2013-2015 Intel, Inc. All rights reserved
22- * Copyright (c) 2014-2015 Research Organization for Information Science
22+ * Copyright (c) 2014-2016 Research Organization for Information Science
2323 * and Technology (RIST). All rights reserved.
2424 * Copyright (c) 2014 Bull SAS. All rights reserved.
2525 * $COPYRIGHT$
4242#include <fcntl.h>
4343#include <stdlib.h>
4444#include <stddef.h>
45- #if BTL_OPENIB_MALLOC_HOOKS_ENABLED
46- /*
47- * The include of malloc.h below breaks abstractions in OMPI (by
48- * directly including a header file from another component), but has
49- * been ruled "ok" because the openib component is only supported on
50- * Linux.
51- *
52- * The malloc hooks in newer glibc were deprecated, including stock
53- * malloc.h causes compilation warnings. Instead, we use the internal
54- * linux component malloc.h which does not cause these warnings.
55- * Internally, OMPI uses the built-in ptmalloc from the linux memory
56- * component anyway.
57- */
58- #include "opal/mca/memory/linux/malloc.h"
59- #endif
6045
46+ #include "opal/mca/memory/memory.h"
6147#include "opal/mca/event/event.h"
6248#include "opal/align.h"
6349#include "opal/util/output.h"
@@ -123,7 +109,6 @@ static void btl_openib_handle_incoming_completion(mca_btl_base_module_t* btl,
123109 * Local variables
124110 */
125111static mca_btl_openib_device_t * receive_queues_device = NULL ;
126- static bool malloc_hook_set = false;
127112static int num_devices_intentionally_ignored = 0 ;
128113
129114mca_btl_openib_component_t mca_btl_openib_component = {
@@ -147,30 +132,6 @@ mca_btl_openib_component_t mca_btl_openib_component = {
147132 }
148133};
149134
150- #if BTL_OPENIB_MALLOC_HOOKS_ENABLED
151- /* This is a memory allocator hook. The purpose of this is to make
152- * every malloc aligned since this speeds up IB HCA work.
153- * There two basic cases here:
154- *
155- * 1. Memory manager for Open MPI is enabled. Then memalign below will
156- * be overridden by __memalign_hook which is set to
157- * opal_memory_linux_memalign_hook. Thus, _malloc_hook is going to
158- * use opal_memory_linux_memalign_hook.
159- *
160- * 2. No memory manager support. The memalign below is just regular glibc
161- * memalign which will be called through __malloc_hook instead of malloc.
162- */
163- static void * btl_openib_malloc_hook (size_t sz , const void * caller )
164- {
165- if (sz < mca_btl_openib_component .memalign_threshold &&
166- malloc_hook_set ) {
167- return mca_btl_openib_component .previous_malloc_hook (sz , caller );
168- } else {
169- return memalign (mca_btl_openib_component .use_memalign , sz );
170- }
171- }
172- #endif
173-
174135static int btl_openib_component_register (void )
175136{
176137 int ret ;
@@ -257,16 +218,6 @@ static int btl_openib_component_close(void)
257218 free (mca_btl_openib_component .default_recv_qps );
258219 }
259220
260- #if BTL_OPENIB_MALLOC_HOOKS_ENABLED
261- /* Must check to see whether the malloc hook was set before
262- assigning it back because ompi_info will call _register() and
263- then _close() (which won't set the hook) */
264- if (malloc_hook_set ) {
265- __malloc_hook = mca_btl_openib_component .previous_malloc_hook ;
266- malloc_hook_set = false;
267- }
268- #endif
269-
270221 /* close memory registration debugging output */
271222 opal_output_close (mca_btl_openib_component .memory_registration_verbose );
272223
@@ -2538,19 +2489,12 @@ btl_openib_component_init(int *num_btl_modules,
25382489 * num_btl_modules = 0 ;
25392490 num_devs = 0 ;
25402491
2541- #if BTL_OPENIB_MALLOC_HOOKS_ENABLED
25422492 /* If we got this far, then setup the memory alloc hook (because
25432493 we're most likely going to be using this component). The hook
25442494 is to be set up as early as possible in this function since we
2545- want most of the allocated resources be aligned.*/
2546- if (mca_btl_openib_component .use_memalign > 0 &&
2547- (opal_mem_hooks_support_level () &
2548- (OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_CHUNK_SUPPORT )) != 0 ) {
2549- mca_btl_openib_component .previous_malloc_hook = __malloc_hook ;
2550- __malloc_hook = btl_openib_malloc_hook ;
2551- malloc_hook_set = true;
2552- }
2553- #endif
2495+ want most of the allocated resources be aligned.
2496+ */
2497+ opal_memory -> memoryc_set_alignment (32 , mca_btl_openib_module .super .btl_eager_limit );
25542498
25552499 /* Per https://svn.open-mpi.org/trac/ompi/ticket/1305, check to
25562500 see if $sysfsdir/class/infiniband exists. If it does not,
@@ -2951,13 +2895,6 @@ btl_openib_component_init(int *num_btl_modules,
29512895
29522896 mca_btl_openib_component .ib_num_btls = 0 ;
29532897 btl_openib_modex_send ();
2954- #if BTL_OPENIB_MALLOC_HOOKS_ENABLED
2955- /*Unset malloc hook since the component won't start*/
2956- if (malloc_hook_set ) {
2957- __malloc_hook = mca_btl_openib_component .previous_malloc_hook ;
2958- malloc_hook_set = false;
2959- }
2960- #endif
29612898 if (NULL != btls ) {
29622899 free (btls );
29632900 }
0 commit comments