Skip to content

Commit 1d5c887

Browse files
committed
osc/sm: add support for controlling location of backing store
This commit adds a new MCA variable to set the location of the backing store: osc_sm_backing_directory. The default on Linux has been changed to use /dev/shm to improve performance in cases where /tmp is not a tmpfs. Signed-off-by: Nathan Hjelm <[email protected]> (cherry picked from commit e9de425) Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 2073766 commit 1d5c887

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

ompi/mca/osc/sm/osc_sm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ typedef struct ompi_osc_sm_node_state_t ompi_osc_sm_node_state_t;
6161

6262
struct ompi_osc_sm_component_t {
6363
ompi_osc_base_component_t super;
64+
65+
char *backing_directory;
6466
};
6567
typedef struct ompi_osc_sm_component_t ompi_osc_sm_component_t;
6668
OMPI_DECLSPEC extern ompi_osc_sm_component_t mca_osc_sm_component;

ompi/mca/osc/sm/osc_sm_component.c

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static int component_finalize(void);
3636
static int component_query(struct ompi_win_t *win, void **base, size_t size, int disp_unit,
3737
struct ompi_communicator_t *comm, struct opal_info_t *info,
3838
int flavor);
39+
static int component_register (void);
3940
static int component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit,
4041
struct ompi_communicator_t *comm, struct opal_info_t *info,
4142
int flavor, int *model);
@@ -51,6 +52,7 @@ ompi_osc_sm_component_t mca_osc_sm_component = {
5152
MCA_BASE_MAKE_VERSION(component, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
5253
OMPI_RELEASE_VERSION),
5354
.mca_open_component = component_open,
55+
.mca_register_component_params = component_register,
5456
},
5557
.osc_data = { /* mca_base_component_data */
5658
/* The component is not checkpoint ready */
@@ -105,6 +107,23 @@ ompi_osc_sm_module_t ompi_osc_sm_module_template = {
105107
}
106108
};
107109

110+
static int component_register (void)
111+
{
112+
if (0 == access ("/dev/shm", W_OK)) {
113+
mca_osc_sm_component.backing_directory = "/dev/shm";
114+
} else {
115+
mca_osc_sm_component.backing_directory = ompi_process_info.proc_session_dir;
116+
}
117+
118+
(void) mca_base_component_var_register (&mca_osc_sm_component.super.osc_version, "backing_directory",
119+
"Directory to place backing files for shared memory windows. "
120+
"This directory should be on a local filesystem such as /tmp or "
121+
"/dev/shm (default: (linux) /dev/shm, (others) session directory)",
122+
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
123+
MCA_BASE_VAR_SCOPE_READONLY, &mca_osc_sm_component.backing_directory);
124+
125+
return OPAL_SUCCESS;
126+
}
108127

109128
static int
110129
component_open(void)
@@ -169,6 +188,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
169188
{
170189
ompi_osc_sm_module_t *module = NULL;
171190
int comm_size = ompi_comm_size (comm);
191+
bool unlink_needed = false;
172192
int ret = OMPI_ERROR;
173193

174194
if (OMPI_SUCCESS != (ret = check_win_ok(comm, flavor))) {
@@ -262,10 +282,10 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
262282
posts_size += OPAL_ALIGN_PAD_AMOUNT(posts_size, 64);
263283
if (0 == ompi_comm_rank (module->comm)) {
264284
char *data_file;
265-
if (asprintf(&data_file, "%s"OPAL_PATH_SEP"shared_window_%d.%s",
266-
ompi_process_info.proc_session_dir,
267-
ompi_comm_get_cid(module->comm),
268-
ompi_process_info.nodename) < 0) {
285+
ret = asprintf (&data_file, "%s" OPAL_PATH_SEP "osc_sm.%s.%x.%d",
286+
mca_osc_sm_component.backing_directory, ompi_process_info.nodename,
287+
OMPI_PROC_MY_NAME->jobid, ompi_comm_get_cid(module->comm));
288+
if (ret < 0) {
269289
return OMPI_ERR_OUT_OF_RESOURCE;
270290
}
271291

@@ -274,6 +294,8 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
274294
if (OPAL_SUCCESS != ret) {
275295
goto error;
276296
}
297+
298+
unlink_needed = true;
277299
}
278300

279301
ret = module->comm->c_coll->coll_bcast (&module->seg_ds, sizeof (module->seg_ds), MPI_BYTE, 0,
@@ -287,6 +309,17 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
287309
goto error;
288310
}
289311

312+
ret = module->comm->c_coll->coll_bcast (&module->seg_ds, sizeof (module->seg_ds), MPI_BYTE, 0,
313+
module->comm, module->comm->c_coll->coll_bcast_module);
314+
if (OMPI_SUCCESS != ret) {
315+
goto error;
316+
}
317+
318+
if (0 == ompi_comm_rank (module->comm)) {
319+
opal_shmem_unlink (&module->seg_ds);
320+
unlink_needed = false;
321+
}
322+
290323
module->sizes = malloc(sizeof(size_t) * comm_size);
291324
if (NULL == module->sizes) return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
292325
module->bases = malloc(sizeof(void*) * comm_size);
@@ -399,6 +432,11 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
399432
return OMPI_SUCCESS;
400433

401434
error:
435+
436+
if (0 == ompi_comm_rank (module->comm) && unlink_needed) {
437+
opal_shmem_unlink (&module->seg_ds);
438+
}
439+
402440
ompi_osc_sm_free (win);
403441

404442
return ret;
@@ -477,10 +515,6 @@ ompi_osc_sm_free(struct ompi_win_t *win)
477515
module->comm->c_coll->coll_barrier(module->comm,
478516
module->comm->c_coll->coll_barrier_module);
479517

480-
if (0 == ompi_comm_rank (module->comm)) {
481-
opal_shmem_unlink (&module->seg_ds);
482-
}
483-
484518
opal_shmem_segment_detach (&module->seg_ds);
485519
} else {
486520
free(module->node_states);

0 commit comments

Comments
 (0)