forked from KhronosGroup/SYCL-CTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (123 loc) · 5.13 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
cmake_minimum_required(VERSION 3.15)
project(sycl_cts LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON) # Required for hex floats in C++11 mode on gcc 6+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
find_package(Threads REQUIRED)
find_package(OpenCL REQUIRED)
find_package(PythonInterp 3 REQUIRED)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/vendor/Catch2/CMakeLists.txt")
message(FATAL_ERROR "The git submodule vendor/Catch2 is missing.\nTry running `git submodule update --init`.")
endif()
add_subdirectory(vendor/Catch2)
# set host compiler flags
if(WIN32)
add_compile_options(/bigobj)
endif()
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU" OR
${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-Wall -Wno-unused-variable)
endif()
include(AddSYCLExecutable)
# ------------------
# Extensive mode for full coverage
option(SYCL_CTS_ENABLE_FULL_CONFORMANCE
"Enable full conformance mode with extensive tests" OFF)
if(SYCL_CTS_ENABLE_FULL_CONFORMANCE)
message(STATUS "Full conformance mode: ON")
add_host_and_device_compiler_definitions(-DSYCL_CTS_ENABLE_FULL_CONFORMANCE)
else()
message(STATUS "Full conformance mode: OFF")
message(WARNING
"Full conformance mode should be used for conformance submission")
endif()
# ------------------
# ------------------
# Extensive mode for running extension oneAPI compile-time property list tests
option(SYCL_CTS_ENABLE_EXT_ONEAPI_PROPERTIES_TESTS
"Enable extension oneAPI compile-time property list tests" OFF)
if(SYCL_CTS_ENABLE_EXT_ONEAPI_PROPERTIES_TESTS)
message(STATUS "oneAPI extension compile-time property list tests mode: ON")
endif()
# ------------------
# ------------------
# Extensive mode for running legacy tests
option(SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS
"Enable tests for the deprecated SYCL features" ON)
if(SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS)
message(STATUS "Tests for the deprecated SYCL features are enabled")
add_definitions(-DSYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS)
else()
message(STATUS "Tests for the deprecated SYCL features are disabled")
message(WARNING
"Tests for the deprecated SYCL features should be enabled for conformance submission")
endif()
# ------------------
# ------------------
# Extensive mode for running extension oneAPI sub_group_mask tests
option(SYCL_CTS_ENABLE_EXT_ONEAPI_SUB_GROUP_MASK_TESTS
"Enable extension oneAPI sub_group_mask tests" OFF)
if(SYCL_CTS_ENABLE_EXT_ONEAPI_SUB_GROUP_MASK_TESTS)
message(STATUS "oneAPI extension sub_group_mask tests mode: ON")
endif()
# ------------------
# ------------------
# Extensive mode for running extension oneAPI device_global tests
option(SYCL_CTS_ENABLE_EXT_ONEAPI_DEVICE_GLOBAL_TESTS
"Enable extension oneAPI device_global tests" OFF)
if(SYCL_CTS_ENABLE_EXT_ONEAPI_DEVICE_GLOBAL_TESTS)
message(STATUS "oneAPI extension device_global tests mode: ON")
endif()
# ------------------
# ------------------
# Debug-level verbose logging
option(SYCL_CTS_ENABLE_VERBOSE_LOG "Enable debug-level logs" OFF)
if(SYCL_CTS_ENABLE_VERBOSE_LOG)
add_definitions(-DSYCL_CTS_VERBOSE_LOG)
endif()
# ------------------
# ------------------
# Double and Half variables
option(SYCL_CTS_ENABLE_DOUBLE_TESTS "Enable Double tests." ON)
option(SYCL_CTS_ENABLE_HALF_TESTS "Enable Half tests." ON)
if(SYCL_CTS_ENABLE_DOUBLE_TESTS)
add_host_and_device_compiler_definitions(-DSYCL_CTS_TEST_DOUBLE)
endif()
if(SYCL_CTS_ENABLE_HALF_TESTS)
add_host_and_device_compiler_definitions(-DSYCL_CTS_TEST_HALF)
endif()
# ------------------
# ------------------
# OpenCL interoperability
option(SYCL_CTS_ENABLE_OPENCL_INTEROP_TESTS
"Enable OpenCL interoperability tests." ON)
if(SYCL_CTS_ENABLE_OPENCL_INTEROP_TESTS)
add_host_and_device_compiler_definitions(-DSYCL_CTS_TEST_OPENCL_INTEROP)
endif()
# ------------------
# ------------------
# Device used for running with CTest (e.g. during conformance report generation)
set(SYCL_CTS_CTEST_DEVICE "" CACHE STRING "Device used when running with CTest")
# ------------------
# ------------------
# Measure build times
option(SYCL_CTS_MEASURE_BUILD_TIMES "Measure build time for each translation unit and write it to 'build_times.log'" OFF)
if(SYCL_CTS_MEASURE_BUILD_TIMES)
if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
# Wrap compiler calls in utility script to measure build times.
# Note that SYCL implementations that require custom build steps, e.g. for dedicated
# device compiler passes (such as ComputeCpp), may require special handling.
# In case the user already specified a compiler launcher, make sure ours comes first.
list(PREPEND CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_SOURCE_DIR}/tools/measure_build_time.py")
else()
# Only Makefiles and Ninja support CMake compiler launchers
message(FATAL_ERROR "Build time measurements are only supported for the 'Unix Makefiles' and 'Ninja' generators.")
endif()
endif()
# ------------------
enable_testing()
add_subdirectory(util)
add_subdirectory(tests)
add_subdirectory(oclmath)