From a13e9a55945a00a7e055fedfce464f702c3c5beb Mon Sep 17 00:00:00 2001 From: Michael Wall Date: Fri, 28 Jun 2024 13:12:43 -0600 Subject: [PATCH] Require BML_USE_POSIX_MEMALIGN to use posix_memalign() Using the HAVE_POSIX_MEMALIGN code path results in ~1.7x slowdown of an MD code which frequently allocates arrays. Require a new macro BML_USE_POSIX_MEMALIGN to be defined, to use the code path. Don't define the macro by default. --- src/C-interface/bml_allocate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/C-interface/bml_allocate.c b/src/C-interface/bml_allocate.c index 98921c18..5c633476 100644 --- a/src/C-interface/bml_allocate.c +++ b/src/C-interface/bml_allocate.c @@ -53,7 +53,7 @@ bml_allocate_memory( __assume_aligned(ptr, MALLOC_ALIGNMENT); ptr[i] = 0; } -#elif defined(HAVE_POSIX_MEMALIGN) +#elif defined(HAVE_POSIX_MEMALIGN) && defined(BML_USE_POSIX_MEMALIGN) char *ptr; posix_memalign((void **) &ptr, MALLOC_ALIGNMENT, size); #pragma omp simd @@ -86,7 +86,7 @@ bml_noinit_allocate_memory( { #if defined(INTEL_OPT) void *ptr = _mm_malloc(size, MALLOC_ALIGNMENT); -#elif defined(HAVE_POSIX_MEMALIGN) +#elif defined(HAVE_POSIX_MEMALIGN) && defined(BML_USE_POSIX_MEMALIGN) void *ptr; posix_memalign(&ptr, MALLOC_ALIGNMENT, size); #else