44
44
#include <semaphore.h>
45
45
#include <sys/mman.h>
46
46
#include <libgen.h>
47
-
47
+ #include <unistd.h>
48
48
49
49
int mca_sharedfp_sm_file_open (struct ompi_communicator_t * comm ,
50
50
const char * filename ,
@@ -65,7 +65,9 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
65
65
int sm_fd ;
66
66
int rank ;
67
67
uint32_t comm_cid ;
68
-
68
+ int int_pid ;
69
+ pid_t my_pid ;
70
+
69
71
/*----------------------------------------------------*/
70
72
/*Open the same file again without shared file pointer*/
71
73
/*----------------------------------------------------*/
@@ -134,7 +136,7 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
134
136
** For sharedfp we also want to put the file backed shared memory into the tmp directory
135
137
*/
136
138
filename_basename = basename (filename );
137
- /* format is "%s/%s_cid-%d.sm", see below */
139
+ /* format is "%s/%s_cid-%d-%d .sm", see below */
138
140
sm_filename_length = strlen (ompi_process_info .job_session_dir ) + 1 + strlen (filename_basename ) + 5 + (3 * sizeof (uint32_t )+1 ) + 4 ;
139
141
sm_filename = (char * ) malloc ( sizeof (char ) * sm_filename_length );
140
142
if (NULL == sm_filename ) {
@@ -146,7 +148,21 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
146
148
}
147
149
148
150
comm_cid = ompi_comm_get_cid (comm );
149
- sprintf (sm_filename , "%s/%s_cid-%d.sm" , ompi_process_info .job_session_dir , filename_basename , comm_cid );
151
+ if ( 0 == fh -> f_rank ) {
152
+ my_pid = getpid ();
153
+ int_pid = (int ) my_pid ;
154
+ }
155
+ err = comm -> c_coll -> coll_bcast (& int_pid , 1 , MPI_INT , 0 , comm , comm -> c_coll -> coll_bcast_module );
156
+ if ( OMPI_SUCCESS != err ) {
157
+ opal_output (0 ,"mca_sharedfp_sm_file_open: Error in bcast operation \n" );
158
+ free (sm_filename );
159
+ free (sm_data );
160
+ free (sh );
161
+ return err ;
162
+ }
163
+ snprintf (sm_filename , sm_filename_length , "%s/%s_cid-%d-%d.sm" , ompi_process_info .job_session_dir ,
164
+ filename_basename , comm_cid , int_pid );
165
+
150
166
/* open shared memory file, initialize to 0, map into memory */
151
167
sm_fd = open (sm_filename , O_RDWR | O_CREAT ,
152
168
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
0 commit comments