Skip to content

Make the custom_file_provider example standalone #754

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,12 @@ if(LINUX)

set_tests_properties(${EXAMPLE_NAME} PROPERTIES
SKIP_RETURN_CODE ${UMF_TEST_SKIP_RETURN_CODE})
set(EXAMPLE_NAME umf_example_file_provider)

set(EXAMPLE_NAME umf_example_custom_file_provider)

add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS custom_provider/file_provider.c
SRCS custom_file_provider/custom_file_provider.c
LIBS umf ${LIBHWLOC_LIBRARIES})

target_include_directories(
Expand Down
52 changes: 52 additions & 0 deletions examples/custom_file_provider/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (C) 2024 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
project(umf_example_custom_file_provider LANGUAGES C)
enable_testing()

set(UMF_EXAMPLE_DIR "${CMAKE_SOURCE_DIR}/..")
list(APPEND CMAKE_MODULE_PATH "${UMF_EXAMPLE_DIR}/cmake")
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")

find_package(PkgConfig)
pkg_check_modules(LIBUMF libumf)
if(NOT LIBUMF_FOUND)
find_package(LIBUMF REQUIRED libumf)
endif()

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_custom_file_provider)
add_executable(${EXAMPLE_NAME} custom_file_provider.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}
${LIBHWLOC_LIBRARIES})

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}"
)
endif()
4 changes: 2 additions & 2 deletions scripts/docs_config/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ TODO
Custom memory provider
==============================================================================

You can find the full examples code in the `examples/custom_provider/file_provider.c`_ file
You can find the full examples code in the `examples/custom_file_provider/custom_file_provider.c`_ file
in the UMF repository.

TODO
Expand Down Expand Up @@ -212,7 +212,7 @@ the :any:`umfCloseIPCHandle` function is called.
.. _examples/level_zero_shared_memory/level_zero_shared_memory.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/level_zero_shared_memory/level_zero_shared_memory.c
.. _examples/cuda_shared_memory/cuda_shared_memory.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/cuda_shared_memory/cuda_shared_memory.c
.. _examples/ipc_level_zero/ipc_level_zero.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/ipc_level_zero/ipc_level_zero.c
.. _examples/custom_provider/file_provider.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/custom_provider/file_provider.c
.. _examples/custom_file_provider/custom_file_provider.c: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/custom_file_provider/custom_file_provider.c
.. _examples/memspace: https://github.com/oneapi-src/unified-memory-framework/blob/main/examples/memspace/
.. _README: https://github.com/oneapi-src/unified-memory-framework/blob/main/README.md#memory-pool-managers
.. _umf/ipc.h: https://github.com/oneapi-src/unified-memory-framework/blob/main/include/umf/ipc.h
Expand Down
6 changes: 4 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,15 @@ if(LINUX
OR UMF_USE_UBSAN
OR UMF_USE_TSAN
OR UMF_USE_MSAN))

set(EXAMPLES "")

if(UMF_POOL_SCALABLE_ENABLED)
set(EXAMPLES ${EXAMPLES} basic)
set(EXAMPLES ${EXAMPLES} basic custom_file_provider)
else()
message(
STATUS
"The basic example requires TBB to be installed and added to the default library search path - skipping"
"The basic and custom_file_provider examples require TBB to be installed and added to the default library search path - skipping"
)
endif()

Expand Down
Loading