Skip to content

Commit 1a033d4

Browse files
committed
Test FetchContent of UMF on Linux and Windows in Nightly
Test FetchContent of UMF on Linux and Windows in Nightly CI job - on Windows with the 'Ninja' and 'NMake Makefiles' generators. Add the fetch_content example based on the basic example. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent c88938a commit 1a033d4

File tree

4 files changed

+163
-2
lines changed

4 files changed

+163
-2
lines changed

.github/workflows/nightly.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,30 @@ jobs:
201201
${{ matrix.umfd_lib == 'ON' && '--umfd-lib' || ''}}
202202
${{ matrix.static_hwloc == 'ON' && '--hwloc' || '' }}
203203
204+
- name: Set VCPKG_PATH with hwloc for the fetch_content example
205+
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
206+
207+
- name: Configure the fetch_content example
208+
working-directory: ${{github.workspace}}/examples/fetch_content
209+
# Fetch_Content the UMF code from the current repository (-DUMF_REPO="${{github.workspace}}")
210+
run: >
211+
cmake
212+
-B ${{github.workspace}}/examples/fetch_content/build
213+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
214+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
215+
-DUMF_REPO="${{github.workspace}}"
216+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
217+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
218+
-G "${{matrix.generator}}"
219+
220+
- name: Build the fetch_content example
221+
working-directory: ${{github.workspace}}/examples/fetch_content
222+
run: cmake --build ${{github.workspace}}/examples/fetch_content/build --config ${{matrix.build_type}} -j $env:NUMBER_OF_PROCESSORS
223+
224+
- name: Run the fetch_content example
225+
working-directory: ${{github.workspace}}/examples/fetch_content/build
226+
run: ctest -V
227+
204228
# Build and test UMF with Intel C++ Compiler (ICX) on Windows
205229
Windows-icx:
206230
env:

