Skip to content

Commit f0ee69f

Browse files
author
Joseph Antony
committed
Notified RMA counters memory allocation in the shared memory segment for a single and multi rank window.
Signed-off-by: Joseph Antony <jajoseph.antony18@gmail.com>
1 parent 088364c commit f0ee69f

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

ompi/mca/osc/sm/osc_sm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ typedef uint64_t osc_sm_post_type_t;
2222
typedef opal_atomic_uint64_t osc_sm_post_atomic_type_t;
2323
#define OSC_SM_POST_BITS 6
2424
#define OSC_SM_POST_MASK 0x3f
25+
#define OSC_SM_MAX_NOTIFY_COUNTERS 16
2526

2627
/* data shared across all peers */
2728
struct ompi_osc_sm_global_state_t {
@@ -79,7 +80,7 @@ struct ompi_osc_sm_module_t {
7980
size_t *sizes;
8081
void **bases;
8182
ptrdiff_t *disp_units;
82-
uint64_t **notify_counters;
83+
uint64_t *notify_counters;
8384

8485

8586
ompi_group_t *start_group;

ompi/mca/osc/sm/osc_sm_component.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)