Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove early-out in runtime topo layer #26415

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 3 additions & 52 deletions runtime/src/topo/hwloc/topo-hwloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ static chpl_bool debug = true;
static chpl_bool debug = false;
#endif

static chpl_bool haveTopology = false;

static hwloc_topology_t topology;

static const struct hwloc_topology_support* topoSupport;
Expand Down Expand Up @@ -148,25 +146,11 @@ static void chk_err_errno_fn(const char*, int, const char*);

void chpl_topo_pre_comm_init(char *accessiblePUsMask) {
//
// accessibleMask is a string in hwloc "bitmap list" format that
// accessiblePUsMask is a string in hwloc "bitmap list" format that
// specifies which processing units should be considered accessible
// to this locale. It is intended for testing purposes only and
// should be NULL in production code.

//
// We only load hwloc topology information in configurations where
// the locale model is other than "flat" or the tasking is based on
// Qthreads (which will use the topology we load). We don't use
// it otherwise (so far) because loading it is somewhat expensive.
//
if (strcmp(CHPL_LOCALE_MODEL, "flat") != 0
|| strcmp(CHPL_TASKS, "qthreads") == 0) {
haveTopology = true;
} else {
haveTopology = false;
return;
}

//
// Allocate and initialize topology object.
//
Expand Down Expand Up @@ -247,10 +231,6 @@ void chpl_topo_post_comm_init(void) {


void chpl_topo_exit(void) {
if (!haveTopology) {
return;
}

if (physAccSet != NULL) {
hwloc_bitmap_free(physAccSet);
physAccSet = NULL;
Expand Down Expand Up @@ -291,7 +271,7 @@ void chpl_topo_exit(void) {


void* chpl_topo_getHwlocTopology(void) {
return (haveTopology) ? topology : NULL;
return topology;
}

//
Expand Down Expand Up @@ -844,10 +824,6 @@ void chpl_topo_setThreadLocality(c_sublocid_t subloc) {

_DBG_P("chpl_topo_setThreadLocality(%d)", (int) subloc);

if (!haveTopology) {
return;
}

if (!topoSupport->cpubind->set_thread_cpubind)
return;

Expand Down Expand Up @@ -877,10 +853,6 @@ c_sublocid_t chpl_topo_getThreadLocality(void) {
int flags;
int node;

if (!haveTopology) {
return c_sublocid_none;
}

if (!topoSupport->cpubind->get_thread_cpubind) {
return c_sublocid_none;
}
Expand Down Expand Up @@ -911,10 +883,6 @@ void chpl_topo_setMemLocality(void* p, size_t size, chpl_bool onlyInside,
_DBG_P("chpl_topo_setMemLocality(%p, %#zx, onlyIn=%s, %d)",
p, size, (onlyInside ? "T" : "F"), (int) subloc);

if (!haveTopology) {
return;
}

alignAddrSize(p, size, onlyInside, &pgSize, &pPgLo, &nPages);

_DBG_P(" localize %p, %#zx bytes (%#zx pages)",
Expand All @@ -940,10 +908,6 @@ void chpl_topo_setMemSubchunkLocality(void* p, size_t size,
_DBG_P("chpl_topo_setMemSubchunkLocality(%p, %#zx, onlyIn=%s)",
p, size, (onlyInside ? "T" : "F"));

if (!haveTopology) {
return;
}

alignAddrSize(p, size, onlyInside, &pgSize, &pPgLo, &nPages);

_DBG_P(" localize %p, %#zx bytes (%#zx pages)",
Expand Down Expand Up @@ -977,8 +941,7 @@ void chpl_topo_touchMemFromSubloc(void* p, size_t size, chpl_bool onlyInside,
_DBG_P("chpl_topo_touchMemFromSubloc(%p, %#zx, onlyIn=%s, %d)",
p, size, (onlyInside ? "T" : "F"), (int) subloc);

if (!haveTopology
|| !topoSupport->cpubind->get_thread_cpubind
if (!topoSupport->cpubind->get_thread_cpubind
|| !topoSupport->cpubind->set_thread_cpubind) {
return;
}
Expand Down Expand Up @@ -1056,10 +1019,6 @@ void alignAddrSize(void* p, size_t size, chpl_bool onlyInside,
void chpl_topo_interleaveMemLocality(void* p, size_t size) {
int flags;

if (!haveTopology) {
return;
}

if (!topoSupport->membind->set_area_membind ||
!topoSupport->membind->interleave_membind) {
return;
Expand All @@ -1080,10 +1039,6 @@ void chpl_topo_setMemLocalityByPages(unsigned char* p, size_t size,
hwloc_obj_t numaObj) {
int flags;

if (!haveTopology) {
return;
}

if (!topoSupport->membind->set_area_membind
|| !do_set_area_membind)
return;
Expand All @@ -1104,10 +1059,6 @@ c_sublocid_t chpl_topo_getMemLocality(void* p) {
hwloc_nodeset_t nodeset;
int node;

if (!haveTopology) {
return c_sublocid_none;
}

if (!topoSupport->membind->get_area_memlocation) {
return c_sublocid_none;
}
Expand Down
Loading