diff --git a/Makefile b/Makefile index 0332d58a3..6fd50d86c 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ include $(MAKE_DIR)/config_git.mk include $(MAKE_DIR)/config_checks.mk include $(MAKE_DIR)/config_defines.mk -INCLUDES += -I./src/includes -I$(LUA_INCLUDE_DIR) -I$(HWLOC_FOLDER)/include -I$(BUILD_DIR) +INCLUDES += -I./src/includes -I$(LUA_INCLUDE_DIR) -I$(HWLOC_INCLUDE_DIR) -I$(BUILD_DIR) LIBS += -ldl ifeq ($(LUA_INTERNAL),false) @@ -262,10 +262,15 @@ $(TARGET_GOTCHA_LIB): @echo "===> ENTER $(GOTCHA_FOLDER)" $(Q)$(MAKE) --no-print-directory -C $(GOTCHA_FOLDER) $(MAKECMDGOALS) - +ifeq ($(USE_HWLOC_INTERNAL),true) $(TARGET_HWLOC_LIB): @echo "===> ENTER $(HWLOC_FOLDER)" $(Q)$(MAKE) --no-print-directory -C $(HWLOC_FOLDER) $(MAKECMDGOALS) +else +$(TARGET_HWLOC_LIB): + @echo "===> EXTERNAL HWLOC" +endif + $(BENCH_TARGET): @echo "===> ENTER $(BENCH_FOLDER)" @@ -327,9 +332,9 @@ distclean: $(TARGET_LUA_LIB) $(TARGET_HWLOC_LIB) $(TARGET_GOTCHA_LIB) $(BENCH_TA @rm -f $(FORTRAN_IF_NAME) @rm -f $(FREQ_TARGET) $(DAEMON_TARGET) $(APPDAEMON_TARGET) @rm -rf $(BUILD_DIR) - @rm -rf $(TARGET_LUA_LIB).* $(shell basename $(TARGET_LUA_LIB)).* - @rm -rf $(TARGET_HWLOC_LIB).* $(shell basename $(TARGET_HWLOC_LIB)).* - @rm -rf $(TARGET_GOTCHA_LIB).* $(shell basename $(TARGET_GOTCHA_LIB)).* + @if [ "$(LUA_INTERNAL)" = "true" ]; then rm -f $(TARGET_LUA_LIB).* $(shell basename $(TARGET_LUA_LIB)).*; fi + @if [ "$(USE_INTERNAL_HWLOC)" = "true" ]; then rm -f $(TARGET_HWLOC_LIB).* $(shell basename $(TARGET_HWLOC_LIB)).*; fi + @rm -f $(TARGET_GOTCHA_LIB).* $(shell basename $(TARGET_GOTCHA_LIB)).* @rm -f $(GENGROUPLOCK) @rm -f likwid-config.cmake @rm -rf doc/html diff --git a/bench/Makefile b/bench/Makefile index fc94c48d8..201a3c72b 100644 --- a/bench/Makefile +++ b/bench/Makefile @@ -72,8 +72,8 @@ endif -SHARED_TARGET_LIB := -L.. -L../ext/hwloc/ -L$(LUA_LIB_DIR) -llikwid -llikwid-hwloc -l$(LUA_LIB_NAME) -STATIC_TARGET_LIB := ../liblikwid.a ../ext/hwloc/liblikwid-hwloc.a $(LUA_LIB_DIR)/lib$(LUA_LIB_NAME).a +SHARED_TARGET_LIB := -L.. -L$(HWLOC_LIB_DIR) -L$(LUA_LIB_DIR) -llikwid -l$(HWLOC_LIB_NAME) -l$(LUA_LIB_NAME) +STATIC_TARGET_LIB := ../liblikwid.a $(HWLOC_LIB_DIR)/lib$(HWLOC_LIB_NAME).a $(LUA_LIB_DIR)/lib$(LUA_LIB_NAME).a TARGET_LIB = $(SHARED_TARGET_LIB) BENCH_LIBS := diff --git a/config.mk b/config.mk index be9e2e530..24aa583bb 100644 --- a/config.mk +++ b/config.mk @@ -90,6 +90,12 @@ INSTALL_CHOWN = -g root -o root#NO SPACE #LUA_LIB_NAME = lua5.2#NO SPACE, executable is assumed to have the same name #LUA_BIN = /usr/bin#NO SPACE +# uncomment to optionally use system hwloc (tested with hwloc 2.x): +# default is to use internal hwloc +#HWLOC_INCLUDE_DIR = /usr/include#NO SPACE +#HWLOC_LIB_DIR = /usr/lib#NO SPACE +#HWLOC_LIB_NAME = hwloc#NO SPACE, used later as -l$HWLOC_LIB_NAME + # Change to true to a build shared library instead of a static one # It is NOT recommended to switch to static libraries as some features don't # work when compiled statically diff --git a/make/config_defines.mk b/make/config_defines.mk index a2652c493..1b6626d99 100644 --- a/make/config_defines.mk +++ b/make/config_defines.mk @@ -32,10 +32,20 @@ LUA_INTERNAL := true#NO SPACE endif SHARED_LIBLUA := lib$(LUA_LIB_NAME).so STATIC_LIBLUA := lib$(LUA_LIB_NAME).a + # HWLOC: +ifdef HWLOC_INCLUDE_DIR +USE_INTERNAL_HWLOC := false#NO SPACE +HWLOC_FOLDER := $(HWLOC_LIB_DIR) +else HWLOC_FOLDER := $(PWD)/ext/hwloc -STATIC_LIBHWLOC := liblikwid-hwloc.a -SHARED_LIBHWLOC := liblikwid-hwloc.so +HWLOC_INCLUDE_DIR := $(HWLOC_FOLDER)/include +HWLOC_LIB_DIR := $(HWLOC_FOLDER) +HWLOC_LIB_NAME := likwid-hwloc +USE_INTERNAL_HWLOC := true#NO SPACE +endif +STATIC_LIBHWLOC := lib$(HWLOC_LIB_NAME).a +SHARED_LIBHWLOC := lib$(HWLOC_LIB_NAME).so GOTCHA_FOLDER := $(PWD)/ext/GOTCHA STATIC_LIBGOTCHA := liblikwid-gotcha.a diff --git a/src/includes/topology_hwloc.h b/src/includes/topology_hwloc.h index a31516094..e42f6762a 100644 --- a/src/includes/topology_hwloc.h +++ b/src/includes/topology_hwloc.h @@ -33,6 +33,15 @@ #include #include +#ifdef USE_INTERNAL_HWLOC +#define HWLOC_PREFIX likwid_ +#else +#define HWLOC_PREFIX +#endif +#define LIKWID_HWLOC_MUNGE_NAME(a, b) LIKWID_HWLOC_MUNGE_NAME2(a, b) +#define LIKWID_HWLOC_MUNGE_NAME2(a, b) a ## b +#define LIKWID_HWLOC_NAME(name) LIKWID_HWLOC_MUNGE_NAME(HWLOC_PREFIX, hwloc_ ## name) + extern hwloc_topology_t hwloc_topology; int likwid_hwloc_record_objs_of_type_below_obj(hwloc_topology_t t, hwloc_obj_t obj, hwloc_obj_type_t type, int* index, uint32_t **list); diff --git a/src/numa_hwloc.c b/src/numa_hwloc.c index 85df10524..686015dda 100644 --- a/src/numa_hwloc.c +++ b/src/numa_hwloc.c @@ -135,11 +135,11 @@ likwid_hwloc_findProcessor(int nodeID, int cpuID) { hwloc_obj_t obj; int i; - int pu_count = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_PU); + int pu_count = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_PU); for (i=0; i 0x00020000 - likwid_hwloc_topology_set_flags(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM ); + LIKWID_HWLOC_NAME(topology_set_flags)(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM ); #else - likwid_hwloc_topology_set_flags(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM|HWLOC_TOPOLOGY_FLAG_WHOLE_IO ); + LIKWID_HWLOC_NAME(topology_set_flags)(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM|HWLOC_TOPOLOGY_FLAG_WHOLE_IO ); #endif - likwid_hwloc_topology_load(hwloc_topology); + LIKWID_HWLOC_NAME(topology_load)(hwloc_topology); } #if defined(__x86_64) || defined(__i386__) - numa_info.numberOfNodes = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, hwloc_type); + numa_info.numberOfNodes = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, hwloc_type); #endif #if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_8A__) numa_info.numberOfNodes = 0; #endif - numPUs = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_PU); + numPUs = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_PU); /* If the amount of NUMA nodes == 0, there is actually no NUMA node, hence aggregate all sockets in the system into the single virtually created NUMA node */ if (numa_info.numberOfNodes == 0) @@ -210,15 +210,15 @@ hwloc_numa_init(void) numa_info.numberOfNodes * sizeof(NumaNode)); return -1; } - depth = likwid_hwloc_get_type_depth(hwloc_topology, hwloc_type); + depth = LIKWID_HWLOC_NAME(get_type_depth)(hwloc_topology, hwloc_type); #if HWLOC_API_VERSION > 0x00020000 - errno = likwid_hwloc_distances_get_by_type(hwloc_topology, hwloc_type, &dist_count, &dists, HWLOC_DISTANCES_KIND_FROM_OS, 0); + errno = LIKWID_HWLOC_NAME(distances_get_by_type)(hwloc_topology, hwloc_type, &dist_count, &dists, HWLOC_DISTANCES_KIND_FROM_OS, 0); #else - distances = likwid_hwloc_get_whole_distance_matrix_by_type(hwloc_topology, hwloc_type); + distances = LIKWID_HWLOC_NAME(get_whole_distance_matrix_by_type)(hwloc_topology, hwloc_type); #endif for (i=0; ios_index; #if HWLOC_API_VERSION > 0x00020000 @@ -267,14 +267,14 @@ hwloc_numa_init(void) for (d = 0; d < cpuid_topology.numHWThreads; d++) { HWThread *t = &cpuid_topology.threadPool[d]; - if (likwid_hwloc_bitmap_isset(obj->cpuset, t->apicId) && t->threadId == 0) + if (LIKWID_HWLOC_NAME(bitmap_isset)(obj->cpuset, t->apicId) && t->threadId == 0) { numa_info.nodes[i].processors[j] = t->apicId; j++; for (int k = 0; k < cpuid_topology.numHWThreads; k++) { HWThread *x = &cpuid_topology.threadPool[k]; - if (t->coreId == x->coreId && t->threadId != x->threadId && likwid_hwloc_bitmap_isset(obj->cpuset, x->apicId)) + if (t->coreId == x->coreId && t->threadId != x->threadId && LIKWID_HWLOC_NAME(bitmap_isset)(obj->cpuset, x->apicId)) { numa_info.nodes[i].processors[j] = x->apicId; j++; @@ -297,11 +297,11 @@ hwloc_numa_init(void) #if HWLOC_API_VERSION > 0x00020000 if (dists) { - int base = hwloc_distances_obj_index(dists, obj); + int base = LIKWID_HWLOC_NAME(distances_obj_index)(dists, obj); for (d = 0; d < dists->nbobjs; d++) { hwloc_obj_t dobj = dists->objs[d]; - int idx = hwloc_distances_obj_index(dists, dobj); + int idx = LIKWID_HWLOC_NAME(distances_obj_index)(dists, dobj); numa_info.nodes[i].distances[idx] = dists->values[(base*dists->nbobjs)+idx]; } numa_info.nodes[i].numberOfDistances = numa_info.numberOfNodes; @@ -328,7 +328,7 @@ hwloc_numa_init(void) #if HWLOC_API_VERSION > 0x00020000 if (dists) { - hwloc_distances_release_remove(hwloc_topology, dists); + LIKWID_HWLOC_NAME(distances_release_remove)(hwloc_topology, dists); } #endif } @@ -351,15 +351,15 @@ hwloc_numa_membind(void* ptr, size_t size, int domainId) if (!ptr || size == 0 || domainId < 0 || domainId >= numa_info.numberOfNodes) return; hwloc_membind_flags_t flags = HWLOC_MEMBIND_STRICT|HWLOC_MEMBIND_PROCESS|HWLOC_MEMBIND_BYNODESET; - hwloc_nodeset_t nodeset = likwid_hwloc_bitmap_alloc(); - likwid_hwloc_bitmap_zero(nodeset); - likwid_hwloc_bitmap_set(nodeset, domainId); + hwloc_nodeset_t nodeset = LIKWID_HWLOC_NAME(bitmap_alloc)(); + LIKWID_HWLOC_NAME(bitmap_zero)(nodeset); + LIKWID_HWLOC_NAME(bitmap_set)(nodeset, domainId); #if HWLOC_API_VERSION > 0x00020000 - ret = likwid_hwloc_set_area_membind(hwloc_topology, ptr, size, nodeset, HWLOC_MEMBIND_BIND, flags); + ret = LIKWID_HWLOC_NAME(set_area_membind)(hwloc_topology, ptr, size, nodeset, HWLOC_MEMBIND_BIND, flags); #else - ret = likwid_hwloc_set_area_membind_nodeset(hwloc_topology, ptr, size, nodeset, HWLOC_MEMBIND_BIND, flags); + ret = LIKWID_HWLOC_NAME(set_area_membind_nodeset)(hwloc_topology, ptr, size, nodeset, HWLOC_MEMBIND_BIND, flags); #endif - likwid_hwloc_bitmap_free(nodeset); + LIKWID_HWLOC_NAME(bitmap_free)(nodeset); if (ret < 0) { @@ -372,21 +372,21 @@ hwloc_numa_setInterleaved(int* processorList, int numberOfProcessors) { int i,j; int ret = 0; - likwid_hwloc_cpuset_t cpuset = hwloc_bitmap_alloc(); - likwid_hwloc_membind_flags_t flags = HWLOC_MEMBIND_STRICT|HWLOC_MEMBIND_PROCESS; - likwid_hwloc_bitmap_zero(cpuset); + LIKWID_HWLOC_NAME(cpuset_t) cpuset = LIKWID_HWLOC_NAME(bitmap_alloc)(); + LIKWID_HWLOC_NAME(membind_flags_t) flags = HWLOC_MEMBIND_STRICT|HWLOC_MEMBIND_PROCESS; + LIKWID_HWLOC_NAME(bitmap_zero)(cpuset); for (i=0; i 0x00020000 - likwid_hwloc_topology_set_flags(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM ); + LIKWID_HWLOC_NAME(topology_set_flags)(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM ); #else - likwid_hwloc_topology_set_flags(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM|HWLOC_TOPOLOGY_FLAG_WHOLE_IO ); + LIKWID_HWLOC_NAME(topology_set_flags)(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM|HWLOC_TOPOLOGY_FLAG_WHOLE_IO ); #endif - likwid_hwloc_topology_load(hwloc_topology); + LIKWID_HWLOC_NAME(topology_load)(hwloc_topology); } - for(i = 0; i < likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_PCI_DEVICE); i++) + for(i = 0; i < LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_PCI_DEVICE); i++) { - obj = likwid_hwloc_get_obj_by_type(hwloc_topology, HWLOC_OBJ_PCI_DEVICE, i); + obj = LIKWID_HWLOC_NAME(get_obj_by_type)(hwloc_topology, HWLOC_OBJ_PCI_DEVICE, i); if (obj->attr->pcidev.vendor_id != testVendor) { continue; diff --git a/src/topology_hwloc.c b/src/topology_hwloc.c index dc8ab02cc..f2a766f9b 100644 --- a/src/topology_hwloc.c +++ b/src/topology_hwloc.c @@ -233,6 +233,8 @@ likwid_hwloc_record_objs_of_type_below_obj( return count; } + + void hwloc_init_cpuInfo(cpu_set_t cpuSet) { @@ -244,16 +246,17 @@ hwloc_init_cpuInfo(cpu_set_t cpuSet) } if (!hwloc_topology) { - likwid_hwloc_topology_init(&hwloc_topology); + //HWLOC_PREFIX#hwloc_topology_init(&hwloc_topology); + LIKWID_HWLOC_NAME(topology_init)(&hwloc_topology); #if HWLOC_API_VERSION > 0x00020000 - likwid_hwloc_topology_set_flags(hwloc_topology, HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED ); - likwid_hwloc_topology_set_type_filter(hwloc_topology, HWLOC_OBJ_PCI_DEVICE, HWLOC_TYPE_FILTER_KEEP_ALL); + LIKWID_HWLOC_NAME(topology_set_flags)(hwloc_topology, HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED ); + LIKWID_HWLOC_NAME(topology_set_type_filter)(hwloc_topology, HWLOC_OBJ_PCI_DEVICE, HWLOC_TYPE_FILTER_KEEP_ALL); #else - likwid_hwloc_topology_set_flags(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM|HWLOC_TOPOLOGY_FLAG_WHOLE_IO ); + LIKWID_HWLOC_NAME(topology_set_flags)(hwloc_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM|HWLOC_TOPOLOGY_FLAG_WHOLE_IO ); #endif - likwid_hwloc_topology_load(hwloc_topology); + LIKWID_HWLOC_NAME(topology_load)(hwloc_topology); } - obj = likwid_hwloc_get_obj_by_type(hwloc_topology, HWLOC_OBJ_SOCKET, 0); + obj = LIKWID_HWLOC_NAME(get_obj_by_type)(hwloc_topology, HWLOC_OBJ_SOCKET, 0); cpuid_info.model = 0; cpuid_info.family = 0; @@ -270,20 +273,20 @@ hwloc_init_cpuInfo(cpu_set_t cpuSet) const char * info; #ifdef __x86_64 - if ((info = hwloc_obj_get_info_by_name(obj, "CPUModelNumber"))) + if ((info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "CPUModelNumber"))) cpuid_info.model = atoi(info); - if ((info = likwid_hwloc_obj_get_info_by_name(obj, "CPUFamilyNumber"))) + if ((info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "CPUFamilyNumber"))) cpuid_info.family = atoi(info); - if ((info = likwid_hwloc_obj_get_info_by_name(obj, "CPUVendor"))) + if ((info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "CPUVendor"))) cpuid_info.isIntel = strcmp(info, "GenuineIntel") == 0; - if ((info = likwid_hwloc_obj_get_info_by_name(obj, "CPUStepping"))) + if ((info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "CPUStepping"))) cpuid_info.stepping = atoi(info); snprintf(cpuid_info.architecture, 19, "x86_64"); #endif #ifdef __ARM_ARCH_7A__ - if ((info = hwloc_obj_get_info_by_name(obj, "CPUArchitecture"))) + if ((info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "CPUArchitecture"))) cpuid_info.family = atoi(info); - if ((info = hwloc_obj_get_info_by_name(obj, "CPURevision"))) + if ((info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "CPURevision"))) cpuid_info.model = atoi(info); if (cpuid_info.family == 0 || cpuid_info.model == 0) { @@ -303,10 +306,10 @@ hwloc_init_cpuInfo(cpu_set_t cpuSet) #endif #ifndef _ARCH_PPC - if ((info = hwloc_obj_get_info_by_name(obj, "CPUModel"))) + if ((info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "CPUModel"))) strcpy(cpuid_info.osname, info); #else - if ((info = likwid_hwloc_obj_get_info_by_name(obj, "CPUModel"))) + if ((info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "CPUModel"))) { if (strstr(info, "POWER7") != NULL) { @@ -340,7 +343,7 @@ hwloc_init_cpuInfo(cpu_set_t cpuSet) #endif - cpuid_topology.numHWThreads = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_PU); + cpuid_topology.numHWThreads = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_PU); #if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_8A) if (count > cpuid_topology.numHWThreads) cpuid_topology.numHWThreads = count; @@ -399,19 +402,19 @@ hwloc_init_nodeTopology(cpu_set_t cpuSet) hwThreadPool[i].inCpuSet = 0; } - maxNumLogicalProcs = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_PU); - maxNumCores = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_CORE); - if (likwid_hwloc_get_nbobjs_by_type(hwloc_topology, socket_type) == 0) + maxNumLogicalProcs = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_PU); + maxNumCores = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_CORE); + if (LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, socket_type) == 0) { socket_type = HWLOC_OBJ_NODE; } - maxNumSockets = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, socket_type); - obj = likwid_hwloc_get_obj_by_type(hwloc_topology, socket_type, 0); + maxNumSockets = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, socket_type); + obj = LIKWID_HWLOC_NAME(get_obj_by_type)(hwloc_topology, socket_type, 0); if (obj) { maxNumCoresPerSocket = likwid_hwloc_record_objs_of_type_below_obj(hwloc_topology, obj, HWLOC_OBJ_CORE, NULL, NULL); } - obj = likwid_hwloc_get_obj_by_type(hwloc_topology, HWLOC_OBJ_CORE, 0); + obj = LIKWID_HWLOC_NAME(get_obj_by_type)(hwloc_topology, HWLOC_OBJ_CORE, 0); if (obj) { maxNumLogicalProcsPerCore = likwid_hwloc_record_objs_of_type_below_obj(hwloc_topology, obj, HWLOC_OBJ_PU, NULL, NULL); @@ -423,7 +426,7 @@ hwloc_init_nodeTopology(cpu_set_t cpuSet) for (uint32_t i=0; i< cpuid_topology.numHWThreads; i++) { int skip = 0; - obj = likwid_hwloc_get_obj_by_type(hwloc_topology, HWLOC_OBJ_PU, i); + obj = LIKWID_HWLOC_NAME(get_obj_by_type)(hwloc_topology, HWLOC_OBJ_PU, i); if (!obj) { continue; @@ -571,29 +574,29 @@ void hwloc_split_llc_check(CacheLevel* llc_cache) { int i = 0; hwloc_obj_t obj = NULL; - int num_sockets = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_SOCKET); - int num_nodes = likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_NODE); + int num_sockets = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_SOCKET); + int num_nodes = LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_NODE); if (num_sockets == num_nodes) { return; } - obj = likwid_hwloc_get_obj_by_type(hwloc_topology, HWLOC_OBJ_SOCKET, 0); + obj = LIKWID_HWLOC_NAME(get_obj_by_type)(hwloc_topology, HWLOC_OBJ_SOCKET, 0); int num_threads_per_socket = likwid_hwloc_record_objs_of_type_below_obj(hwloc_topology, obj, HWLOC_OBJ_PU, NULL, NULL); if (num_threads_per_socket == 0) { - for (i = 0; i < likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_PU); i++) + for (i = 0; i < LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_PU); i++) { - if (hwloc_bitmap_isset(obj->cpuset, i)) + if (LIKWID_HWLOC_NAME(bitmap_isset)(obj->cpuset, i)) num_threads_per_socket++; } } - obj = likwid_hwloc_get_obj_by_type(hwloc_topology, HWLOC_OBJ_NODE, 0); + obj = LIKWID_HWLOC_NAME(get_obj_by_type)(hwloc_topology, HWLOC_OBJ_NODE, 0); int num_threads_per_node = likwid_hwloc_record_objs_of_type_below_obj(hwloc_topology, obj, HWLOC_OBJ_PU, NULL, NULL); if (num_threads_per_node == 0) { - for (i = 0; i < likwid_hwloc_get_nbobjs_by_type(hwloc_topology, HWLOC_OBJ_PU); i++) + for (i = 0; i < LIKWID_HWLOC_NAME(get_nbobjs_by_type)(hwloc_topology, HWLOC_OBJ_PU); i++) { - if (hwloc_bitmap_isset(obj->cpuset, i)) + if (LIKWID_HWLOC_NAME(bitmap_isset)(obj->cpuset, i)) num_threads_per_node++; } } @@ -619,11 +622,11 @@ hwloc_init_cacheTopology(void) const char* info; /* Sum up all depths with caches */ - depth = likwid_hwloc_topology_get_depth(hwloc_topology); + depth = LIKWID_HWLOC_NAME(topology_get_depth)(hwloc_topology); for (d = 0; d < depth; d++) { #if HWLOC_API_VERSION > 0x00020000 - hwloc_obj_type_t depth_type = likwid_hwloc_get_depth_type(hwloc_topology, d); + hwloc_obj_type_t depth_type = LIKWID_HWLOC_NAME(get_depth_type)(hwloc_topology, d); if (depth_type == HWLOC_OBJ_L1CACHE || depth_type == HWLOC_OBJ_L2CACHE || depth_type == HWLOC_OBJ_L3CACHE || @@ -631,7 +634,7 @@ hwloc_init_cacheTopology(void) depth_type == HWLOC_OBJ_L5CACHE) maxNumLevels++; #else - if (likwid_hwloc_get_depth_type(hwloc_topology, d) == HWLOC_OBJ_CACHE) + if (LIKWID_HWLOC_NAME(get_depth_type)(hwloc_topology, d) == HWLOC_OBJ_CACHE) maxNumLevels++; #endif } @@ -643,20 +646,20 @@ hwloc_init_cacheTopology(void) return; } /* Start at the bottom of the tree to get all cache levels in order */ - depth = likwid_hwloc_topology_get_depth(hwloc_topology); + depth = LIKWID_HWLOC_NAME(topology_get_depth)(hwloc_topology); id = 0; for(d=depth-1;d >= 0; d--) { /* We only need caches, so skip other levels */ #if HWLOC_API_VERSION > 0x00020000 - hwloc_obj_type_t depth_type = likwid_hwloc_get_depth_type(hwloc_topology, d); + hwloc_obj_type_t depth_type = LIKWID_HWLOC_NAME(get_depth_type)(hwloc_topology, d); if (depth_type != HWLOC_OBJ_L1CACHE && depth_type != HWLOC_OBJ_L2CACHE && depth_type != HWLOC_OBJ_L3CACHE && depth_type != HWLOC_OBJ_L4CACHE && depth_type != HWLOC_OBJ_L5CACHE) #else - if (likwid_hwloc_get_depth_type(hwloc_topology, d) < HWLOC_OBJ_CACHE) + if (LIKWID_HWLOC_NAME(get_depth_type)(hwloc_topology, d) < HWLOC_OBJ_CACHE) #endif { continue; @@ -670,7 +673,7 @@ hwloc_init_cacheTopology(void) cachePool[id].inclusive = 0; cachePool[id].threads = 0; /* Get the cache object */ - obj = likwid_hwloc_get_obj_by_depth(hwloc_topology, d, 0); + obj = LIKWID_HWLOC_NAME(get_obj_by_depth)(hwloc_topology, d, 0); /* All caches have this attribute, so safe to access */ switch (obj->attr->cache.type) { @@ -714,7 +717,7 @@ hwloc_init_cacheTopology(void) #if defined(__x86_64) || defined(__i386__) if (obj->infos_count > 0) { - while (!(info = likwid_hwloc_obj_get_info_by_name(obj, "inclusiveness")) && obj->next_cousin) + while (!(info = LIKWID_HWLOC_NAME(obj_get_info_by_name)(obj, "inclusiveness")) && obj->next_cousin) { // If some PU/core are not bindable because of cgroup, hwloc may // not know the inclusiveness of some of their cache. @@ -774,7 +777,7 @@ hwloc_close(void) { if (hwloc_topology) { - likwid_hwloc_topology_destroy(hwloc_topology); + LIKWID_HWLOC_NAME(topology_destroy)(hwloc_topology); hwloc_topology = NULL; } }