Skip to content

Commit 4133278

Browse files
authored
Merge pull request #652 from bratpiorka/rrudnick_0.9x_rc2
commits for 0.9x rc2
2 parents 246f051 + 19a5bf5 commit 4133278

20 files changed

+344
-117
lines changed

.github/workflows/basic.yml

+19-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
shared_library: ['OFF']
2424
level_zero_provider: ['ON']
2525
install_tbb: ['ON']
26+
disable_hwloc: ['OFF']
27+
link_hwloc_statically: ['OFF']
2628
include:
2729
- os: 'ubuntu-20.04'
2830
build_type: Release
@@ -69,6 +71,20 @@ jobs:
6971
shared_library: 'ON'
7072
level_zero_provider: 'ON'
7173
install_tbb: 'OFF'
74+
- os: 'ubuntu-22.04'
75+
build_type: Debug
76+
compiler: {c: gcc, cxx: g++}
77+
shared_library: 'ON'
78+
level_zero_provider: 'ON'
79+
install_tbb: 'ON'
80+
disable_hwloc: 'ON'
81+
- os: 'ubuntu-22.04'
82+
build_type: Release
83+
compiler: {c: gcc, cxx: g++}
84+
shared_library: 'ON'
85+
level_zero_provider: 'ON'
86+
install_tbb: 'ON'
87+
link_hwloc_statically: 'ON'
7288
runs-on: ${{matrix.os}}
7389

7490
steps:
@@ -122,6 +138,8 @@ jobs:
122138
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
123139
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
124140
-DUMF_TESTS_FAIL_ON_SKIP=ON
141+
-DUMF_DISABLE_HWLOC=${{matrix.disable_hwloc}}
142+
-DUMF_LINK_HWLOC_STATICALLY=${{matrix.link_hwloc_statically}}
125143
126144
- name: Build UMF
127145
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -144,7 +162,7 @@ jobs:
144162
--build-type ${{matrix.build_type}}
145163
--disjoint-pool
146164
--jemalloc-pool
147-
${{ matrix.install_tbb == 'ON' && '--proxy' || '' }}
165+
${{ matrix.install_tbb == 'ON' && matrix.disable_hwloc != 'ON' && matrix.link_hwloc_statically != 'ON' && '--proxy' || '' }}
148166
--umf-version ${{env.UMF_VERSION}}
149167
${{ matrix.shared_library == 'ON' && '--shared-library' || '' }}
150168

.github/workflows/sanitizers.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ jobs:
7272
working-directory: ${{env.BUILD_DIR}}
7373
run: >
7474
${{ matrix.compiler.cxx == 'icpx' && '. /opt/intel/oneapi/setvars.sh &&' || ''}}
75-
GTEST_FILTER="-*umfProviderTest.alloc_page64_align_0*" ctest --output-on-failure
76-
# TO DO: fix umf-provider_os_memory test for sanitizers
77-
# issue 581: https://github.com/oneapi-src/unified-memory-framework/issues/581
75+
ctest --output-on-failure
7876
7977
windows-build:
8078
name: cl and clang-cl on Windows

CMakeLists.txt

+105-25
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
77
set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
88

99
list(APPEND CMAKE_MODULE_PATH "${UMF_CMAKE_SOURCE_DIR}/cmake")
10-
include(helpers)
10+
# Use full path of the helpers module (to omit potential conflicts with others)
11+
include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)
1112

1213
# We use semver aligned version, set via git tags. We parse git output to
1314
# establih the version of UMF to be used in CMake, Win dll's, and within the
@@ -47,8 +48,10 @@ option(UMF_BUILD_EXAMPLES "Build UMF examples" ON)
4748
option(UMF_BUILD_FUZZTESTS "Build UMF fuzz tests" OFF)
4849
option(UMF_BUILD_GPU_EXAMPLES "Build UMF GPU examples" OFF)
4950
option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF)
50-
option(UMF_LINK_HWLOC_STATICALLY
51-
"Link UMF with HWLOC library statically (Windows+Release only)" OFF)
51+
option(
52+
UMF_LINK_HWLOC_STATICALLY
53+
"Link UMF with HWLOC library statically (supported for Linux, MacOS and Release build on Windows)"
54+
OFF)
5255
option(UMF_FORMAT_CODE_STYLE
5356
"Add clang, cmake, and black -format-check and -format-apply targets"
5457
OFF)
@@ -60,6 +63,10 @@ option(USE_TSAN "Enable ThreadSanitizer checks" OFF)
6063
option(USE_MSAN "Enable MemorySanitizer checks" OFF)
6164
option(USE_VALGRIND "Enable Valgrind instrumentation" OFF)
6265
option(USE_GCOV "Enable gcov support" OFF)
66+
option(
67+
UMF_DISABLE_HWLOC
68+
"Disable features that requires hwloc (OS provider, memory targets, topolgy discovery)"
69+
OFF)
6370

