Skip to content

Add option to disable hwloc #642

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

Merged
merged 1 commit into from
Jul 29, 2024
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
11 changes: 10 additions & 1 deletion .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
shared_library: ['OFF']
level_zero_provider: ['ON']
install_tbb: ['ON']
disable_hwloc: ['OFF']
include:
- os: 'ubuntu-20.04'
build_type: Release
Expand Down Expand Up @@ -69,6 +70,13 @@ jobs:
shared_library: 'ON'
level_zero_provider: 'ON'
install_tbb: 'OFF'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
shared_library: 'ON'
level_zero_provider: 'ON'
install_tbb: 'ON'
disable_hwloc: 'ON'
runs-on: ${{matrix.os}}

steps:
Expand Down Expand Up @@ -122,6 +130,7 @@ jobs:
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON
-DUMF_DISABLE_HWLOC=${{matrix.disable_hwloc}}

- name: Build UMF
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
Expand All @@ -144,7 +153,7 @@ jobs:
--build-type ${{matrix.build_type}}
--disjoint-pool
--jemalloc-pool
${{ matrix.install_tbb == 'ON' && '--proxy' || '' }}
${{ matrix.install_tbb == 'ON' && matrix.disable_hwloc != 'ON' && '--proxy' || '' }}
--umf-version ${{env.UMF_VERSION}}
${{ matrix.shared_library == 'ON' && '--shared-library' || '' }}

Expand Down
27 changes: 19 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ option(USE_TSAN "Enable ThreadSanitizer checks" OFF)
option(USE_MSAN "Enable MemorySanitizer checks" OFF)
option(USE_VALGRIND "Enable Valgrind instrumentation" OFF)
option(USE_GCOV "Enable gcov support" OFF)
option(
UMF_DISABLE_HWLOC
"Disable features that requires hwloc (OS provider, memory targets, topolgy discovery)"
OFF)

# set UMF_PROXY_LIB_BASED_ON_POOL to one of: SCALABLE or JEMALLOC
set(KNOWN_PROXY_LIB_POOLS SCALABLE JEMALLOC)
Expand Down Expand Up @@ -95,14 +99,17 @@ else()
endif()

if(NOT UMF_LINK_HWLOC_STATICALLY)
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
if(NOT LIBHWLOC_FOUND)
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
if(NOT UMF_DISABLE_HWLOC)
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
if(NOT LIBHWLOC_FOUND)
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
endif()

# add PATH to DLL on Windows
set(DLL_PATH_LIST
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin"
)
endif()
# add PATH to DLL on Windows
set(DLL_PATH_LIST
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin"
)
else()
if(NOT WINDOWS)
message(FATAL_ERROR "hwloc can be statically linked only on Windows")
Expand Down Expand Up @@ -329,7 +336,11 @@ if(UMF_BUILD_BENCHMARKS)
endif()

if(UMF_BUILD_EXAMPLES)
add_subdirectory(examples)
if(NOT UMF_DISABLE_HWLOC)
add_subdirectory(examples)
else()
message(WARNING "Examples cannot be build - hwloc disabled")
endif()
endif()

# Conditional configuration for Level Zero provider
Expand Down
8 changes: 4 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(EXAMPLE_NAME umf_example_basic)
add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS basic/basic.c
LIBS umf hwloc)
LIBS umf ${LIBHWLOC_LIBRARIES})

target_include_directories(
${EXAMPLE_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
Expand Down Expand Up @@ -172,7 +172,7 @@ if(LINUX)
add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS memspace/memspace_numa.c
LIBS umf hwloc numa)
LIBS umf ${LIBHWLOC_LIBRARIES} numa)

target_include_directories(
${EXAMPLE_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
Expand All @@ -190,7 +190,7 @@ if(LINUX)
add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS memspace/memspace_hmat.c
LIBS umf hwloc numa)
LIBS umf ${LIBHWLOC_LIBRARIES} numa)

target_include_directories(
${EXAMPLE_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
Expand All @@ -209,7 +209,7 @@ if(LINUX)
add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS custom_provider/file_provider.c
LIBS umf hwloc)
LIBS umf ${LIBHWLOC_LIBRARIES})

