Skip to content

Commit de4fe77

Browse files
authored
Merge pull request #9880 from hppritcha/topic/no_xpmem_for_fboxes
btl/sm: avoid using xpmem for fast boxes
2 parents 8e5894a + 8bac539 commit de4fe77

File tree

2 files changed

+35
-74
lines changed

2 files changed

+35
-74
lines changed

opal/mca/btl/sm/btl_sm_component.c

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,6 @@ static int mca_btl_sm_component_close(void)
254254
OBJ_DESTRUCT(&mca_btl_sm_component.pending_endpoints);
255255
OBJ_DESTRUCT(&mca_btl_sm_component.pending_fragments);
256256

257-
if (mca_smsc_base_has_feature(MCA_SMSC_FEATURE_CAN_MAP)
258-
&& NULL != mca_btl_sm_component.my_segment) {
259-
munmap(mca_btl_sm_component.my_segment, mca_btl_sm_component.segment_size);
260-
}
261-
262257
mca_btl_sm_component.my_segment = NULL;
263258

264259
if (mca_btl_sm_component.mpool) {
@@ -276,14 +271,9 @@ static int mca_btl_base_sm_modex_send(void)
276271

277272
modex_size = sizeof(modex) - sizeof(modex.seg_ds);
278273

279-
if (!mca_smsc_base_has_feature(MCA_SMSC_FEATURE_CAN_MAP)) {
280274
modex.seg_ds_size = opal_shmem_sizeof_shmem_ds(&mca_btl_sm_component.seg_ds);
281275
memmove(&modex.seg_ds, &mca_btl_sm_component.seg_ds, modex.seg_ds_size);
282276
modex_size += modex.seg_ds_size;
283-
} else {
284-
modex.segment_base = (uintptr_t) mca_btl_sm_component.my_segment;
285-
modex.seg_ds_size = 0;
286-
}
287277

288278
int rc;
289279
OPAL_MODEX_SEND(rc, PMIX_LOCAL, &mca_btl_sm_component.super.btl_version, &modex, modex_size);
@@ -376,41 +366,29 @@ mca_btl_sm_component_init(int *num_btls, bool enable_progress_threads, bool enab
376366
mca_btl_sm.super.btl_put = NULL;
377367
}
378368

379-
if (!mca_smsc_base_has_feature(MCA_SMSC_FEATURE_CAN_MAP)) {
380-
char *sm_file;
369+
char *sm_file;
381370

382-
rc = opal_asprintf(&sm_file, "%s" OPAL_PATH_SEP "sm_segment.%s.%u.%x.%d",
383-
mca_btl_sm_component.backing_directory, opal_process_info.nodename,
371+
rc = opal_asprintf(&sm_file, "%s" OPAL_PATH_SEP "sm_segment.%s.%u.%x.%d",
372+
mca_btl_sm_component.backing_directory, opal_process_info.nodename,
384373
geteuid(), OPAL_PROC_MY_NAME.jobid, MCA_BTL_SM_LOCAL_RANK);
385-
if (0 > rc) {
386-
free(btls);
387-
return NULL;
388-
}
389-
opal_pmix_register_cleanup(sm_file, false, false, false);
390-
391-
rc = opal_shmem_segment_create(&component->seg_ds, sm_file, component->segment_size);
392-
free(sm_file);
393-
if (OPAL_SUCCESS != rc) {
394-
BTL_VERBOSE(("Could not create shared memory segment"));
395-
free(btls);
396-
return NULL;
397-
}
374+
if (0 > rc) {
375+
free(btls);
376+
return NULL;
377+
}
378+
opal_pmix_register_cleanup(sm_file, false, false, false);
398379

399-
component->my_segment = opal_shmem_segment_attach(&component->seg_ds);
400-
if (NULL == component->my_segment) {
401-
BTL_VERBOSE(("Could not attach to just created shared memory segment"));
402-
goto failed;
403-
}
404-
} else {
405-
/* if the shared-memory single-copy component can map memory (XPMEM) an anonymous segment
406-
* can be used instead */
407-
component->my_segment = mmap(NULL, component->segment_size, PROT_READ | PROT_WRITE,
408-
MAP_ANONYMOUS | MAP_SHARED, -1, 0);
409-
if ((void *) -1 == component->my_segment) {
410-
BTL_VERBOSE(("Could not create anonymous memory segment"));
411-
free(btls);
412-
return NULL;
413-
}
380+
rc = opal_shmem_segment_create(&component->seg_ds, sm_file, component->segment_size);
381+
free(sm_file);
382+
if (OPAL_SUCCESS != rc) {
383+
BTL_VERBOSE(("Could not create shared memory segment"));
384+
free(btls);
385+
return NULL;
386+
}
387+
388+
component->my_segment = opal_shmem_segment_attach(&component->seg_ds);
389+
if (NULL == component->my_segment) {
390+
BTL_VERBOSE(("Could not attach to just created shared memory segment"));
391+
goto failed;
414392
}
415393

416394
/* initialize my fifo */
@@ -432,11 +410,7 @@ mca_btl_sm_component_init(int *num_btls, bool enable_progress_threads, bool enab
432410

433411
return btls;
434412
failed:
435-
if (mca_smsc_base_has_feature(MCA_SMSC_FEATURE_CAN_MAP)) {
436-
munmap(component->my_segment, component->segment_size);
437-
} else {
438-
opal_shmem_unlink(&component->seg_ds);
439-
}
413+
opal_shmem_unlink(&component->seg_ds);
440414

441415
if (btls) {
442416
free(btls);

opal/mca/btl/sm/btl_sm_module.c

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ static int init_sm_endpoint(struct mca_btl_base_endpoint_t **ep_out, struct opal
185185
mca_btl_sm.super.btl_put = NULL;
186186
mca_btl_sm.super.btl_flags &= ~MCA_BTL_FLAGS_RDMA;
187187
}
188-
if (mca_smsc_base_has_feature(MCA_SMSC_FEATURE_CAN_MAP)) {
189-
ep->smsc_map_context = MCA_SMSC_CALL(map_peer_region, ep->smsc_endpoint, /*flag=*/0,
190-
(void *) (uintptr_t) modex->segment_base,
191-
mca_btl_sm_component.segment_size,
192-
(void **) &ep->segment_base);
193-
} else {
194188
/* store a copy of the segment information for detach */
195189
ep->seg_ds = malloc(modex->seg_ds_size);
196190
if (NULL == ep->seg_ds) {
@@ -203,7 +197,6 @@ static int init_sm_endpoint(struct mca_btl_base_endpoint_t **ep_out, struct opal
203197
if (NULL == ep->segment_base) {
204198
return OPAL_ERROR;
205199
}
206-
}
207200

208201
OBJ_CONSTRUCT(&ep->lock, opal_mutex_t);
209202

@@ -353,10 +346,8 @@ static int sm_finalize(struct mca_btl_base_module_t *btl)
353346
free(component->fbox_in_endpoints);
354347
component->fbox_in_endpoints = NULL;
355348

356-
if (!mca_smsc_base_has_feature(MCA_SMSC_FEATURE_CAN_MAP)) {
357-
opal_shmem_unlink(&mca_btl_sm_component.seg_ds);
358-
opal_shmem_segment_detach(&mca_btl_sm_component.seg_ds);
359-
}
349+
opal_shmem_unlink(&mca_btl_sm_component.seg_ds);
350+
opal_shmem_segment_detach(&mca_btl_sm_component.seg_ds);
360351

361352
return OPAL_SUCCESS;
362353
}
@@ -521,22 +512,18 @@ static void mca_btl_sm_endpoint_destructor(mca_btl_sm_endpoint_t *ep)
521512
OBJ_DESTRUCT(&ep->pending_frags);
522513
OBJ_DESTRUCT(&ep->pending_frags_lock);
523514

524-
if (!mca_smsc_base_has_feature(MCA_SMSC_FEATURE_CAN_MAP)) {
525-
if (ep->seg_ds) {
526-
opal_shmem_ds_t seg_ds;
527-
528-
/* opal_shmem_segment_detach expects a opal_shmem_ds_t and will
529-
* stomp past the end of the seg_ds if it is too small (which
530-
* ep->seg_ds probably is) */
531-
memcpy(&seg_ds, ep->seg_ds, opal_shmem_sizeof_shmem_ds(ep->seg_ds));
532-
free(ep->seg_ds);
533-
ep->seg_ds = NULL;
534-
535-
/* disconnect from the peer's segment */
536-
opal_shmem_segment_detach(&seg_ds);
537-
}
538-
} else if (NULL != ep->smsc_map_context) {
539-
MCA_SMSC_CALL(unmap_peer_region, ep->smsc_map_context);
515+
if (ep->seg_ds) {
516+
opal_shmem_ds_t seg_ds;
517+
518+
/* opal_shmem_segment_detach expects a opal_shmem_ds_t and will
519+
* stomp past the end of the seg_ds if it is too small (which
520+
* ep->seg_ds probably is) */
521+
memcpy(&seg_ds, ep->seg_ds, opal_shmem_sizeof_shmem_ds(ep->seg_ds));
522+
free(ep->seg_ds);
523+
ep->seg_ds = NULL;
524+
525+
/* disconnect from the peer's segment */
526+
opal_shmem_segment_detach(&seg_ds);
540527
}
541528

542529
if (ep->fbox_out.fbox) {

0 commit comments

Comments
 (0)