From c613a84655e6e3dd0708ed8a8843bcbe0953e5e1 Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Sun, 7 Jun 2026 20:21:33 -0400 Subject: [PATCH 1/2] Fix no-hwloc build Some code paths were not properly protected if we could not find hwloc. Signed-off-by: Joseph Schuchart --- parsec/parsec.c | 8 +++++--- parsec/parsec_hwloc.c | 23 ++++++++++++++++------- parsec/parsec_hwloc.h | 16 ++++++++++++++++ parsec/vpmap.c | 8 ++++++-- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/parsec/parsec.c b/parsec/parsec.c index 7f4bbf71c..3b9e187d3 100644 --- a/parsec/parsec.c +++ b/parsec/parsec.c @@ -824,18 +824,20 @@ parsec_context_t* parsec_init( int nb_cores, int* pargc, char** pargv[] ) /* Introduce communication engine */ (void)parsec_remote_dep_init(context); +#if defined(PARSEC_HAVE_HWLOC) if( parsec_report_bindings) { char *str; - hwloc_bitmap_asprintf(&str, context->cpuset_allowed_mask); + HWLOC_ASPRINTF(&str, context->cpuset_allowed_mask); parsec_inform("Process binding [rank %d]: cpuset [ALLOWED ]: %s\n", context->my_rank, str); free(str); - hwloc_bitmap_asprintf(&str, context->cpuset_used_mask); + HWLOC_ASPRINTF(&str, context->cpuset_used_mask); parsec_inform("Process binding [rank %d]: cpuset [USED ]: %s\n", context->my_rank, str); free(str); - hwloc_bitmap_asprintf(&str, context->cpuset_free_mask); + HWLOC_ASPRINTF(&str, context->cpuset_free_mask); parsec_inform("Process binding [rank %d]: cpuset [FREE ]: %s\n", context->my_rank, str); free(str); } +#endif /* defined(PARSEC_HAVE_HWLOC) */ /* print a warning if multiple ranks share the same PU/cores * note we do it only once during init, we don't recheck during diff --git a/parsec/parsec_hwloc.c b/parsec/parsec_hwloc.c index 8dd4df0c4..24d40005f 100644 --- a/parsec/parsec_hwloc.c +++ b/parsec/parsec_hwloc.c @@ -25,9 +25,9 @@ static hwloc_topology_t parsec_hwloc_loaded_topology; static hwloc_topology_t parsec_hwloc_restricted_topology; static int parsec_hwloc_first_init = 1; +static int parsec_available_binding_resources = 1; #endif /* defined(PARSEC_HAVE_HWLOC) */ static int hyperth_per_core = 1; -static int parsec_available_binding_resources = 1; #if defined(PARSEC_HAVE_HWLOC_PARENT_MEMBER) #define HWLOC_GET_PARENT(OBJ) (OBJ)->parent @@ -59,19 +59,19 @@ char* parsec_hwloc_convert_cpuset(int convert_to_system, hwloc_cpuset_t cpuset) hwloc_cpuset_t binding_mask; binding_mask = parsec_hwloc_cpuset_convert_to_system(cpuset); HWLOC_ASPRINTF(&str, binding_mask); - hwloc_bitmap_free(binding_mask); + HWLOC_FREE(binding_mask); } else { HWLOC_ASPRINTF(&str, cpuset); } return str; } +#if defined(PARSEC_HAVE_HWLOC) /** * Print the cpuset as a string prefaced with the provided message. */ static void parsec_hwloc_print_cpuset(int verb, int convert_to_system, char* msg, hwloc_cpuset_t cpuset) { -#if defined(PARSEC_HAVE_HWLOC) char *str = NULL; str = parsec_hwloc_convert_cpuset(convert_to_system, cpuset); @@ -80,11 +80,8 @@ static void parsec_hwloc_print_cpuset(int verb, int convert_to_system, char* msg else if( 2 == verb ) parsec_inform("%s %s", msg, str); else parsec_debug_verbose(verb, parsec_debug_output, "%s %s", msg, str); free(str); -#else - (void)cpuset;(void)verb; - parsec_debug_verbose(3, parsec_debug_output, "%s compiled without HWLOC support", msg); -#endif /* defined(PARSEC_HAVE_HWLOC) */ } +#endif /* defined(PARSEC_HAVE_HWLOC) */ int parsec_hwloc_init(void) { @@ -383,9 +380,14 @@ unsigned int parsec_hwloc_nb_cores_per_obj( int level, int index ) hwloc_cpuset_t parsec_hwloc_cpuset_per_obj(int level, int index) { +#if defined(PARSEC_HAVE_HWLOC) hwloc_obj_t obj = hwloc_get_obj_by_depth(parsec_hwloc_loaded_topology, level, index); if(NULL == obj) return NULL; return HWLOC_DUP(obj->cpuset); +#else + (void)level; (void)index; + return 0; +#endif /* defined(PARSEC_HAVE_HWLOC) */ } int parsec_hwloc_nb_levels(void) @@ -421,6 +423,9 @@ char *parsec_hwloc_get_binding(hwloc_cpuset_t* cpuset, int flag) } return binding; #else + // unused + (void)cpuset; + (void)flag; return NULL; #endif } @@ -482,6 +487,7 @@ int parsec_hwloc_bind_on_core_index(int cpu_index, int local_ht_index) hwloc_cpuset_t parsec_hwloc_cpuset_convert_to_system(hwloc_cpuset_t cpuset) { +#if defined(PARSEC_HAVE_HWLOC) unsigned cpu_index; hwloc_obj_t obj; hwloc_cpuset_t binding_mask; @@ -505,6 +511,9 @@ hwloc_cpuset_t parsec_hwloc_cpuset_convert_to_system(hwloc_cpuset_t cpuset) } hwloc_bitmap_foreach_end(); return binding_mask; +#else + return cpuset; +#endif /* defined(PARSEC_HAVE_HWLOC) */ } int parsec_hwloc_bind_on_mask_index(hwloc_cpuset_t cpuset) { diff --git a/parsec/parsec_hwloc.h b/parsec/parsec_hwloc.h index 1a3265ed1..2907454bb 100644 --- a/parsec/parsec_hwloc.h +++ b/parsec/parsec_hwloc.h @@ -28,6 +28,7 @@ BEGIN_C_DECLS #define HWLOC_FREE hwloc_bitmap_free #define HWLOC_INTERSECTS hwloc_bitmap_intersects #define HWLOC_OR hwloc_bitmap_or +#define HWLOC_SET_RANGE hwloc_bitmap_set_range #else #define HWLOC_ASPRINTF hwloc_cpuset_asprintf #define HWLOC_ISSET hwloc_cpuset_isset @@ -40,7 +41,22 @@ BEGIN_C_DECLS #define HWLOC_OR hwloc_cpuset_or #define HWLOC_SINGLIFY hwloc_cpuset_singlify #define HWLOC_FREE hwloc_cpuset_free +#define HWLOC_SET_RANGE hwloc_cpuset_set_range #endif /* defined(PARSEC_HAVE_HWLOC_BITMAP) */ +#else /* !defined(PARSEC_HAVE_HWLOC) */ +/* No-op stubs so code using these macros compiles without hwloc */ +#define HWLOC_ALLOC() 0 +#define HWLOC_FREE(b) ((void)(b)) +#define HWLOC_DUP(b) 0 +#define HWLOC_ISSET(b,i) 0 +#define HWLOC_SET(b,i) ((void)(0)) +#define HWLOC_FIRST(b) (-1) +#define HWLOC_WEIGHT(b) 0 +#define HWLOC_SINGLIFY(b) ((void)(0)) +#define HWLOC_INTERSECTS(a,b) 0 +#define HWLOC_OR(d,s1,s2) ((void)(0)) +#define HWLOC_ASPRINTF(s,b) ((void)(*(s) = NULL)) +#define HWLOC_SET_RANGE(b,start,count) ((void)(0)) #endif /* defined(PARSEC_HAVE_HWLOC) */ /** diff --git a/parsec/vpmap.c b/parsec/vpmap.c index 63526c954..046b3a927 100644 --- a/parsec/vpmap.c +++ b/parsec/vpmap.c @@ -150,7 +150,7 @@ int parsec_vpmap_init(char* optarg, int nb_cores ) parsec_vpmap[i].threads[j].cpuset = HWLOC_ALLOC(); } if( parsec_runtime_singlify_bindings > 0 ) /* late singlify */ - hwloc_bitmap_singlify(parsec_vpmap[i].threads[j].cpuset); + HWLOC_SINGLIFY(parsec_vpmap[i].threads[j].cpuset); if( HWLOC_INTERSECTS(parsec_vpmap[i].cpuset, parsec_vpmap[i].threads[j].cpuset) ) { /* overlap detected, show it to the user */ if(parsec_report_binding_issues) { @@ -210,7 +210,11 @@ hwloc_cpuset_t parsec_vpmap_get_vp_thread_affinity(int vp, int thread, int *ht) (parsec_vpmap == NULL) || (thread < 0) || (thread >= parsec_vpmap[vp].nbthreads ) ) +#if defined(PARSEC_HAVE_HWLOC) return NULL; +#else + return 0; +#endif /* defined(PARSEC_HAVE_HWLOC) */ *ht = parsec_vpmap[vp].threads[thread].ht; return parsec_vpmap[vp].threads[thread].cpuset; } @@ -406,7 +410,7 @@ int parsec_vpmap_init_from_flat(int nbthreads) parsec_vpmap[0].threads[id].nbcores = step; parsec_vpmap[0].threads[id].cpuset = HWLOC_ALLOC(); parsec_vpmap[0].threads[id].ht = 0; - hwloc_bitmap_set_range(parsec_vpmap[0].threads[id].cpuset, id * step, (id+1) * step - 1); + HWLOC_SET_RANGE(parsec_vpmap[0].threads[id].cpuset, id * step, (id+1) * step - 1); } parsec_nb_total_threads = nbthreads; return PARSEC_SUCCESS; From 3eda4de0c6df58ce84ce80c9f5c2e4a9a28d2c37 Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Sun, 7 Jun 2026 20:26:45 -0400 Subject: [PATCH 2/2] Fix mismatching datatype NULL Not every MPI implementation uses pointers for MPI handles. Signed-off-by: Joseph Schuchart --- parsec/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsec/data.c b/parsec/data.c index 306a6c507..29770d593 100644 --- a/parsec/data.c +++ b/parsec/data.c @@ -635,7 +635,7 @@ static void parsec_arena_datatype_construct(parsec_object_t *obj) { adt->ht_item.next_item = NULL; /* keep Coverity happy */ adt->ht_item.hash64 = 0; /* keep Coverity happy */ adt->ht_item.key = 0; /* keep Coverity happy */ - adt->opaque_dtt = NULL; + adt->opaque_dtt = PARSEC_DATATYPE_NULL; } static void parsec_arena_datatype_destruct(parsec_object_t *obj) {