Skip to content

Commit 2944f96

Browse files
committed
Fix building umfd.dll on single-config generators
- add installation tests step to Windows generators nightly tests
1 parent 99d5347 commit 2944f96

File tree

3 files changed

+120
-28
lines changed

3 files changed

+120
-28
lines changed

.github/workflows/nightly.yml

+26-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ permissions:
1212

1313
env:
1414
BUILD_DIR : "${{github.workspace}}/build"
15+
INSTALL_DIR: "${{github.workspace}}/build/install"
1516

1617
jobs:
1718
fuzz-test:
@@ -96,11 +97,12 @@ jobs:
9697
strategy:
9798
matrix:
9899
os: ['windows-2019', 'windows-2022']
99-
build_type: [Release]
100+
build_type: [Debug, Release]
100101
compiler: [{c: cl, cxx: cl}]
101102
shared_library: ['ON', 'OFF']
102103
static_hwloc: ['ON', 'OFF']
103104
generator: ['Ninja', 'NMake Makefiles']
105+
umfd_lib: ['ON', 'OFF']
104106

105107
runs-on: ${{matrix.os}}
106108

@@ -112,11 +114,11 @@ jobs:
112114

113115
- name: Set VCPKG_PATH with hwloc
114116
if: matrix.static_hwloc == 'OFF'
115-
run: echo "VCPKG_PATH='${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows'" >> $env:GITHUB_ENV
117+
run: echo "VCPKG_PATH=${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows" >> $env:GITHUB_ENV
116118

117119
- name: Set VCPKG_PATH without hwloc
118120
if: matrix.static_hwloc == 'ON'
119-
run: echo "VCPKG_PATH='${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows'" >> $env:GITHUB_ENV
121+
run: echo "VCPKG_PATH=${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows" >> $env:GITHUB_ENV
120122

121123
- name: Initialize vcpkg
122124
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
@@ -141,6 +143,7 @@ jobs:
141143
run: >
142144
cmake
143145
-B ${{env.BUILD_DIR}}
146+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
144147
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
145148
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
146149
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
@@ -153,6 +156,7 @@ jobs:
153156
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
154157
-DUMF_BUILD_CUDA_PROVIDER=ON
155158
-DUMF_TESTS_FAIL_ON_SKIP=ON
159+
${{ matrix.umfd_lib == 'ON' && '-DUMF_USE_DEBUG_POSTFIX=ON' || '' }}
156160
157161
- name: Build UMF
158162
shell: cmd
@@ -163,6 +167,25 @@ jobs:
163167
working-directory: ${{env.BUILD_DIR}}
164168
run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test
165169

170+
- name: Get UMF version
171+
run: |
172+
$version = (git describe --tags --abbrev=0 | Select-String -Pattern '\d+\.\d+\.\d+').Matches.Value
173+
echo "UMF_VERSION=$version" >> $env:GITHUB_ENV
174+
shell: pwsh
175+
176+
- name: Test UMF installation and uninstallation
177+
# The '--shared-library' parameter is added to the installation test when the UMF is built as a shared library
178+
# The '--umfd-lib' parameter is added when the UMF is built with the umfd library
179+
run: >
180+
python3 ${{github.workspace}}/test/test_installation.py
181+
--build-dir ${{env.BUILD_DIR}}
182+
--install-dir ${{env.INSTALL_DIR}}
183+
--build-type ${{matrix.build_type}}
184+
--umf-version ${{env.UMF_VERSION}}
185+
${{ matrix.shared_library == 'ON' && '--proxy --shared-library' || '' }}
186+
${{ matrix.umfd_lib == 'ON' && '--umfd-lib' || ''}}
187+
${{ matrix.static_hwloc == 'ON' && '--hwloc' || '' }}
188+
166189
icx:
167190
name: ICX
168191
env:

CMakeLists.txt

+78-20
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ macro(umf_option)
5858
option(${ARGV})
5959
endmacro()
6060

