diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 763d11670..acb118941 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -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( diff --git a/examples/custom_file_provider/CMakeLists.txt b/examples/custom_file_provider/CMakeLists.txt new file mode 100644 index 000000000..9d4e336c7 --- /dev/null +++ b/examples/custom_file_provider/CMakeLists.txt @@ -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() diff --git a/examples/custom_provider/file_provider.c b/examples/custom_file_provider/custom_file_provider.c similarity index 100% rename from examples/custom_provider/file_provider.c rename to examples/custom_file_provider/custom_file_provider.c diff --git a/scripts/docs_config/examples.rst b/scripts/docs_config/examples.rst index 0f88fcc40..5e2ff71fa 100644 --- a/scripts/docs_config/examples.rst +++ b/scripts/docs_config/examples.rst @@ -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 @@ -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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 22599dad4..c1877ddab 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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()