Skip to content

Commit

Permalink
Require BML_USE_POSIX_MEMALIGN to use posix_memalign()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mewall authored Jun 28, 2024
1 parent 6a24bfc commit a13e9a5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/C-interface/bml_allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a13e9a5

Please sign in to comment.