6471
# set UMF_PROXY_LIB_BASED_ON_POOL to one of: SCALABLE or JEMALLOC
6572
set(KNOWN_PROXY_LIB_POOLS SCALABLE JEMALLOC)
@@ -93,27 +100,42 @@ else()
93100
message(FATAL_ERROR "Unknown OS type")
94101
endif()
95102

103+
if(NOT DEFINED UMF_HWLOC_REPO)
104+
set(UMF_HWLOC_REPO "https://github.com/open-mpi/hwloc.git")
105+
endif()
106+
107+
if(NOT DEFINED UMF_HWLOC_TAG)
108+
set(UMF_HWLOC_TAG hwloc-2.10.0)
109+
endif()
110+
96111
if(NOT UMF_LINK_HWLOC_STATICALLY)
97-
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
98-
if(NOT LIBHWLOC_FOUND)
99-
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
112+
if(NOT UMF_DISABLE_HWLOC)
113+
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
114+
if(NOT LIBHWLOC_FOUND)
115+
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
116+
endif()
117+
118+
# add PATH to DLL on Windows
119+
set(DLL_PATH_LIST
120+
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin"
121+
)
100122
endif()
101123
# add PATH to DLL on Windows
102124
set(DLL_PATH_LIST
103125
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin"
104126
)
105-
else()
106-
if(NOT WINDOWS)
107-
message(FATAL_ERROR "hwloc can be statically linked only on Windows")
108-
endif()
127+
elseif(WINDOWS AND NOT UMF_DISABLE_HWLOC)
109128
include(FetchContent)
110129
set(HWLOC_ENABLE_TESTING OFF)
111130
set(HWLOC_SKIP_LSTOPO ON)
112131
set(HWLOC_SKIP_TOOLS ON)
132+
133+
message(STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO}")
134+
113135
FetchContent_Declare(
114136
hwloc_targ
115-
GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
116-
GIT_TAG hwloc-2.10.0
137+
GIT_REPOSITORY ${UMF_HWLOC_REPO}
138+
GIT_TAG ${UMF_HWLOC_TAG}
117139
SOURCE_SUBDIR contrib/windows-cmake/ FIND_PACKAGE_ARGS)
118140

119141
FetchContent_GetProperties(hwloc_targ)
@@ -126,6 +148,57 @@ else()
126148
set(LIBHWLOC_LIBRARY_DIRS
127149
${hwloc_targ_BINARY_DIR}/Release;${hwloc_targ_BINARY_DIR}/Debug)
128150

151+
message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}")
152+
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}")
153+
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
154+
elseif(NOT UMF_DISABLE_HWLOC)
155+
include(FetchContent)
156+
message(STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO}")
157+
158+
FetchContent_Declare(
159+
hwloc_targ
160+
GIT_REPOSITORY ${UMF_HWLOC_REPO}
161+
GIT_TAG ${UMF_HWLOC_TAG})
162+
163+
FetchContent_GetProperties(hwloc_targ)
164+
if(NOT hwloc_targ_POPULATED)
165+
FetchContent_MakeAvailable(hwloc_targ)
166+
endif()
167+
168+
add_custom_command(
169+
COMMAND ./autogen.sh
170+
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
171+
OUTPUT ${hwloc_targ_SOURCE_DIR}/configure)
172+
add_custom_command(
173+
COMMAND
174+
./configure --prefix=${hwloc_targ_BINARY_DIR} --enable-static=yes
175+
--enable-shared=no --disable-libxml2 --disable-levelzero
176+
CFLAGS=-fPIC CXXFLAGS=-fPIC
177+
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
178+
OUTPUT ${hwloc_targ_SOURCE_DIR}/Makefile
179+
DEPENDS ${hwloc_targ_SOURCE_DIR}/configure)
180+
add_custom_command(
181+
COMMAND make
182+
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
183+
OUTPUT ${hwloc_targ_SOURCE_DIR}/lib/libhwloc.la
184+
DEPENDS ${hwloc_targ_SOURCE_DIR}/Makefile)
185+
add_custom_command(
186+
COMMAND make install
187+
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
188+
OUTPUT ${hwloc_targ_BINARY_DIR}/lib/libhwloc.a
189+
DEPENDS ${hwloc_targ_SOURCE_DIR}/lib/libhwloc.la)
190+
191+
add_custom_target(hwloc_prod
192+
DEPENDS ${hwloc_targ_BINARY_DIR}/lib/libhwloc.a)
193+
add_library(hwloc INTERFACE)
194+
target_link_libraries(hwloc
195+
INTERFACE ${hwloc_targ_BINARY_DIR}/lib/libhwloc.a)
196+
add_dependencies(hwloc hwloc_prod)
197+
198+
set(LIBHWLOC_LIBRARY_DIRS ${hwloc_targ_BINARY_DIR}/lib)
199+
set(LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_BINARY_DIR}/include)
200+
set(LIBHWLOC_LIBRARIES ${hwloc_targ_BINARY_DIR}/lib/libhwloc.a)
201+
129202
message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}")
130203
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}")
131204
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
@@ -317,6 +390,18 @@ else()
317390
)
318391
endif()
319392

