Skip to content

Commit c666f12

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 c666f12

File tree

4 files changed

+140
-2
lines changed

4 files changed

+140
-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: dir .\umf_example_fetch_content.exe
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: 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)

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)