Skip to content

Commit 9943b0b

Browse files
committed
oshmem/shmem: Allocate and exchange base segment address beforehand
Signed-off-by: Thomas Vegas <[email protected]>
1 parent 6a7154b commit 9943b0b

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

oshmem/mca/memheap/base/memheap_base_select.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static void *memheap_mmap_get(void *hint, size_t size)
124124
static int memheap_exchange_base_address(size_t size, void **address)
125125
{
126126
int nprocs = oshmem_num_procs();
127+
int need_sync = (*address != NULL);
127128
void *base = NULL;
128129
void *ptr = NULL;
129130
int rc, i;
@@ -154,23 +155,29 @@ static int memheap_exchange_base_address(size_t size, void **address)
154155
oshmem_my_proc_id(), base,
155156
(base == ptr)? "ok" : "unavailable");
156157

157-
rc = oshmem_shmem_allgather(&ptr, bases, sizeof(ptr));
158-
if (OSHMEM_SUCCESS != rc) {
159-
MEMHEAP_ERROR("Failed to exchange selected vma for base segment "
160-
"(error %d)", rc);
161-
goto out;
162-
}
163-
164158
*address = base;
165-
for (i = 0; i < nprocs; i++) {
166-
if ((NULL == bases[i]) || (bases[i] != base)) {
167-
*address = NULL;
168-
break;
159+
if (need_sync) {
160+
/* They all succeed or fail to allow fallback */
161+
rc = oshmem_shmem_allgather(&ptr, bases, sizeof(ptr));
162+
if (OSHMEM_SUCCESS != rc) {
163+
MEMHEAP_ERROR("Failed to exchange selected vma for base segment "
164+
"(error %d)", rc);
165+
goto out;
166+
}
167+
168+
for (i = 0; i < nprocs; i++) {
169+
if ((NULL == bases[i]) || (bases[i] != base)) {
170+
*address = NULL;
171+
break;
172+
}
169173
}
174+
} else if (ptr != base) {
175+
/* Any failure terminates the rank and others start teardown */
176+
rc = OSHMEM_ERROR;
170177
}
171178

172179
out:
173-
if (((OSHMEM_SUCCESS != rc) || (*address == NULL)) && (NULL != ptr)) {
180+
if (((OSHMEM_SUCCESS != rc) || (*address == NULL)) && (ptr != NULL)) {
174181
(void)munmap(ptr, size);
175182
}
176183

@@ -187,7 +194,8 @@ static int memheap_base_segment_setup(size_t size)
187194
{
188195
int rc;
189196

190-
if (mca_sshmem_base_start_address == (void *)UINTPTR_MAX) {
197+
if ((mca_sshmem_base_start_address == (void *)UINTPTR_MAX) ||
198+
(mca_sshmem_base_start_address == NULL)) {
191199
if (UINTPTR_MAX == 0xFFFFFFFF) {
192200
/**
193201
* if 32 bit we set sshmem_base_start_adress to 0

0 commit comments

Comments
 (0)