393+
set(UMF_OPTIONAL_SYMBOLS_LINUX "")
394+
set(UMF_OPTIONAL_SYMBOLS_WINDOWS "")
395+
396+
# Conditional configuration for Level Zero provider
397+
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
398+
add_optional_symbol(umfLevelZeroMemoryProviderOps)
399+
endif()
400+
401+
if(NOT UMF_DISABLE_HWLOC)
402+
add_optional_symbol(umfOsMemoryProviderOps)
403+
endif()
404+
320405
add_subdirectory(src)
321406

322407
if(UMF_BUILD_TESTS)
@@ -328,20 +413,13 @@ if(UMF_BUILD_BENCHMARKS)
328413
endif()
329414

330415
if(UMF_BUILD_EXAMPLES)
331-
add_subdirectory(examples)
332-
endif()
333-
334-
# Conditional configuration for Level Zero provider
335-
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
336-
set(OPTIONAL_SYMBOLS "umfLevelZeroMemoryProviderOps")
337-
else()
338-
set(OPTIONAL_SYMBOLS "")
416+
if(NOT UMF_DISABLE_HWLOC)
417+
add_subdirectory(examples)
418+
else()
419+
message(WARNING "Examples cannot be build - hwloc disabled")
420+
endif()
339421
endif()
340422

341-
# Configure the DEF file based on whether Level Zero provider is built
342-
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/libumf.def.in"
343-
"${CMAKE_CURRENT_BINARY_DIR}/src/libumf.def" @ONLY)
344-
345423
if(UMF_FORMAT_CODE_STYLE)
346424
find_program(CLANG_FORMAT NAMES clang-format-15 clang-format-15.0
347425
clang-format)
@@ -522,8 +600,10 @@ endif()
522600
# Configure make install/uninstall and packages
523601
# --------------------------------------------------------------------------- #
524602
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE.TXT
525-
${CMAKE_SOURCE_DIR}/third-party-programs.txt
526603
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/")
604+
install(
605+
FILES ${CMAKE_SOURCE_DIR}/licensing/third-party-programs.txt
606+
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/licensing/")
527607

528608
install(DIRECTORY examples DESTINATION "${CMAKE_INSTALL_DOCDIR}")
529609

cmake/helpers.cmake

+29-2
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,33 @@ function(get_program_version_major_minor name ret)
176176
PARENT_SCOPE)
177177
endfunction()
178178

179+
# Checks compiler for given ${flag}, stores the output in C_HAS_${flag} and
180+
# CXX_HAS_${flag} (if compiler supports C++)
181+
function(check_compilers_flag flag)
182+
check_c_compiler_flag("${flag}" "C_HAS_${flag}")
183+
if(CMAKE_CXX_COMPILE_FEATURES)
184+
check_cxx_compiler_flag("${flag}" "CXX_HAS_${flag}")
185+
endif()
186+
endfunction()
187+
188+
function(check_add_target_compile_options target)
189+
foreach(option ${ARGN})
190+
check_compilers_flag(${option})
191+
if(C_HAS_${option} AND CXX_HAS_${option})
192+
target_compile_options(${target} PRIVATE ${option})
193+
endif()
194+
endforeach()
195+
endfunction()
196+
179197
function(add_umf_target_compile_options name)
198+
check_add_target_compile_options(${name} "-Wno-covered-switch-default")
199+
180200
if(NOT MSVC)
181201
target_compile_options(
182202
${name}
183203
PRIVATE -fPIC
184204
-Wall
185205
-Wextra
186-
-Werror
187206
-Wpedantic
188207
-Wempty-body
189208
-Wunused-parameter
@@ -213,7 +232,6 @@ function(add_umf_target_compile_options name)
213232
/analyze
214233
/DYNAMICBASE
215234
/W4
216-
/WX
217235
/Gy
218236
/GS
219237
# disable warning 6326: Potential comparison of a constant
@@ -399,3 +417,12 @@ macro(add_sanitizer_flag flag)
399417

400418
set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
401419
endmacro()
420+
421+
function(add_optional_symbol symbol)
422+
set(UMF_OPTIONAL_SYMBOLS_WINDOWS
423+
"${UMF_OPTIONAL_SYMBOLS_WINDOWS} \n ${symbol}"
424+
PARENT_SCOPE)
425+
set(UMF_OPTIONAL_SYMBOLS_LINUX
426+
"${UMF_OPTIONAL_SYMBOLS_LINUX} \n ${symbol};"
427+
PARENT_SCOPE)
428+
endfunction()

examples/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set(EXAMPLE_NAME umf_example_basic)
1818
add_umf_executable(
1919
NAME ${EXAMPLE_NAME}
2020
SRCS basic/basic.c
21-
LIBS umf hwloc)
21+
LIBS umf ${LIBHWLOC_LIBRARIES})
2222

2323
target_include_directories(
2424
${EXAMPLE_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
File renamed without changes.

0 commit comments

Comments
 (0)