target_include_directories(
${EXAMPLE_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
Expand Down
43 changes: 32 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ set(BA_SOURCES
${BA_SOURCES}
PARENT_SCOPE)

set(HWLOC_DEPENDENT_SOURCES topology.c)

set(UMF_SOURCES
${BA_SOURCES}
libumf.c
Expand All @@ -74,8 +76,11 @@ set(UMF_SOURCES
provider/provider_tracking.c
critnib/critnib.c
pool/pool_proxy.c
pool/pool_scalable.c
topology.c)
pool/pool_scalable.c)

if(NOT UMF_DISABLE_HWLOC)
set(UMF_SOURCES ${UMF_SOURCES} ${HWLOC_DEPENDENT_SOURCES})
endif()

set(UMF_SOURCES_LINUX libumf_linux.c)

Expand All @@ -93,16 +98,22 @@ set(UMF_SOURCES_COMMON_LINUX_MACOSX
memspaces/memspace_highest_bandwidth.c
memspaces/memspace_lowest_latency.c)

set(UMF_SOURCES_LINUX ${UMF_SOURCES_LINUX} ${UMF_SOURCES_COMMON_LINUX_MACOSX}
provider/provider_os_memory_linux.c)
if(NOT UMF_DISABLE_HWLOC)
set(UMF_SOURCES_LINUX
${UMF_SOURCES_LINUX} ${UMF_SOURCES_COMMON_LINUX_MACOSX}
provider/provider_os_memory_linux.c)

set(UMF_SOURCES_MACOSX ${UMF_SOURCES_MACOSX} ${UMF_SOURCES_COMMON_LINUX_MACOSX}
provider/provider_os_memory_macosx.c)
set(UMF_SOURCES_MACOSX
${UMF_SOURCES_MACOSX} ${UMF_SOURCES_COMMON_LINUX_MACOSX}
provider/provider_os_memory_macosx.c)

set(UMF_SOURCES_WINDOWS ${UMF_SOURCES_WINDOWS} provider/provider_os_memory.c
provider/provider_os_memory_windows.c)
set(UMF_SOURCES_WINDOWS
${UMF_SOURCES_WINDOWS} provider/provider_os_memory.c
provider/provider_os_memory_windows.c)

set(UMF_LIBS ${UMF_LIBS} ${LIBHWLOC_LIBRARIES})
endif()

set(UMF_LIBS ${UMF_LIBS} ${LIBHWLOC_LIBRARIES})
set(UMF_PRIVATE_LIBRARY_DIRS ${UMF_PRIVATE_LIBRARY_DIRS}
${LIBHWLOC_LIBRARY_DIRS})

Expand All @@ -121,11 +132,14 @@ elseif(MACOSX)
endif()

if(UMF_BUILD_SHARED_LIBRARY)
if(NOT UMF_DISABLE_HWLOC)
set(HWLOC_LIB hwloc)
endif()
add_umf_library(
NAME umf
TYPE SHARED
SRCS ${UMF_SOURCES}
LIBS ${UMF_LIBS} hwloc
LIBS ${UMF_LIBS} ${HWLOC_LIB}
LINUX_MAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libumf.map
WINDOWS_DEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/libumf.def)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
Expand All @@ -143,6 +157,11 @@ else()
LIBS ${UMF_LIBS})
endif()

if(UMF_DISABLE_HWLOC)
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
UMF_NO_HWLOC=1)
endif()

if(UMF_LINK_HWLOC_STATICALLY)
add_dependencies(umf hwloc)
endif()
Expand Down Expand Up @@ -190,6 +209,8 @@ install(TARGETS umf EXPORT ${PROJECT_NAME}-targets)

add_subdirectory(pool)

if(UMF_PROXY_LIB_ENABLED AND NOT UMF_LINK_HWLOC_STATICALLY)
if(UMF_PROXY_LIB_ENABLED
AND NOT UMF_LINK_HWLOC_STATICALLY
AND NOT UMF_DISABLE_HWLOC)
add_subdirectory(proxy_lib)
endif()
6 changes: 4 additions & 2 deletions src/libumf.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#include "base_alloc_global.h"
#include "memspace_internal.h"
#include "provider_tracking.h"
#include "topology.h"
#include "utils_log.h"
#if !defined(UMF_NO_HWLOC)
#include "topology.h"
#endif

umf_memory_tracker_handle_t TRACKER = NULL;

