@@ -36,6 +36,7 @@ static int component_finalize(void);
36
36
static int component_query (struct ompi_win_t * win , void * * base , size_t size , int disp_unit ,
37
37
struct ompi_communicator_t * comm , struct opal_info_t * info ,
38
38
int flavor );
39
+ static int component_register (void );
39
40
static int component_select (struct ompi_win_t * win , void * * base , size_t size , int disp_unit ,
40
41
struct ompi_communicator_t * comm , struct opal_info_t * info ,
41
42
int flavor , int * model );
@@ -51,6 +52,7 @@ ompi_osc_sm_component_t mca_osc_sm_component = {
51
52
MCA_BASE_MAKE_VERSION (component , OMPI_MAJOR_VERSION , OMPI_MINOR_VERSION ,
52
53
OMPI_RELEASE_VERSION ),
53
54
.mca_open_component = component_open ,
55
+ .mca_register_component_params = component_register ,
54
56
},
55
57
.osc_data = { /* mca_base_component_data */
56
58
/* The component is not checkpoint ready */
@@ -105,6 +107,23 @@ ompi_osc_sm_module_t ompi_osc_sm_module_template = {
105
107
}
106
108
};
107
109
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
+ }
108
127
109
128
static int
110
129
component_open (void )
@@ -169,6 +188,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
169
188
{
170
189
ompi_osc_sm_module_t * module = NULL ;
171
190
int comm_size = ompi_comm_size (comm );
191
+ bool unlink_needed = false;
172
192
int ret = OMPI_ERROR ;
173
193
174
194
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
262
282
posts_size += OPAL_ALIGN_PAD_AMOUNT (posts_size , 64 );
263
283
if (0 == ompi_comm_rank (module -> comm )) {
264
284
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 ) {
269
289
return OMPI_ERR_OUT_OF_RESOURCE ;
270
290
}
271
291
@@ -274,6 +294,8 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
274
294
if (OPAL_SUCCESS != ret ) {
275
295
goto error ;
276
296
}
297
+
298
+ unlink_needed = true;
277
299
}
278
300
279
301
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
287
309
goto error ;
288
310
}
289
311
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
+
290
323
module -> sizes = malloc (sizeof (size_t ) * comm_size );
291
324
if (NULL == module -> sizes ) return OMPI_ERR_TEMP_OUT_OF_RESOURCE ;
292
325
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
399
432
return OMPI_SUCCESS ;
400
433
401
434
error :
435
+
436
+ if (0 == ompi_comm_rank (module -> comm ) && unlink_needed ) {
437
+ opal_shmem_unlink (& module -> seg_ds );
438
+ }
439
+
402
440
ompi_osc_sm_free (win );
403
441
404
442
return ret ;
@@ -477,10 +515,6 @@ ompi_osc_sm_free(struct ompi_win_t *win)
477
515
module -> comm -> c_coll -> coll_barrier (module -> comm ,
478
516
module -> comm -> c_coll -> coll_barrier_module );
479
517
480
- if (0 == ompi_comm_rank (module -> comm )) {
481
- opal_shmem_unlink (& module -> seg_ds );
482
- }
483
-
484
518
opal_shmem_segment_detach (& module -> seg_ds );
485
519
} else {
486
520
free (module -> node_states );
0 commit comments