forked from juliusikkala/fuchsia_radix_sort
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
107 lines (95 loc) · 4.44 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
106
107
cmake_minimum_required(VERSION 3.16)
project(RadixSort LANGUAGES C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Vulkan REQUIRED)
# GoogleTest setup
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/5ed21863955149a5a877a53d7d5045b6919090ed.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
function(shader header source source_list include_path)
get_filename_component(shader_bin_name ${source} NAME)
string(REPLACE "\." "_" shader_bin_name ${shader_bin_name})
add_custom_command(
OUTPUT ${header}
COMMAND glslc --target-env=vulkan1.2 ${CMAKE_CURRENT_SOURCE_DIR}/${source} -o ${CMAKE_CURRENT_BINARY_DIR}/${shader_bin_name}.spv -I${include_path} -Os
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHONPATH} python3 ${CMAKE_CURRENT_SOURCE_DIR}/generate_c_header.py ${CMAKE_CURRENT_BINARY_DIR}/${shader_bin_name}.spv ${CMAKE_CURRENT_BINARY_DIR}/${header} ${shader_bin_name}
MAIN_DEPENDENCY ${source}
DEPENDS ${source}
IMPLICIT_DEPENDS C ${source}
VERBATIM
)
set(${source_list} ${${source_list}} ${header} PARENT_SCOPE)
endfunction()
set(targets
amd/gcn3
arm/bifrost4
arm/bifrost8
intel/gen8
nvidia/sm35
)
foreach(target ${targets})
foreach(keyval IN ITEMS u32 u64)
get_filename_component(arch ${target} NAME)
set(a ${arch}_${keyval}_)
set(i "${CMAKE_CURRENT_SOURCE_DIR}/platforms/vk/targets/vendors/${target}/${keyval}")
shader(${a}init.comp.h platforms/vk/shaders/init.comp shader_binary ${i})
shader(${a}fill.comp.h platforms/vk/shaders/fill.comp shader_binary ${i})
shader(${a}histogram.comp.h platforms/vk/shaders/histogram.comp shader_binary ${i})
shader(${a}prefix.comp.h platforms/vk/shaders/prefix.comp shader_binary ${i})
shader(${a}scatter_0_even.comp.h platforms/vk/shaders/scatter_0_even.comp shader_binary ${i})
shader(${a}scatter_0_odd.comp.h platforms/vk/shaders/scatter_0_odd.comp shader_binary ${i})
shader(${a}scatter_1_even.comp.h platforms/vk/shaders/scatter_1_even.comp shader_binary ${i})
shader(${a}scatter_1_odd.comp.h platforms/vk/shaders/scatter_1_odd.comp shader_binary ${i})
set(target_sources ${target_sources} ${i}/header.c)
endforeach()
endforeach()
add_library(vk-radix-sort STATIC
platforms/vk/radix_sort_vk.c
platforms/vk/radix_sort_vk_ext.h
platforms/vk/shaders/push.h
platforms/vk/target.h
platforms/vk/target.c
platforms/vk/target_requirements.c
platforms/vk/target_requirements.h
common/vk/assert.c
common/vk/barrier.c
common/util.c
${target_sources}
${shader_binary}
)
target_link_libraries(vk-radix-sort PUBLIC Vulkan::Vulkan)
target_include_directories(vk-radix-sort PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/platforms/vk ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(vk-radix-sort PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/platforms/vk/include)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
if(BUILD_TESTING)
enable_language(CXX)
set(common_src
platforms/vk/tests/radix_sort_vk_bench/cpu_sort.cc
platforms/vk/tests/radix_sort_vk_bench/radix_sort_vk_bench.cpp
platforms/vk/tests/radix_sort_vk_bench/find_target_name.c
common/vk/assert.c
common/vk/barrier.c
common/vk/debug_utils.c
common/vk/find_mem_type_idx.c
common/vk/pipeline_cache.c
common/util.c
)
# Benchmark executable
add_executable(benchmark platforms/vk/tests/radix_sort_vk_bench/main.c ${common_src})
target_link_libraries(benchmark PUBLIC vk-radix-sort)
target_include_directories(benchmark PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(benchmark PUBLIC RS_VK_TARGET_ARCHIVE_LINKABLE)
# Unit tests with GoogleTest
add_executable(unittest platforms/vk/tests/radix_sort_vk_bench/tests/radix_sort_vk_bench_unittests.cc ${common_src})
target_link_libraries(unittest PUBLIC vk-radix-sort gtest gtest_main)
target_include_directories(unittest PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} platforms/vk/tests/radix_sort_vk_bench)
target_compile_definitions(unittest PUBLIC RS_VK_TARGET_ARCHIVE_LINKABLE)
# Commented out for now
# gtest_add_tests(unittest "" AUTO)
endif()
endif()