Skip to content

Commit

Permalink
Added CHPL_COMM_OFI_USE_HUGEPAGES and CHPL_RT_COMM_OFI_USE_HUGEPAGES
Browse files Browse the repository at this point in the history
The CHPL_RT_COMM_OFI_USE_HUGEPAGES environment variable controls whether or
not hugepage support is included in the Chapel runtime. The
CHPL_RT_COMM_OFI_USE_HUGEPAGES variable controls whether or not hugepages are
used at runtime.

Signed-off-by: John H. Hartman <[email protected]>
  • Loading branch information
jhh67 committed Jul 25, 2023
1 parent b8c4dbd commit c8d3d2d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
5 changes: 3 additions & 2 deletions runtime/src/comm/ofi/Makefile.share
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ ifneq (, $(findstring pmi2, $(COMM_SRCS)))
endif
endif


#
# Use hugepages on Cray XC and HPE Cray EX systems.
# Use hugepages if requested.
#

ifneq (, $(findstring $(CHPL_MAKE_TARGET_PLATFORM), cray-xc hpe-cray-ex))
ifneq (, $(call isTrue, $(CHPL_COMM_OFI_USE_HUGEPAGES)))
COMM_SRCS += comm-ofi-hugepages.c
else
COMM_SRCS += comm-ofi-no-hugepages.c
Expand Down
4 changes: 4 additions & 0 deletions runtime/src/comm/ofi/comm-ofi-hugepages.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ void* chpl_comm_ofi_hp_get_huge_pages(size_t size) {
size_t chpl_comm_ofi_hp_gethugepagesize(void) {
return gethugepagesize();
}

chpl_bool chpl_comm_ofi_hp_supported(void) {
return true;
}
1 change: 1 addition & 0 deletions runtime/src/comm/ofi/comm-ofi-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ int chpl_comm_ofi_oob_locales_on_node(int *localRank);

void* chpl_comm_ofi_hp_get_huge_pages(size_t);
size_t chpl_comm_ofi_hp_gethugepagesize(void);
chpl_bool chpl_comm_ofi_hp_supported(void);


//
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/comm/ofi/comm-ofi-no-hugepages.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ void* chpl_comm_ofi_hp_get_huge_pages(size_t size) { return NULL; }


size_t chpl_comm_ofi_hp_gethugepagesize(void) { return 0; }

chpl_bool chpl_comm_ofi_hp_supported(void) {return false; }
20 changes: 17 additions & 3 deletions runtime/src/comm/ofi/comm-ofi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3479,6 +3479,10 @@ void init_fixedHeap(void) {

if ((page_size = get_hugepageSize()) == 0) {
have_hugepages = false;
} else {
have_hugepages = true;
}
if (!have_hugepages) {
page_size = chpl_getSysPageSize();
//
// We'll make a fixed heap, on whole pages.
Expand Down Expand Up @@ -3510,7 +3514,6 @@ void init_fixedHeap(void) {
if (start == NULL)
chpl_error("cannot create fixed heap: cannot get memory", 0, 0);
} else {
have_hugepages = true;
//
// We'll make a fixed heap on whole hugepages.
//
Expand Down Expand Up @@ -3562,11 +3565,22 @@ size_t get_hugepageSize(void) {

static
void init_hugepageSize(void) {
if (chpl_numNodes > 1
&& getenv("HUGETLB_DEFAULT_PAGE_SIZE") != NULL) {
chpl_bool use_hugepages = chpl_env_rt_get_bool("COMM_OFI_USE_HUGEPAGES",
false);
if ((chpl_numNodes > 1) && use_hugepages &&
(getenv("HUGETLB_DEFAULT_PAGE_SIZE") != NULL)) {
hugepageSize = chpl_comm_ofi_hp_gethugepagesize();
}

if (use_hugepages && (hugepageSize == 0)) {
if (chpl_comm_ofi_hp_supported()) {
chpl_error("Unable to get hugepage size. "
"Ensure that a hugepage module is loaded.", 0, 0);
} else {
chpl_error("Chapel was not built with hugepage support.", 0, 0);
}
}

DBG_PRINTF(DBG_HUGEPAGES,
"setting hugepage info: use hugepages %s, sz %#zx",
(hugepageSize > 0) ? "YES" : "NO", hugepageSize);
Expand Down

0 comments on commit c8d3d2d

Please sign in to comment.