-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathCMakeLists.txt
105 lines (95 loc) · 3.5 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# ########################################################################
# Copyright 2024 Advanced Micro Devices, Inc.
# ########################################################################
function(add_hipstdpar_test TEST TEST_TYPE INTERPOSE_ALLOC)
set(TEST_SOURCE "test_${TEST}.cpp")
set(TEST_TARGET "${TEST}_${TEST_TYPE}.hip")
add_executable(${TEST_TARGET} ${TEST_SOURCE})
target_compile_options(${TEST_TARGET}
PRIVATE
--hipstdpar
--hipstdpar-path=${HIPSTDPAR_LOCATION}
--hipstdpar-thrust-path=${THRUST_LOCATION})
if(INTERPOSE_ALLOC)
target_compile_options(${TEST_TARGET}
PRIVATE
--hipstdpar-interpose-alloc
)
endif()
target_link_libraries(${TEST_TARGET}
PRIVATE
--hipstdpar
TBB::tbb
Threads::Threads
)
if (NOT WIN32)
foreach(gpu_target ${GPU_TARGETS})
target_link_libraries(${TEST_TARGET}
PRIVATE
--offload-arch=${gpu_target}
)
endforeach()
endif()
set_target_properties(${TEST_TARGET}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test/hipstdpar"
)
if(AMDGPU_TEST_TARGETS)
foreach(AMDGPU_TARGET IN LISTS AMDGPU_TEST_TARGETS)
add_test("${AMDGPU_TARGET}-${TEST_TARGET}" ${TEST_TARGET})
set_tests_properties("${AMDGPU_TARGET}-${TEST_TARGET}"
PROPERTIES
RESOURCE_GROUPS "1,${AMDGPU_TARGET}:1"
LABELS "hip;${AMDGPU_TARGET}"
)
endforeach()
else()
add_relative_test(${TEST_TARGET} ${TEST_TARGET})
set_tests_properties(${TEST_TARGET}
PROPERTIES
LABELS "hip"
)
endif()
rocm_install(TARGETS ${TEST_TARGET} COMPONENT tests)
if (WIN32 AND NOT DEFINED DLLS_COPIED)
set(DLLS_COPIED "YES")
set(DLLS_COPIED ${DLLS_COPIED} PARENT_SCOPE)
# for now adding in all .dll as dependency chain is not cmake based on win32
file( GLOB third_party_dlls
LIST_DIRECTORIES ON
CONFIGURE_DEPENDS
${HIP_DIR}/bin/*.dll
${CMAKE_SOURCE_DIR}/rtest.*
)
foreach( file_i ${third_party_dlls})
add_custom_command( TARGET ${TEST_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${file_i} ${PROJECT_BINARY_DIR}/test )
endforeach( file_i )
endif()
endfunction()
# Make sure that hipstdpar tests are compiled for C++17, without changing the global state
set(ROCTHRUST_CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD})
set(CMAKE_CXX_STANDARD 17)
# Dependencies
find_package(TBB QUIET)
if(NOT TARGET TBB::tbb AND NOT TARGET tbb)
message(STATUS "Thread Building Blocks not found. Fetching...")
FetchContent_Declare(
thread-building-blocks
GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git
GIT_TAG 1c4c93fc5398c4a1acb3492c02db4699f3048dea # v2021.13.0
)
# Disable tests for TBB
set(TBB_TEST OFF CACHE BOOL "Disable TBB tests" FORCE)
FetchContent_MakeAvailable(thread-building-blocks)
else()
find_package(TBB REQUIRED)
endif()
find_package(Threads REQUIRED)
# Define where to find rocThrust and hipstdpar headers
set(THRUST_LOCATION ${PROJECT_SOURCE_DIR})
set(HIPSTDPAR_LOCATION ${THRUST_LOCATION}/thrust/system/hip/hipstdpar)
# Add tests
add_hipstdpar_test("algorithms" "compile" OFF)
add_hipstdpar_test("interpose" "compile" ON)
# Restore global state
set(CMAKE_CXX_STANDARD ${ROCTHRUST_CMAKE_CXX_STANDARD})