examples/fetch_content/CMakeLists.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
6+
project(umf_example_fetch_content LANGUAGES C)
7+
enable_testing()
8+
9+
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
10+
set(LINUX TRUE)
11+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
12+
set(WINDOWS TRUE)
13+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
14+
set(MACOSX TRUE)
15+
else()
16+
message(FATAL_ERROR "Unknown OS type")
17+
endif()
18+
19+
set(UMF_EXAMPLE_DIR "${CMAKE_SOURCE_DIR}/..")
20+
list(APPEND CMAKE_MODULE_PATH "${UMF_EXAMPLE_DIR}/cmake")
21+
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
22+
23+
include("fetch_umf.cmake")
24+
25+
find_package(PkgConfig)
26+
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
27+
if(NOT LIBHWLOC_FOUND)
28+
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
29+
endif()
30+
31+
pkg_check_modules(TBB tbb)
32+
if(NOT TBB_FOUND)
33+
find_package(TBB REQUIRED tbb)
34+
endif()
35+
36+
# build the example
37+
set(EXAMPLE_NAME umf_example_fetch_content)
38+
# reusing the basic.c source file from the basic example
39+
add_executable(${EXAMPLE_NAME} ${CMAKE_SOURCE_DIR}/../basic/basic.c)
40+
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS})
41+
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS})
42+
target_link_libraries(${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARIES} hwloc)
43+
44+
# an optional part - adds a test of this example
45+
add_test(
46+
NAME ${EXAMPLE_NAME}
47+
COMMAND ${EXAMPLE_NAME}
48+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
49+
50+
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example-standalone")
51+
52+
if(LINUX)
53+
# set LD_LIBRARY_PATH
54+
set_property(
55+
TEST ${EXAMPLE_NAME}
56+
PROPERTY
57+
ENVIRONMENT_MODIFICATION
58+
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
59+
)
60+
elseif(WINDOWS)
61+
# add PATH to DLL on Windows
62+
set(DLL_PATH_LIST
63+
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_DLL_DIRS};PATH=path_list_append:${TBB_DLL_DIRS}"
64+
)
65+
66+
message(STATUS "DLL_PATH_LIST=${DLL_PATH_LIST}")
67+
68+
# append PATH to DLLs NOTE: this would work only for the CMake ver >= #
69+
# 3.22. For the older versions, the PATH variable should be set in the test
70+
# script)
71+
set_property(TEST ${EXAMPLE_NAME} PROPERTY ENVIRONMENT_MODIFICATION
72+
"${DLL_PATH_LIST}")
73+
endif()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
message(STATUS "Downloading Unified Memory Framework ...")
6+
7+
include(FetchContent)
8+
9+
if(NOT DEFINED UMF_REPO)
10+
set(UMF_REPO "https://github.com/oneapi-src/unified-memory-framework.git")
11+
elseif(WINDOWS)
12+
string(REPLACE "\\" "/" OUT_UMF_REPO "${UMF_REPO}")
13+
message(
14+
STATUS
15+
"Replaced \"${UMF_REPO}\" with \"${OUT_UMF_REPO}\" for Windows compatibility"
16+
)
17+
set(UMF_REPO "${OUT_UMF_REPO}")
18+
endif()
19+
20+
if(NOT DEFINED UMF_TAG)
21+
set(UMF_TAG HEAD)
22+
endif()
23+
24+
message(
25+
STATUS
26+
"Will fetch Unified Memory Framework from ${UMF_REPO} at ${UMF_TAG} ..."
27+
)
28+
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
29+
30+
FetchContent_Declare(
31+
unified-memory-framework
32+
GIT_REPOSITORY ${UMF_REPO}
33+
GIT_TAG ${UMF_TAG})
34+
35+
set(UMF_BUILD_TESTS
36+
OFF
37+
CACHE INTERNAL "Do not build UMF tests")
38+
set(UMF_BUILD_EXAMPLES
39+
OFF
40+
CACHE INTERNAL "Do not build UMF examples")
41+
set(UMF_BUILD_SHARED_LIBRARY
42+
OFF
43+
CACHE INTERNAL "Build UMF shared library")
44+
set(UMF_BUILD_LIBUMF_POOL_DISJOINT
45+
ON
46+
CACHE INTERNAL "Build Disjoint Pool")
47+
set(UMF_BUILD_CUDA_PROVIDER
48+
OFF
49+
CACHE INTERNAL "Do not build CUDA provider")
50+
set(UMF_BUILD_LEVEL_ZERO_PROVIDER
51+
OFF
52+
CACHE INTERNAL "Do not build L0 provider")
53+
set(UMF_DISABLE_HWLOC
54+
OFF
55+
CACHE INTERNAL "Enable HWLOC support")
56+
set(UMF_LINK_HWLOC_STATICALLY
57+
OFF
58+
CACHE INTERNAL "UMF_LINK_HWLOC_STATICALLY=OFF")
59+
60+
FetchContent_MakeAvailable(unified-memory-framework)
61+
FetchContent_GetProperties(unified-memory-framework)
62+
63+
set(LIBUMF_INCLUDE_DIRS ${unified-memory-framework_SOURCE_DIR}/include)
64+
set(LIBUMF_LIBRARIES umf::umf umf::headers)

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,11 @@ if(LINUX
672672
set(EXAMPLES "")
673673

674674
if(UMF_POOL_SCALABLE_ENABLED)
675-
set(EXAMPLES ${EXAMPLES} basic custom_file_provider)
675+
set(EXAMPLES ${EXAMPLES} basic fetch_content custom_file_provider)
676676
else()
677677
message(
678678
STATUS
679-
"The basic and custom_file_provider examples require TBB to be installed and added to the default library search path - skipping"
679+
"The basic, fetch_content and custom_file_provider examples require TBB to be installed and added to the default library search path - skipping"
680680
)
681681
endif()
682682

0 commit comments

Comments
 (0)