Skip to content

Commit 1f5ed0b

Browse files
authored
Merge pull request #8070 from devreal/osc-page-align
OSC RDMA: put memory for each process into separate pages
2 parents 08f6867 + 52b52b8 commit 1f5ed0b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ompi/mca/osc/rdma/osc_rdma_component.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "opal/util/argv.h"
4848
#include "opal/util/printf.h"
4949
#include "opal/align.h"
50+
#include "opal/util/sys_limits.h"
5051
#if OPAL_CUDA_SUPPORT
5152
#include "opal/datatype/opal_datatype_cuda.h"
5253
#endif /* OPAL_CUDA_SUPPORT */
@@ -550,6 +551,7 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
550551
ompi_osc_rdma_region_t *state_region;
551552
struct _local_data *temp;
552553
char *data_file;
554+
int page_size = opal_getpagesize();
553555

554556
shared_comm = module->shared_comm;
555557

@@ -575,9 +577,9 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
575577
data_base = state_base + leader_peer_data_size + module->state_size * local_size;
576578

577579
/* ensure proper alignment */
578-
data_base += OPAL_ALIGN_PAD_AMOUNT(data_base, OPAL_ALIGN_MIN);
579580
if (MPI_WIN_FLAVOR_ALLOCATE == module->flavor) {
580-
size += OPAL_ALIGN_PAD_AMOUNT(size, OPAL_ALIGN_MIN);
581+
data_base += OPAL_ALIGN_PAD_AMOUNT(data_base, page_size);
582+
size += OPAL_ALIGN_PAD_AMOUNT(size, page_size);
581583
}
582584

583585
do {
@@ -648,8 +650,12 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
648650
}
649651

650652
if (size && MPI_WIN_FLAVOR_ALLOCATE == module->flavor) {
651-
*base = (void *)((intptr_t) module->segment_base + my_base_offset);
652-
memset (*base, 0, size);
653+
char *baseptr = (char *)((intptr_t) module->segment_base + my_base_offset);
654+
*base = (void *)baseptr;
655+
// touch each page to force allocation on local NUMA node
656+
for (size_t i = 0; i < size; i += page_size) {
657+
baseptr[i] = 0;
658+
}
653659
}
654660

655661
module->rank_array = (ompi_osc_rdma_rank_data_t *) module->segment_base;

0 commit comments

Comments
 (0)