Skip to content

Make memspace_hmat and memspace_numa examples standalone #755

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
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
4 changes: 2 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ if(LINUX)

add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS memspace/memspace_numa.c
SRCS memspace_numa/memspace_numa.c
LIBS umf ${LIBHWLOC_LIBRARIES} numa)

target_include_directories(
Expand All @@ -233,7 +233,7 @@ if(LINUX)

add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS memspace/memspace_hmat.c
SRCS memspace_hmat/memspace_hmat.c
LIBS umf ${LIBHWLOC_LIBRARIES} numa)

target_include_directories(
Expand Down
20 changes: 20 additions & 0 deletions examples/cmake/FindLIBNUMA.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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

message(STATUS "Checking for module 'libnuma' using find_library()")

find_library(LIBNUMA_LIBRARY NAMES libnuma numa)
set(LIBNUMA_LIBRARIES ${LIBNUMA_LIBRARY})

if(LIBNUMA_LIBRARY)
message(STATUS " Found libnuma using find_library()")
else()
set(MSG_NOT_FOUND
"libnuma NOT found (set CMAKE_PREFIX_PATH to point the location)")
if(LIBNUMA_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
endif()
endif()
58 changes: 58 additions & 0 deletions examples/memspace_hmat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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_memspace_hmat 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(LIBNUMA numa)
if(NOT LIBNUMA_FOUND)
find_package(LIBNUMA REQUIRED numa)
endif()

# build the example
set(EXAMPLE_NAME umf_example_memspace_hmat)
add_executable(${EXAMPLE_NAME} memspace_hmat.c)
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS}
../common)
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS}
${LIBNUMA_LIBRARY_DIRS})
target_link_libraries(
${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARIES} ${LIBHWLOC_LIBRARIES}
${LIBNUMA_LIBRARIES})

add_test(
NAME ${EXAMPLE_NAME}
COMMAND ${EXAMPLE_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

set(UMF_TEST_SKIP_RETURN_CODE 125)
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example-standalone")
set_tests_properties(${EXAMPLE_NAME} PROPERTIES SKIP_RETURN_CODE
${UMF_TEST_SKIP_RETURN_CODE})

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};LD_LIBRARY_PATH=path_list_append:${LIBNUMA_LIBRARY_DIRS}"
)
endif()
58 changes: 58 additions & 0 deletions examples/memspace_numa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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_memspace_numa 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(LIBNUMA numa)
if(NOT LIBNUMA_FOUND)
find_package(LIBNUMA REQUIRED numa)
endif()

# build the example
set(EXAMPLE_NAME umf_example_memspace_numa)
add_executable(${EXAMPLE_NAME} memspace_numa.c)
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS}
../common)
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS}
${LIBNUMA_LIBRARY_DIRS})
target_link_libraries(
${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARIES} ${LIBHWLOC_LIBRARIES}
${LIBNUMA_LIBRARIES})

add_test(
NAME ${EXAMPLE_NAME}
COMMAND ${EXAMPLE_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

set(UMF_TEST_SKIP_RETURN_CODE 125)
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example-standalone")
set_tests_properties(${EXAMPLE_NAME} PROPERTIES SKIP_RETURN_CODE
${UMF_TEST_SKIP_RETURN_CODE})

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};LD_LIBRARY_PATH=path_list_append:${LIBNUMA_LIBRARY_DIRS}"
)
endif()
9 changes: 9 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,15 @@ if(LINUX
)
endif()

if(LIBNUMA_LIBRARIES)
set(EXAMPLES ${EXAMPLES} memspace_hmat memspace_numa)
else()
message(
STATUS
"The memspace_hmat and memspace_numa examples require libnuma to be installed and added to the default library search path - skipping"
)
endif()

if(UMF_BUILD_GPU_EXAMPLES
AND UMF_BUILD_LIBUMF_POOL_DISJOINT
AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
Expand Down
Loading