Skip to content

Commit 7efc85a

Browse files
committed
base/mpool: add support for mpi_minimum_memory_alignment info key
Signed-off-by: Joseph Schuchart <schuchart@hlrs.de>
1 parent 3ac45e0 commit 7efc85a

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

opal/mca/mpool/base/mpool_base_alloc.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2004-2006 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
9-
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
* Copyright (c) 2004-2020 High Performance Computing Center Stuttgart,
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
@@ -62,26 +62,40 @@ void *mca_mpool_base_alloc(size_t size, opal_info_t *info, const char *hints)
6262
mca_mpool_base_tree_item_t *mpool_tree_item = NULL;
6363
mca_mpool_base_module_t *mpool;
6464
void *mem = NULL;
65-
#if defined(TODO_BTL_GB)
66-
int flag = 0;
67-
#endif /* defined(TODO_BTL_GB) */
65+
opal_cstring_t *align_info_str;
66+
size_t memory_alignment = OPAL_ALIGN_MIN;
6867

6968
mpool_tree_item = mca_mpool_base_tree_item_get();
7069
if (!mpool_tree_item) {
7170
return NULL;
7271
}
7372

73+
if (NULL != info) {
74+
int flag;
75+
opal_info_get(info, "mpi_minimum_memory_alignment",
76+
&align_info_str, &flag);
77+
78+
if (flag) {
79+
ssize_t tmp_align = atoll(align_info_str->string);
80+
OBJ_RELEASE(align_info_str);
81+
if (tmp_align > memory_alignment) {
82+
memory_alignment = tmp_align;
83+
}
84+
}
85+
}
86+
7487
mpool_tree_item->num_bytes = size;
7588
mpool_tree_item->count = 0;
7689

7790
mpool = mca_mpool_base_module_lookup(hints);
7891
if (NULL != mpool) {
79-
mem = mpool->mpool_alloc(mpool, size, OPAL_ALIGN_MIN, 0);
92+
mem = mpool->mpool_alloc (mpool, size, memory_alignment, 0);
8093
}
8194

8295
if (NULL == mem) {
83-
/* fall back on malloc */
84-
mem = malloc(size);
96+
/* fall back to default mpool */
97+
mem = mca_mpool_base_default_module->mpool_alloc(mca_mpool_base_default_module,
98+
size, memory_alignment, 0);
8599

86100
mca_mpool_base_tree_item_put(mpool_tree_item);
87101
} else {
@@ -114,7 +128,7 @@ int mca_mpool_base_free(void *base)
114128

115129
if (!mpool_tree_item) {
116130
/* nothing in the tree this was just plain old malloc'd memory */
117-
free(base);
131+
mca_mpool_base_default_module->mpool_free(mca_mpool_base_default_module, base);
118132
return OPAL_SUCCESS;
119133
}
120134

0 commit comments

Comments
 (0)