Skip to content

Use malloc instead of posix_memalign for small (<= sizeof(void *)) alignments #4565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opal/mca/mpool/base/mpool_base_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void *mca_mpool_base_alloc(size_t size, opal_info_t *info, const char *hints)

mpool = mca_mpool_base_module_lookup (hints);
if (NULL != mpool) {
mem = mpool->mpool_alloc (mpool, size, 0, 0);
mem = mpool->mpool_alloc (mpool, size, sizeof(void *), 0);
}

if (NULL == mem) {
Expand Down
6 changes: 5 additions & 1 deletion opal/mca/mpool/base/mpool_base_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ static void *mca_mpool_default_alloc (mca_mpool_base_module_t *mpool, size_t siz
#if HAVE_POSIX_MEMALIGN
void *addr = NULL;

(void) posix_memalign (&addr, align, size);
if (align <= sizeof(void *)) {
addr = malloc (size);
} else {
(void) posix_memalign (&addr, align, size);
}
return addr;
#else
void *addr, *ret;
Expand Down