|
6 | 6 | * Copyright (c) 2004-2006 The University of Tennessee and The University
|
7 | 7 | * of Tennessee Research Foundation. All rights
|
8 | 8 | * reserved.
|
9 |
| - * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
| 9 | + * Copyright (c) 2004-2020 High Performance Computing Center Stuttgart, |
10 | 10 | * University of Stuttgart. All rights reserved.
|
11 | 11 | * Copyright (c) 2004-2005 The Regents of the University of California.
|
12 | 12 | * All rights reserved.
|
@@ -62,26 +62,40 @@ void *mca_mpool_base_alloc(size_t size, opal_info_t *info, const char *hints)
|
62 | 62 | mca_mpool_base_tree_item_t *mpool_tree_item = NULL;
|
63 | 63 | mca_mpool_base_module_t *mpool;
|
64 | 64 | 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; |
68 | 67 |
|
69 | 68 | mpool_tree_item = mca_mpool_base_tree_item_get();
|
70 | 69 | if (!mpool_tree_item) {
|
71 | 70 | return NULL;
|
72 | 71 | }
|
73 | 72 |
|
| 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 | + |
74 | 87 | mpool_tree_item->num_bytes = size;
|
75 | 88 | mpool_tree_item->count = 0;
|
76 | 89 |
|
77 | 90 | mpool = mca_mpool_base_module_lookup(hints);
|
78 | 91 | if (NULL != mpool) {
|
79 |
| - mem = mpool->mpool_alloc(mpool, size, OPAL_ALIGN_MIN, 0); |
| 92 | + mem = mpool->mpool_alloc (mpool, size, memory_alignment, 0); |
80 | 93 | }
|
81 | 94 |
|
82 | 95 | 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); |
85 | 99 |
|
86 | 100 | mca_mpool_base_tree_item_put(mpool_tree_item);
|
87 | 101 | } else {
|
@@ -114,7 +128,7 @@ int mca_mpool_base_free(void *base)
|
114 | 128 |
|
115 | 129 | if (!mpool_tree_item) {
|
116 | 130 | /* 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); |
118 | 132 | return OPAL_SUCCESS;
|
119 | 133 | }
|
120 | 134 |
|
|
0 commit comments