88#include "mpl_shm.h"
99#include "mpidimpl.h"
1010#include "mpir_pmi.h"
11- #include "mpidu_shm_seg.h"
1211
1312static int init_shm_initialized ;
1413
@@ -58,7 +57,10 @@ typedef struct Init_shm_barrier {
5857 MPL_atomic_int_t wait ;
5958} Init_shm_barrier_t ;
6059
61- static MPIDU_shm_seg_t memory ;
60+ static size_t init_shm_len ;
61+ static MPL_shm_hnd_t init_shm_hnd ;
62+ static char * init_shm_addr ;
63+
6264static Init_shm_barrier_t * barrier ;
6365static void * baseaddr ;
6466
@@ -70,7 +72,7 @@ static int Init_shm_barrier_init(int is_root)
7072
7173 MPIR_FUNC_ENTER ;
7274
73- barrier = (Init_shm_barrier_t * ) memory . base_addr ;
75+ barrier = (Init_shm_barrier_t * ) init_shm_addr ;
7476 if (is_root ) {
7577 MPL_atomic_store_int (& barrier -> val , 0 );
7678 MPL_atomic_store_int (& barrier -> wait , 0 );
@@ -136,20 +138,20 @@ int MPIDU_Init_shm_init(void)
136138 char * serialized_hnd = NULL ;
137139 int serialized_hnd_size = 0 ;
138140
139- mpl_err = MPL_shm_hnd_init (& ( memory . hnd ) );
141+ mpl_err = MPL_shm_hnd_init (& init_shm_hnd );
140142 MPIR_ERR_CHKANDJUMP (mpl_err , mpi_errno , MPI_ERR_OTHER , "**alloc_shar_mem" );
141143
142- memory . segment_len = segment_len ;
144+ init_shm_len = segment_len ;
143145
144146 if (MPIDU_Init_shm_local_rank == 0 ) {
145147 /* root prepare shm segment */
146- mpl_err = MPL_shm_seg_create_and_attach (memory . hnd , memory . segment_len ,
147- (void * * ) & (memory . base_addr ), 0 );
148+ mpl_err = MPL_shm_seg_create_and_attach (init_shm_hnd , init_shm_len ,
149+ (void * * ) & (init_shm_addr ), 0 );
148150 MPIR_ERR_CHKANDJUMP (mpl_err , mpi_errno , MPI_ERR_OTHER , "**alloc_shar_mem" );
149151
150152 MPIR_Assert (MPIR_Process .node_local_map [0 ] == MPIR_Process .rank );
151153
152- mpl_err = MPL_shm_hnd_get_serialized_by_ref (memory . hnd , & serialized_hnd );
154+ mpl_err = MPL_shm_hnd_get_serialized_by_ref (init_shm_hnd , & serialized_hnd );
153155 MPIR_ERR_CHKANDJUMP (mpl_err , mpi_errno , MPI_ERR_OTHER , "**alloc_shar_mem" );
154156 serialized_hnd_size = strlen (serialized_hnd ) + 1 ;
155157 MPIR_Assert (serialized_hnd_size < MPIR_pmi_max_val_size ());
@@ -169,11 +171,10 @@ int MPIDU_Init_shm_init(void)
169171
170172 if (MPIDU_Init_shm_local_rank > 0 ) {
171173 /* non-root attach shm segment */
172- mpl_err = MPL_shm_hnd_deserialize (memory . hnd , serialized_hnd , strlen (serialized_hnd ));
174+ mpl_err = MPL_shm_hnd_deserialize (init_shm_hnd , serialized_hnd , strlen (serialized_hnd ));
173175 MPIR_ERR_CHKANDJUMP (mpl_err , mpi_errno , MPI_ERR_OTHER , "**alloc_shar_mem" );
174176
175- mpl_err = MPL_shm_seg_attach (memory .hnd , memory .segment_len ,
176- (void * * ) & memory .base_addr , 0 );
177+ mpl_err = MPL_shm_seg_attach (init_shm_hnd , init_shm_len , (void * * ) & init_shm_addr , 0 );
177178 MPIR_ERR_CHKANDJUMP (mpl_err , mpi_errno , MPI_ERR_OTHER , "**attach_shar_mem" );
178179
179180 mpi_errno = Init_shm_barrier_init (FALSE);
@@ -184,13 +185,12 @@ int MPIDU_Init_shm_init(void)
184185 MPIR_ERR_CHECK (mpi_errno );
185186
186187 if (MPIDU_Init_shm_local_rank == 0 ) {
187- /* memory->hnd no longer needed */
188- mpl_err = MPL_shm_seg_remove (memory . hnd );
188+ /* init_shm_hnd no longer needed */
189+ mpl_err = MPL_shm_seg_remove (init_shm_hnd );
189190 MPIR_ERR_CHKANDJUMP (mpl_err , mpi_errno , MPI_ERR_OTHER , "**remove_shar_mem" );
190191 }
191192
192- baseaddr = memory .base_addr + MPIDU_SHM_CACHE_LINE_LEN ;
193- memory .symmetrical = 0 ;
193+ baseaddr = init_shm_addr + MPIDU_SHM_CACHE_LINE_LEN ;
194194
195195 mpi_errno = Init_shm_barrier ();
196196 }
@@ -215,10 +215,10 @@ int MPIDU_Init_shm_finalize(void)
215215 goto fn_exit ;
216216 }
217217
218- mpl_err = MPL_shm_seg_detach (memory . hnd , (void * * ) & (memory . base_addr ), memory . segment_len );
218+ mpl_err = MPL_shm_seg_detach (init_shm_hnd , (void * * ) & (init_shm_addr ), init_shm_len );
219219 MPIR_ERR_CHKANDJUMP (mpl_err , mpi_errno , MPI_ERR_OTHER , "**detach_shar_mem" );
220220
221- MPL_shm_hnd_finalize (& (memory . hnd ));
221+ MPL_shm_hnd_finalize (& (init_shm_hnd ));
222222
223223 init_shm_initialized = 0 ;
224224
0 commit comments