Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion parsec/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 5 additions & 3 deletions parsec/parsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 16 additions & 7 deletions parsec/parsec_hwloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
16 changes: 16 additions & 0 deletions parsec/parsec_hwloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) */

/**
Expand Down
8 changes: 6 additions & 2 deletions parsec/vpmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
Loading