61+
# All CMake options have to be explicitly set in the build_umfd target's
62+
# configuration command
6163
umf_option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF)
6264
umf_option(UMF_BUILD_LEVEL_ZERO_PROVIDER "Build Level Zero memory provider" ON)
6365
umf_option(UMF_BUILD_CUDA_PROVIDER "Build CUDA memory provider" ON)
@@ -148,6 +150,8 @@ if(UMF_DEVELOPER_MODE)
148150
UMF_DEVELOPER_MODE=1)
149151
endif()
150152

153+
message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
154+
151155
if(NOT UMF_BUILD_LIBUMF_POOL_JEMALLOC)
152156
set(UMF_POOL_JEMALLOC_ENABLED FALSE)
153157
set(JEMALLOC_FOUND FALSE)
@@ -285,6 +289,7 @@ else()
285289
set(HWLOC_ENABLE_TESTING OFF)
286290
set(HWLOC_SKIP_LSTOPO ON)
287291
set(HWLOC_SKIP_TOOLS ON)
292+
set(HWLOC_SKIP_INCLUDES ON)
288293

289294
FetchContent_Declare(
290295
hwloc_targ
@@ -428,25 +433,72 @@ elseif(UMF_BUILD_CUDA_PROVIDER)
428433
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
429434
endif()
430435

436+
# Build the umfd target in a separate directory with Debug configuration
431437
if(WINDOWS AND UMF_USE_DEBUG_POSTFIX)
432-
# Build debug umf library with the d suffix that is compiled with /MDd so
433-
# users can link against it in debug builds.
434-
set(CMAKE_DEBUG_POSTFIX d)
435-
438+
# The build_umfd target's configuration command requires to have
439+
# CMAKE_PREFIX_PATH with semicolons escaped
440+
string(JOIN "\;" UMFD_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
436441
add_custom_target(
437-
umfd ALL
438-
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target umf
439-
--config Debug
440-
COMMENT "Building debug umf library with the d suffix")
442+
build_umfd ALL
443+
COMMAND
444+
${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -S ${UMF_CMAKE_SOURCE_DIR}
445+
-B ${CMAKE_BINARY_DIR}/umfd_build -DCMAKE_BUILD_TYPE=Debug
446+
-DCMAKE_DEBUG_POSTFIX=d
447+
-DCMAKE_PREFIX_PATH="${UMFD_CMAKE_PREFIX_PATH}"
448+
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
449+
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
450+
-DUMF_USE_DEBUG_POSTFIX=OFF
451+
-DUMF_BUILD_SHARED_LIBRARY=${UMF_BUILD_SHARED_LIBRARY}
452+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=${UMF_BUILD_LEVEL_ZERO_PROVIDER}
453+
-DUMF_BUILD_CUDA_PROVIDER=${UMF_BUILD_CUDA_PROVIDER}
454+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=${UMF_BUILD_LIBUMF_POOL_JEMALLOC}
455+
-DUMF_BUILD_TESTS=OFF -DUMF_BUILD_GPU_TESTS=OFF
456+
-DUMF_BUILD_BENCHMARKS=OFF -DUMF_BUILD_BENCHMARKS_MT=OFF
457+
-DUMF_BUILD_EXAMPLES=OFF -DUMF_BUILD_GPU_EXAMPLES=OFF
458+
-DUMF_BUILD_FUZZTESTS=OFF -DUMF_DISABLE_HWLOC=${UMF_DISABLE_HWLOC}
459+
-DUMF_LINK_HWLOC_STATICALLY=${UMF_LINK_HWLOC_STATICALLY}
460+
-DUMF_HWLOC_NAME=${UMF_HWLOC_NAME}
461+
-DUMF_INSTALL_RPATH=${UMF_INSTALL_RPATH} -DUMF_DEVELOPER_MODE=OFF
462+
-DUMF_FORMAT_CODE_STYLE=OFF -DUMF_TESTS_FAIL_ON_SKIP=OFF
463+
-DUMF_USE_ASAN=OFF -DUMF_USE_UBSAN=OFF -DUMF_USE_TSAN=OFF
464+
-DUMF_USE_MSAN=OFF -DUMF_USE_VALGRIND=OFF -DUMF_USE_COVERAGE=OFF
465+
-DUMF_PROXY_LIB_BASED_ON_POOL=${UMF_PROXY_LIB_BASED_ON_POOL}
466+
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/umfd_build --target
467+
umf --config Debug
468+
COMMENT
469+
"Configuring and building umfd.dll in a separate directory with Debug configuration"
470+
)
441471

442-
# Copy built UMF libraries to the Release build subdirectory
472+
# Copy built UMF libraries to the main binary directory and remove
473+
# umfd_build
474+
if(CMAKE_CONFIGURATION_TYPES)
475+
# Multi-config generator (e.g., Visual Studio)
476+
set(UMFD_DLL_SRC "${CMAKE_BINARY_DIR}/umfd_build/bin/Debug/umfd.dll")
477+
set(UMFD_LIB_SRC "${CMAKE_BINARY_DIR}/umfd_build/lib/Debug/umfd.lib")
478+
set(UMFD_DLL "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/umfd.dll")
479+
set(UMFD_LIB "${CMAKE_BINARY_DIR}/lib/$<CONFIG>/umfd.lib")
480+
else()
481+
# Single-config generator (e.g., Ninja)
482+
set(UMFD_DLL_SRC "${CMAKE_BINARY_DIR}/umfd_build/bin/umfd.dll")
483+
set(UMFD_LIB_SRC "${CMAKE_BINARY_DIR}/umfd_build/lib/umfd.lib")
484+
set(UMFD_DLL "${CMAKE_BINARY_DIR}/bin/umfd.dll")
485+
set(UMFD_LIB "${CMAKE_BINARY_DIR}/lib/umfd.lib")
486+
endif()
487+
488+
if(UMF_BUILD_SHARED_LIBRARY)
489+
add_custom_command(
490+
TARGET build_umfd
491+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${UMFD_DLL_SRC}
492+
${UMFD_DLL}
493+
COMMENT "Copying umfd.dll to the main binary directory")
494+
endif()
443495
add_custom_command(
444-
TARGET umfd
445-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/Debug/umfd.dll
446-
${CMAKE_BINARY_DIR}/bin/Release/umfd.dll
447-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/Debug/umfd.lib
448-
${CMAKE_BINARY_DIR}/lib/Release/umfd.lib
449-
COMMENT "Copying debug libraries to the Release build directory")
496+
TARGET build_umfd
497+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${UMFD_LIB_SRC}
498+
${UMFD_LIB}
499+
COMMAND ${CMAKE_COMMAND} -E remove_directory
500+
${CMAKE_BINARY_DIR}/umfd_build DEPENDS ${UMFD_DLL}
501+
COMMENT "Copying umfd.lib to the main library directory")
450502
endif()
451503

452504
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
@@ -841,12 +893,18 @@ endif()
841893
# --------------------------------------------------------------------------- #
842894
# Configure make install/uninstall and packages
843895
# --------------------------------------------------------------------------- #
844-
# Install umfd target
896+
# Install the umfd library files as part of the umfd component
845897
if(WINDOWS AND UMF_USE_DEBUG_POSTFIX)
846-
install(FILES ${CMAKE_BINARY_DIR}/bin/Debug/umfd.dll
847-
DESTINATION ${CMAKE_INSTALL_BINDIR})
848-
install(FILES ${CMAKE_BINARY_DIR}/lib/Debug/umfd.lib
849-
DESTINATION ${CMAKE_INSTALL_LIBDIR})
898+
if(UMF_BUILD_SHARED_LIBRARY)
899+
install(
900+
FILES ${UMFD_DLL}
901+
DESTINATION ${CMAKE_INSTALL_BINDIR}
902+
COMPONENT umfd)
903+
endif()
904+
install(
905+
FILES ${UMFD_LIB}
906+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
907+
COMPONENT umfd)
850908
endif()
851909

852910
install(FILES ${PROJECT_SOURCE_DIR}/LICENSE.TXT

test/test_installation.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class UmfInstaller:
2828
proxy (bool): Determines whether the proxy library should be built together with the UMF library
2929
pools (List[str]): A list of enabled pools during the UMF compilation
3030
umf_version (Version): UMF version currently being built and installed
31-
match_list (List[str]): A list of relative paths of files that should be installed
31+
umfd_lib (bool): Determines if the UMF was built with the umfd library
32+
hwloc (bool): Determines if hwloc is installed and should be checked
3233
"""
3334

3435
def __init__(
@@ -42,6 +43,7 @@ def __init__(
4243
pools: List[str],
4344
umf_version: Version,
4445
umfd_lib: bool,
46+
hwloc: bool,
4547
):
4648
self.workspace_dir = workspace_dir
4749
self.build_dir = build_dir
@@ -52,6 +54,7 @@ def __init__(
5254
self.pools = pools
5355
self.umf_version = umf_version
5456
self.umfd_lib = umfd_lib
57+
self.hwloc = hwloc
5558
self.match_list = self._create_match_list()
5659

5760
def _create_match_list(self) -> List[str]:
@@ -76,9 +79,7 @@ def _create_match_list(self) -> List[str]:
7679
lib_prefix = "lib"
7780

7881
bin = []
79-
if platform.system() == "Windows" and (
80-
self.shared_library or self.proxy or self.umfd_lib
81-
):
82+
if platform.system() == "Windows" and (self.shared_library or self.proxy):
8283
bin.append("bin")
8384
if self.shared_library:
8485
bin.append("bin/umf.dll")
@@ -103,8 +104,11 @@ def _create_match_list(self) -> List[str]:
103104
f"lib/cmake/umf/umf-targets-{self.build_type}.cmake",
104105
"lib/cmake/umf/umf-targets.cmake",
105106
]
107+
106108
for pool in self.pools:
107109
lib.append(f"lib/{lib_prefix}{pool}.{lib_ext_static}")
110+
if platform.system() == "Windows" and self.hwloc:
111+
lib.append(f"lib/{lib_prefix}hwloc.{lib_ext_static}")
108112
if self.shared_library:
109113
lib.append(f"lib/{lib_prefix}umf.{lib_ext_shared}")
110114
if platform.system() == "Windows" and self.umfd_lib:
@@ -122,6 +126,8 @@ def _create_match_list(self) -> List[str]:
122126
lib.append(f"lib/{lib_prefix}umf.{self.umf_version}.{lib_ext_shared}")
123127
else:
124128
lib.append(f"lib/{lib_prefix}umf.{lib_ext_static}")
129+
if self.umfd_lib and platform.system() == "Windows":
130+
lib.append(f"lib/{lib_prefix}umfd.{lib_ext_static}")
125131

126132
if self.proxy:
127133
lib.append(f"lib/{lib_prefix}umf_proxy.{lib_ext_shared}")
@@ -135,7 +141,6 @@ def _create_match_list(self) -> List[str]:
135141
f"lib/{lib_prefix}umf_proxy.{self.umf_version.major}.{lib_ext_shared}"
136142
)
137143

138-
share = []
139144
share = [
140145
"share",
141146
"share/doc",
@@ -296,6 +301,11 @@ def parse_arguments(self) -> argparse.Namespace:
296301
action="store_true",
297302
help="Add this argument if the UMF was built with the umfd library",
298303
)
304+
self.parser.add_argument(
305+
"--hwloc",
306+
action="store_true",
307+
help="Add this argument if hwloc is installed and should be checked",
308+
)
299309
return self.parser.parse_args()
300310

301311
def run(self) -> None:
@@ -320,6 +330,7 @@ def run(self) -> None:
320330
pools,
321331
umf_version,
322332
self.args.umfd_lib,
333+
self.args.hwloc,
323334
)
324335

325336
print("Installation test - BEGIN", flush=True)

0 commit comments

Comments
 (0)