Expand All @@ -30,7 +32,7 @@ int umfInit(void) {

void umfTearDown(void) {
if (util_fetch_and_add64(&umfRefCount, -1) == 1) {
#ifndef _WIN32
#if !defined(_WIN32) && !defined(UMF_NO_HWLOC)
umfMemspaceHostAllDestroy();
umfMemspaceHighestCapacityDestroy();
umfMemspaceHighestBandwidthDestroy();
Expand Down
68 changes: 39 additions & 29 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,29 @@ endif()

if(UMF_BUILD_LIBUMF_POOL_DISJOINT
AND UMF_BUILD_LIBUMF_POOL_JEMALLOC
AND UMF_POOL_SCALABLE_ENABLED)
AND UMF_POOL_SCALABLE_ENABLED
AND (NOT UMF_DISABLE_HWLOC))
add_umf_test(
NAME c_api_multi_pool
SRCS c_api/multi_pool.c
LIBS disjoint_pool jemalloc_pool ${JEMALLOC_LIBRARIES})
endif()

if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (NOT UMF_DISABLE_HWLOC))
add_umf_test(
NAME jemalloc_pool
SRCS pools/jemalloc_pool.cpp malloc_compliance_tests.cpp
LIBS jemalloc_pool)
endif()

if(UMF_POOL_SCALABLE_ENABLED)
if(UMF_POOL_SCALABLE_ENABLED AND (NOT UMF_DISABLE_HWLOC))
add_umf_test(NAME scalable_pool SRCS pools/scalable_pool.cpp
malloc_compliance_tests.cpp)
endif()

if(LINUX) # OS-specific functions are implemented only for Linux now
if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented
# only for
# Linux now
if(PkgConfig_FOUND)
pkg_check_modules(LIBNUMA numa)
endif()
Expand Down Expand Up @@ -266,7 +269,9 @@ add_umf_test(
LIBS ${UMF_UTILS_FOR_TEST})

# tests for the proxy library
if(UMF_PROXY_LIB_ENABLED AND UMF_BUILD_SHARED_LIBRARY)
if(UMF_PROXY_LIB_ENABLED
AND UMF_BUILD_SHARED_LIBRARY
AND NOT UMF_DISABLE_HWLOC)
add_umf_test(
NAME proxy_lib_basic
SRCS ${BA_SOURCES_FOR_TEST} test_proxy_lib.cpp
Expand Down Expand Up @@ -317,22 +322,24 @@ function(add_umf_ipc_test)
endfunction()

if(LINUX)
build_umf_test(
NAME
ipc_os_prov_consumer
SRCS
ipc_os_prov_consumer.c
common/ipc_common.c
common/ipc_os_prov_common.c)
build_umf_test(
NAME
ipc_os_prov_producer
SRCS
ipc_os_prov_producer.c
common/ipc_common.c
common/ipc_os_prov_common.c)
add_umf_ipc_test(TEST ipc_os_prov_anon_fd)
add_umf_ipc_test(TEST ipc_os_prov_shm)
if(NOT UMF_DISABLE_HWLOC)
build_umf_test(
NAME
ipc_os_prov_consumer
SRCS
ipc_os_prov_consumer.c
common/ipc_common.c
common/ipc_os_prov_common.c)
build_umf_test(
NAME
ipc_os_prov_producer
SRCS
ipc_os_prov_producer.c
common/ipc_common.c
common/ipc_os_prov_common.c)
add_umf_ipc_test(TEST ipc_os_prov_anon_fd)
add_umf_ipc_test(TEST ipc_os_prov_shm)
endif()
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
build_umf_test(
NAME
Expand Down Expand Up @@ -368,7 +375,8 @@ endif()

if(LINUX
AND UMF_BUILD_SHARED_LIBRARY
AND UMF_POOL_SCALABLE_ENABLED)
AND UMF_POOL_SCALABLE_ENABLED
AND NOT UMF_DISABLE_HWLOC)
add_umf_test(
NAME init_teardown
SRCS test_init_teardown.c
Expand Down Expand Up @@ -431,11 +439,13 @@ if(LINUX
)
endif()

add_test(
NAME umf_standalone_examples
COMMAND
${UMF_CMAKE_SOURCE_DIR}/test/test_examples.sh
${UMF_CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_INSTALL_PREFIX}
${EXAMPLES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(NOT UMF_DISABLE_HWLOC)
add_test(
NAME umf_standalone_examples
COMMAND
${UMF_CMAKE_SOURCE_DIR}/test/test_examples.sh
${UMF_CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
${CMAKE_INSTALL_PREFIX} ${EXAMPLES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()
Loading