-
Notifications
You must be signed in to change notification settings - Fork 35
Add test for FetchContent of UMF on Linux and Windows #1384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could add a short description why do we have this example |
||
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR) | ||
project(umf_example_fetch_content LANGUAGES C) | ||
enable_testing() | ||
|
||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
set(LINUX TRUE) | ||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||
set(WINDOWS TRUE) | ||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
set(MACOSX TRUE) | ||
else() | ||
message(FATAL_ERROR "Unknown OS type") | ||
endif() | ||
|
||
set(UMF_EXAMPLE_DIR "${CMAKE_SOURCE_DIR}/..") | ||
list(APPEND CMAKE_MODULE_PATH "${UMF_EXAMPLE_DIR}/cmake") | ||
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") | ||
|
||
include("fetch_umf.cmake") | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(LIBHWLOC hwloc>=2.3.0) | ||
if(NOT LIBHWLOC_FOUND) | ||
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc) | ||
endif() | ||
|
||
pkg_check_modules(TBB tbb) | ||
if(NOT TBB_FOUND) | ||
find_package(TBB REQUIRED tbb) | ||
endif() | ||
|
||
# build the example | ||
set(EXAMPLE_NAME umf_example_fetch_content) | ||
# reusing the basic.c source file from the basic example | ||
add_executable(${EXAMPLE_NAME} ${CMAKE_SOURCE_DIR}/../basic/basic.c) | ||
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS}) | ||
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS}) | ||
target_link_libraries(${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARIES} hwloc) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you please add printing of PATHs found in this example and used above..? // e.g. like here: https://github.com/lukaszstolarczuk/unified-memory-framework/actions/runs/16051712582/job/45295762065#step:11:4353 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which paths exactly do you mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mostly which umf is used (so |
||
# an optional part - adds a test of this example | ||
add_test( | ||
NAME ${EXAMPLE_NAME} | ||
COMMAND ${EXAMPLE_NAME} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example-standalone") | ||
|
||
if(LINUX) | ||
# set LD_LIBRARY_PATH | ||
set_property( | ||
TEST ${EXAMPLE_NAME} | ||
PROPERTY | ||
ENVIRONMENT_MODIFICATION | ||
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}" | ||
) | ||
elseif(WINDOWS) | ||
# add PATH to DLL on Windows | ||
set(DLL_PATH_LIST | ||
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_DLL_DIRS};PATH=path_list_append:${TBB_DLL_DIRS}" | ||
) | ||
|
||
message(STATUS "DLL_PATH_LIST=${DLL_PATH_LIST}") | ||
|
||
# append PATH to DLLs NOTE: this would work only for the CMake ver >= # | ||
# 3.22. For the older versions, the PATH variable should be set in the test | ||
# script) | ||
set_property(TEST ${EXAMPLE_NAME} PROPERTY ENVIRONMENT_MODIFICATION | ||
"${DLL_PATH_LIST}") | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a general note, not neccessarily needed to be done in this PR - so now, as we test it, perhaps we should add a README section about integration (e.g. like in UR repo: https://github.com/oneapi-src/unified-runtime?tab=readme-ov-file#integration) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can consider that. The question is if it should be the recommended way to integrate UMF. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm yeah, probably we shouldn't say that it's recommended |
||
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
message(STATUS "Downloading Unified Memory Framework ...") | ||
|
||
include(FetchContent) | ||
|
||
if(NOT DEFINED UMF_REPO) | ||
set(UMF_REPO "https://github.com/oneapi-src/unified-memory-framework.git") | ||
elseif(WINDOWS) | ||
string(REPLACE "\\" "/" OUT_UMF_REPO "${UMF_REPO}") | ||
message( | ||
STATUS | ||
"Replaced \"${UMF_REPO}\" with \"${OUT_UMF_REPO}\" for Windows compatibility" | ||
) | ||
set(UMF_REPO "${OUT_UMF_REPO}") | ||
endif() | ||
|
||
if(NOT DEFINED UMF_TAG) | ||
set(UMF_TAG HEAD) | ||
endif() | ||
|
||
message( | ||
STATUS | ||
"Will fetch Unified Memory Framework from ${UMF_REPO} at ${UMF_TAG} ..." | ||
) | ||
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}") | ||
|
||
FetchContent_Declare( | ||
unified-memory-framework | ||
GIT_REPOSITORY ${UMF_REPO} | ||
GIT_TAG ${UMF_TAG}) | ||
|
||
set(UMF_BUILD_TESTS | ||
OFF | ||
CACHE INTERNAL "Do not build UMF tests") | ||
set(UMF_BUILD_EXAMPLES | ||
OFF | ||
CACHE INTERNAL "Do not build UMF examples") | ||
set(UMF_BUILD_SHARED_LIBRARY | ||
OFF | ||
CACHE INTERNAL "Build UMF shared library") | ||
set(UMF_BUILD_LIBUMF_POOL_DISJOINT | ||
ON | ||
CACHE INTERNAL "Build Disjoint Pool") | ||
set(UMF_BUILD_CUDA_PROVIDER | ||
OFF | ||
CACHE INTERNAL "Do not build CUDA provider") | ||
set(UMF_BUILD_LEVEL_ZERO_PROVIDER | ||
OFF | ||
CACHE INTERNAL "Do not build L0 provider") | ||
set(UMF_DISABLE_HWLOC | ||
OFF | ||
CACHE INTERNAL "Enable HWLOC support") | ||
set(UMF_LINK_HWLOC_STATICALLY | ||
OFF | ||
CACHE INTERNAL "UMF_LINK_HWLOC_STATICALLY=OFF") | ||
|
||
FetchContent_MakeAvailable(unified-memory-framework) | ||
FetchContent_GetProperties(unified-memory-framework) | ||
|
||
set(LIBUMF_INCLUDE_DIRS ${unified-memory-framework_SOURCE_DIR}/include) | ||
set(LIBUMF_LIBRARIES umf::umf umf::headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have a step like this, I guess we could just do the same as in that step: add
if: matrix.static_hwloc == 'OFF'
to the fetch_content example's configure/build/execution stepsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fetch_content example always requires hwloc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I'm just saying, we could test that example only in cases where the job already have VCPKG_PATH set