Skip to content

Commit b28de77

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 b02c3c5 commit b28de77

File tree

3 files changed

+174
-0
lines changed

3 files changed

+174
-0
lines changed

.github/workflows/nightly.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,43 @@ jobs:
107107
- name: Run tests under valgrind
108108
run: ${{github.workspace}}/test/test_valgrind.sh ${{github.workspace}} ${{github.workspace}}/build ${{matrix.tool}}
109109

110+
Linux-FetchContent:
111+
runs-on: ubuntu-latest
112+
container:
113+
image: ghcr.io/bb-ur/umf-${{ matrix.os }}:latest
114+
options: --user test_user --cap-add=SYS_NICE --cap-add=SYS_PTRACE
115+
volumes:
116+
- ${{ github.workspace }}:${{ github.workspace }}
117+
strategy:
118+
fail-fast: false
119+
matrix:
120+
os: ['ubuntu-24.04']
121+
build_type: [Debug]
122+
name: FetchContent-Linux (${{matrix.os}}, build_type=${{matrix.build_type}})
123+
124+
steps:
125+
- name: Checkout repository
126+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
127+
with:
128+
fetch-depth: 0
129+
130+
- name: Configure the fetch_content example
131+
working-directory: ${{github.workspace}}/examples/fetch_content
132+
# Fetch_Content the UMF code from the current repository (-DUMF_REPO="${{github.workspace}}")
133+
run: >
134+
cmake
135+
-B ${{github.workspace}}/examples/fetch_content/build
136+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
137+
-DUMF_REPO="${{github.workspace}}"
138+
139+
- name: Build the fetch_content example
140+
working-directory: ${{github.workspace}}/examples/fetch_content
141+
run: cmake --build ${{github.workspace}}/examples/fetch_content/build --config ${{matrix.build_type}} -j $(nproc)
142+
143+
- name: Run the fetch_content example
144+
working-directory: ${{github.workspace}}/examples/fetch_content/build
145+
run: ./umf_example_fetch_content
146+
110147
# Build and test UMF with different CMake generators on Windows
111148
Windows-generators:
112149
strategy:
@@ -188,6 +225,29 @@ jobs:
188225
echo "UMF_VERSION=$version" >> $env:GITHUB_ENV
189226
shell: pwsh
190227

228+
- name: Configure the fetch_content example
229+
working-directory: ${{github.workspace}}/examples/fetch_content
230+
# Fetch_Content the UMF code from the current repository (-DUMF_REPO="${{github.workspace}}")
231+
run: >
232+
cmake
233+
-B ${{github.workspace}}/examples/fetch_content/build
234+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
235+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
236+
-DUMF_REPO="${{github.workspace}}"
237+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
238+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
239+
-G "${{matrix.generator}}"
240+
241+
- name: Build the fetch_content example
242+
working-directory: ${{github.workspace}}/examples/fetch_content
243+
shell: cmd
244+
run: cmake --build ${{github.workspace}}/examples/fetch_content/build --config ${{matrix.build_type}} -j %NUMBER_OF_PROCESSORS%
245+
246+
- name: Run the fetch_content example
247+
shell: cmd
248+
working-directory: ${{github.workspace}}/examples/fetch_content/build
249+
run: dir .\umf_example_fetch_content.exe
250+
191251
- name: Test UMF installation and uninstallation
192252
# The '--shared-library' parameter is added to the installation test when the UMF is built as a shared library
193253
# The '--umfd-lib' parameter is added when the UMF is built with the umfd library

examples/fetch_content/CMakeLists.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
set(UMF_EXAMPLE_DIR "${CMAKE_SOURCE_DIR}/..")
10+
list(APPEND CMAKE_MODULE_PATH "${UMF_EXAMPLE_DIR}/cmake")
11+
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
12+
13+
include("fetch_umf.cmake")
14+
15+
find_package(PkgConfig)
16+
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
17+
if(NOT LIBHWLOC_FOUND)
18+
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
19+
endif()
20+
21+
pkg_check_modules(TBB tbb)
22+
if(NOT TBB_FOUND)
23+
find_package(TBB REQUIRED tbb)
24+
endif()
25+
26+
# build the example
27+
set(EXAMPLE_NAME umf_example_fetch_content)
28+
# reusing the basic.c source file from the basic example
29+
add_executable(${EXAMPLE_NAME} ${CMAKE_SOURCE_DIR}/../basic/basic.c)
30+
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS})
31+
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS})
32+
target_link_libraries(${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARIES} hwloc)
33+
34+
# an optional part - adds a test of this example
35+
add_test(
36+
NAME ${EXAMPLE_NAME}
37+
COMMAND ${EXAMPLE_NAME}
38+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
39+
40+
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example-standalone")
41+
42+
if(LINUX)
43+
# set LD_LIBRARY_PATH
44+
set_property(
45+
TEST ${EXAMPLE_NAME}
46+
PROPERTY
47+
ENVIRONMENT_MODIFICATION
48+
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
49+
)
50+
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(${CMAKE_SYSTEM_NAME} MATCHES "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)

0 commit comments

Comments
 (0)