-
Notifications
You must be signed in to change notification settings - Fork 35
Add standalone tests of examples #599
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
lukaszstolarczuk
merged 1 commit into
oneapi-src:main
from
ldorau:Add_standalone_tests_of_examples
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_basic 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_basic) | ||
add_executable(${EXAMPLE_NAME} 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) | ||
|
||
# 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}" | ||
) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# 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 'libhwloc' using find_library()") | ||
|
||
find_library(LIBHWLOC_LIBRARY NAMES libhwloc hwloc) | ||
set(LIBHWLOC_LIBRARIES ${LIBHWLOC_LIBRARY}) | ||
|
||
get_filename_component(LIBHWLOC_LIB_DIR ${LIBHWLOC_LIBRARIES} DIRECTORY) | ||
set(LIBHWLOC_LIBRARY_DIRS ${LIBHWLOC_LIB_DIR}) | ||
|
||
find_file(LIBHWLOC_HEADER NAMES hwloc.h) | ||
get_filename_component(LIBHWLOC_INCLUDE_DIR ${LIBHWLOC_HEADER} DIRECTORY) | ||
set(LIBHWLOC_INCLUDE_DIRS ${LIBHWLOC_INCLUDE_DIR}) | ||
|
||
set(HWLOC_VERSION_CODE | ||
" | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include \"hwloc.h\" | ||
|
||
void main(int argc, char** argv) { | ||
unsigned LIBHWLOC_API_PATCH = HWLOC_API_VERSION & 0xFF; | ||
unsigned LIBHWLOC_API_MINOR = (HWLOC_API_VERSION >> 8) & 0xFF; | ||
unsigned LIBHWLOC_API_MAJOR = (HWLOC_API_VERSION >> 16) & 0xFF; | ||
printf(\"%d.%d.%d\", LIBHWLOC_API_MAJOR, LIBHWLOC_API_MINOR, LIBHWLOC_API_PATCH); | ||
}") | ||
|
||
set(HWLOC_VERSION_CODE_FILENAME "hwloc_get_version.c") | ||
file(WRITE "${CMAKE_BINARY_DIR}/${HWLOC_VERSION_CODE_FILENAME}" | ||
"${HWLOC_VERSION_CODE}") | ||
|
||
try_run( | ||
HWLOC_RUN_RESULT HWLOC_COMPILE_RESULT ${CMAKE_BINARY_DIR} | ||
"${CMAKE_BINARY_DIR}/${HWLOC_VERSION_CODE_FILENAME}" | ||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${LIBHWLOC_INCLUDE_DIR}" | ||
RUN_OUTPUT_VARIABLE LIBHWLOC_API_VERSION) | ||
|
||
if(WINDOWS) | ||
find_file(LIBHWLOC_DLL NAMES "bin/hwloc-15.dll" "bin/libhwloc-15.dll") | ||
get_filename_component(LIBHWLOC_DLL_DIR ${LIBHWLOC_DLL} DIRECTORY) | ||
set(LIBHWLOC_DLL_DIRS ${LIBHWLOC_DLL_DIR}) | ||
endif() | ||
|
||
if(LIBHWLOC_LIBRARY) | ||
message(STATUS " Found libhwloc using find_library()") | ||
message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}") | ||
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}") | ||
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}") | ||
message(STATUS " LIBHWLOC_API_VERSION = ${LIBHWLOC_API_VERSION}") | ||
if(WINDOWS) | ||
message(STATUS " LIBHWLOC_DLL_DIRS = ${LIBHWLOC_DLL_DIRS}") | ||
endif() | ||
|
||
if(LIBHWLOC_FIND_VERSION) | ||
if(NOT LIBHWLOC_API_VERSION) | ||
message(FATAL_ERROR "Failed to retrieve libhwloc version") | ||
elseif(NOT LIBHWLOC_API_VERSION VERSION_GREATER_EQUAL | ||
LIBHWLOC_FIND_VERSION) | ||
message( | ||
FATAL_ERROR | ||
" Required version: ${LIBHWLOC_FIND_VERSION}, found ${LIBHWLOC_API_VERSION}" | ||
) | ||
endif() | ||
endif() | ||
else() | ||
set(MSG_NOT_FOUND | ||
"libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)") | ||
if(LIBHWLOC_FIND_REQUIRED) | ||
message(FATAL_ERROR ${MSG_NOT_FOUND}) | ||
else() | ||
message(WARNING ${MSG_NOT_FOUND}) | ||
endif() | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# 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 'libumf' using find_library()") | ||
|
||
find_library(LIBUMF_LIBRARY NAMES libumf umf) | ||
set(LIBUMF_LIBRARIES ${LIBUMF_LIBRARY}) | ||
|
||
get_filename_component(LIBUMF_LIB_DIR ${LIBUMF_LIBRARIES} DIRECTORY) | ||
set(LIBUMF_LIBRARY_DIRS ${LIBUMF_LIB_DIR}) | ||
|
||
find_file(LIBUMF_HEADER NAMES umf.h) | ||
get_filename_component(LIBUMF_INCLUDE_DIR ${LIBUMF_HEADER} DIRECTORY) | ||
set(LIBUMF_INCLUDE_DIRS ${LIBUMF_INCLUDE_DIR}) | ||
|
||
if(LIBUMF_LIBRARY) | ||
message(STATUS " Found libumf using find_library()") | ||
message(STATUS " LIBUMF_LIBRARIES = ${LIBUMF_LIBRARIES}") | ||
message(STATUS " LIBUMF_INCLUDE_DIRS = ${LIBUMF_INCLUDE_DIRS}") | ||
message(STATUS " LIBUMF_LIBRARY_DIRS = ${LIBUMF_LIBRARY_DIRS}") | ||
else() | ||
set(MSG_NOT_FOUND | ||
"libumf NOT found (set CMAKE_PREFIX_PATH to point the location)") | ||
if(LIBUMF_FIND_REQUIRED) | ||
message(FATAL_ERROR ${MSG_NOT_FOUND}) | ||
else() | ||
message(WARNING ${MSG_NOT_FOUND}) | ||
endif() | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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 'tbb' using find_library()") | ||
|
||
find_library(TBB_LIBRARY NAMES libtbbmalloc tbbmalloc) | ||
set(TBB_LIBRARIES ${TBB_LIBRARY}) | ||
|
||
get_filename_component(TBB_LIB_DIR ${TBB_LIBRARIES} DIRECTORY) | ||
set(TBB_LIBRARY_DIRS ${TBB_LIB_DIR}) | ||
|
||
find_file(TBB_HEADER NAMES "tbb/scalable_allocator.h") | ||
if(TBB_HEADER) | ||
get_filename_component(TBB_INCLUDE_DIR_TBB ${TBB_HEADER} DIRECTORY) | ||
get_filename_component(TBB_INCLUDE_DIR ${TBB_INCLUDE_DIR_TBB} DIRECTORY) | ||
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR}) | ||
else() | ||
set(MSG_NOT_FOUND "<tbb/scalable_allocator.h> header NOT found (set " | ||
"CMAKE_PREFIX_PATH to point the location)") | ||
if(TBB_FIND_REQUIRED) | ||
message(FATAL_ERROR ${MSG_NOT_FOUND}) | ||
else() | ||
message(WARNING ${MSG_NOT_FOUND}) | ||
endif() | ||
endif() | ||
|
||
if(WINDOWS) | ||
find_file(TBB_DLL NAMES "bin/tbbmalloc.dll") | ||
get_filename_component(TBB_DLL_DIR ${TBB_DLL} DIRECTORY) | ||
set(TBB_DLL_DIRS ${TBB_DLL_DIR}) | ||
endif() | ||
|
||
if(TBB_LIBRARY) | ||
message(STATUS " Found tbb using find_library()") | ||
message(STATUS " TBB_LIBRARIES = ${TBB_LIBRARIES}") | ||
message(STATUS " TBB_INCLUDE_DIRS = ${TBB_INCLUDE_DIRS}") | ||
message(STATUS " TBB_LIBRARY_DIRS = ${TBB_LIBRARY_DIRS}") | ||
if(WINDOWS) | ||
message(STATUS " TBB_DLL_DIRS = ${TBB_DLL_DIRS}") | ||
endif() | ||
else() | ||
set(MSG_NOT_FOUND "tbb NOT found (set CMAKE_PREFIX_PATH to point the " | ||
"location)") | ||
if(TBB_FIND_REQUIRED) | ||
message(FATAL_ERROR ${MSG_NOT_FOUND}) | ||
else() | ||
message(WARNING ${MSG_NOT_FOUND}) | ||
endif() | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# 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_gpu_shared_memory 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() | ||
|
||
include(FetchContent) | ||
|
||
set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git") | ||
set(LEVEL_ZERO_LOADER_TAG v1.16.1) | ||
|
||
message( | ||
STATUS | ||
"Installing level-zero ${LEVEL_ZERO_LOADER_TAG} from ${LEVEL_ZERO_LOADER_REPO} ..." | ||
) | ||
|
||
FetchContent_Declare( | ||
level-zero-loader | ||
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO} | ||
GIT_TAG ${LEVEL_ZERO_LOADER_TAG} | ||
EXCLUDE_FROM_ALL) | ||
|
||
FetchContent_GetProperties(level-zero-loader) | ||
if(NOT level-zero-loader_POPULATED) | ||
FetchContent_Populate(level-zero-loader) | ||
endif() | ||
|
||
set(LEVEL_ZERO_INCLUDE_DIRS | ||
${level-zero-loader_SOURCE_DIR}/include | ||
CACHE PATH "Path to Level Zero Headers") | ||
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}") | ||
|
||
# build the example | ||
set(EXAMPLE_NAME umf_example_gpu_shared_memory) | ||
add_executable(${EXAMPLE_NAME} gpu_shared_memory.c) | ||
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS} | ||
${UMF_EXAMPLE_DIR}/common) | ||
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARY_DIRS} | ||
${LIBHWLOC_LIBRARY_DIRS}) | ||
target_link_options(${EXAMPLE_NAME} PRIVATE "-Wl,--start-group") | ||
target_link_libraries(${EXAMPLE_NAME} PRIVATE stdc++ libdisjoint_pool.a | ||
ze_loader ${LIBUMF_LIBRARIES}) | ||
|
||
# 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}" | ||
) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# 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_ipc_ipcapi 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 | ||
function(build_umf_ipc_example name) | ||
set(BASE_NAME ${name}) | ||
set(EXAMPLE_NAME umf_example_${BASE_NAME}) | ||
|
||
foreach(loop_var IN ITEMS "producer" "consumer") | ||
set(EX_NAME ${EXAMPLE_NAME}_${loop_var}) | ||
add_executable(${EX_NAME} ${BASE_NAME}_${loop_var}.c) | ||
target_include_directories(${EX_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS}) | ||
target_link_directories(${EX_NAME} PRIVATE ${LIBHWLOC_LIBRARY_DIRS}) | ||
target_link_libraries(${EX_NAME} PRIVATE ${LIBUMF_LIBRARIES} hwloc) | ||
endforeach(loop_var) | ||
endfunction() | ||
|
||
# an optional part - adds a test of this example | ||
function(add_test_for_umf_ipc_example script) | ||
set(EXAMPLE_NAME umf_example_${script}) | ||
|
||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${script}.sh | ||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
add_test( | ||
NAME ${EXAMPLE_NAME} | ||
COMMAND ${script}.sh | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
if(LINUX) | ||
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() | ||
|
||
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example-standalone") | ||
if(NOT UMF_TESTS_FAIL_ON_SKIP) | ||
set_tests_properties(${EXAMPLE_NAME} PROPERTIES SKIP_RETURN_CODE 125) | ||
endif() | ||
endfunction() | ||
|
||
# build the example | ||
build_umf_ipc_example(ipc_ipcapi) | ||
|
||
# an optional part - adds a test of this example | ||
add_test_for_umf_ipc_example(ipc_ipcapi_anon_fd) | ||
add_test_for_umf_ipc_example(ipc_ipcapi_shm) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.