@@ -255,12 +255,17 @@ component_select(struct ompi_win_t *win, void **base, size_t size, ptrdiff_t dis
255255 module -> posts = calloc (1 , sizeof (module -> posts [0 ]) + sizeof (module -> posts [0 ][0 ]));
256256 if (NULL == module -> posts ) return OMPI_ERR_TEMP_OUT_OF_RESOURCE ;
257257 module -> posts [0 ] = (osc_sm_post_atomic_type_t * ) (module -> posts + 1 );
258+
259+ /* allocate notify counters for single process case */
260+ module -> notify_counters = calloc (OSC_SM_MAX_NOTIFY_COUNTERS , sizeof (uint64_t ));
261+ if (NULL == module -> notify_counters ) return OMPI_ERR_TEMP_OUT_OF_RESOURCE ;
258262 } else {
259263 unsigned long total , * rbuf ;
260264 int i , flag ;
261265 size_t pagesize ;
262266 size_t state_size ;
263267 size_t posts_size , post_size = (comm_size + OSC_SM_POST_MASK ) / (OSC_SM_POST_MASK + 1 );
268+ size_t notify_counters_size ;
264269 size_t data_base_size ;
265270
266271 opal_output_verbose (MCA_BASE_VERBOSE_DEBUG , ompi_osc_base_framework .framework_output ,
@@ -316,7 +321,9 @@ component_select(struct ompi_win_t *win, void **base, size_t size, ptrdiff_t dis
316321 state_size += OPAL_ALIGN_PAD_AMOUNT (state_size , 64 );
317322 posts_size = comm_size * post_size * sizeof (module -> posts [0 ][0 ]);
318323 posts_size += OPAL_ALIGN_PAD_AMOUNT (posts_size , 64 );
319- data_base_size = state_size + posts_size ;
324+ notify_counters_size = OSC_SM_MAX_NOTIFY_COUNTERS * sizeof (uint64_t );
325+ notify_counters_size += OPAL_ALIGN_PAD_AMOUNT (notify_counters_size , 64 );
326+ data_base_size = state_size + posts_size + notify_counters_size ;
320327 data_base_size += OPAL_ALIGN_PAD_AMOUNT (data_base_size , pagesize );
321328 if (0 == ompi_comm_rank (module -> comm )) {
322329 char * data_file ;
@@ -377,6 +384,12 @@ component_select(struct ompi_win_t *win, void **base, size_t size, ptrdiff_t dis
377384 module -> global_state = (ompi_osc_sm_global_state_t * ) (module -> posts [0 ] + comm_size * post_size );
378385 module -> node_states = (ompi_osc_sm_node_state_t * ) (module -> global_state + 1 );
379386
387+ /* set up notify counters in shared memory after node_states */
388+ module -> notify_counters = (uint64_t * ) ((char * )(module -> node_states + comm_size ) +
389+ OPAL_ALIGN_PAD_AMOUNT ((uintptr_t )(module -> node_states + comm_size ), 64 ));
390+ /* zero out notify counters */
391+ memset (module -> notify_counters , 0 , OSC_SM_MAX_NOTIFY_COUNTERS * sizeof (uint64_t ));
392+
380393 for (i = 0 , total = data_base_size ; i < comm_size ; ++ i ) {
381394 if (i > 0 ) {
382395 module -> posts [i ] = module -> posts [i - 1 ] + post_size ;
@@ -555,13 +568,16 @@ ompi_osc_sm_free(struct ompi_win_t *win)
555568 module -> comm -> c_coll -> coll_barrier_module );
556569
557570 opal_shmem_segment_detach (& module -> seg_ds );
571+ /* notify_counters points into shared memory segment, no separate free needed */
558572 } else {
559573 free (module -> node_states );
560574 free (module -> global_state );
561575 if (NULL != module -> bases ) {
562576 mca_mpool_base_default_module -> mpool_free (mca_mpool_base_default_module ,
563577 module -> bases [0 ]);
564578 }
579+ /* free notify_counters for single process case */
580+ free (module -> notify_counters );
565581 }
566582 free (module -> disp_units );
567583 free (module -> outstanding_locks );
0 commit comments