@@ -29,28 +29,59 @@ set(MYBUILDTYPE Release Debug RelWithDebInfo MinSizeRel)
29
29
set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build" )
30
30
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${MYBUILDTYPE} )
31
31
32
- # Unfortunately, there is no proper support of SyCL in CMake as of now.
32
+ # Unfortunately, there is no proper support of SYCL in CMake as of now.
33
33
# Compilation without passing any environment variables was given as a
34
34
# requirement, hence, we set the compiler here directly (CMake discourages this).
35
35
set (SYCL oneAPI CACHE STRING "Select the SYCL target architecture" )
36
- set (MYSYCL oneAPI oneAPIold LLVM hipSYCL )
36
+ set (MYSYCL oneAPI oneAPIold LLVM OpenSYCL )
37
37
set_property (CACHE SYCL PROPERTY STRINGS ${MYSYCL} )
38
38
target_compile_definitions (echo PRIVATE SYCL=${SYCL} )
39
- # TODO: So far the only target for LLVM is NVIDIA, and for hipSYCL omp/cpu. Add the others!
40
- if (SYCL STREQUAL LLVM)
41
- set (CMAKE_CXX_COMPILER "clang++" )
42
- message (STATUS "Configuring Echo with LLVM (NVIDIA) Toolchain" )
43
- target_compile_options (echo PUBLIC -fsycl -fsycl-targets=nvptx64-nvidia-cuda)
44
- target_link_options (echo PUBLIC -fsycl -fsycl-targets=nvptx64-nvidia-cuda)
45
- message (STATUS "Set device target to NVIDIA PTX64" )
46
- elseif (SYCL STREQUAL hipSYCL )
39
+ target_compile_options (echo PUBLIC -fsycl)
40
+ target_link_options (echo PUBLIC -fsycl)
41
+
42
+ # A bit cumbersome to support all!
43
+ if (SYCL STREQUAL OpenSYCL )
47
44
set (CMAKE_CXX_COMPILER "syclcc-clang" )
48
- message (STATUS "Configuring Echo with hipSycl Toolchain" )
49
- else ()
50
- set (CMAKE_CXX_COMPILER "dpcpp" )
51
- message (STATUS "Configuring Echo with LLVM (Intel) Toolchain" )
52
- target_compile_options (echo PUBLIC -fsycl -fsycl-unnamed-lambda -xHost)
53
- target_link_options (echo PUBLIC -fsycl)
45
+ message (STATUS "Configuring Echo with OpenSycl Toolchain" )
46
+ elseif (SYCL STREQUAL LLVM)
47
+ set (CMAKE_CXX_COMPILER "clang++" )
48
+ set (SYCL_LLVM_CHAIN Intel CACHE STRING "Intel/NVidia/AMD" )
49
+ set (MYCHAIN AMD Intel NVidia)
50
+ set_property (CACHE SYCL_LLVM_CHAIN PROPERTY STRINGS ${MYCHAIN} )
51
+ message (STATUS "Configuring Echo with LLVM (${SYCL_LLVM_CHAIN} ) Toolchain" )
52
+ if (SYCL_LLVM_CHAIN STREQUAL AMD)
53
+ target_compile_options (echo PUBLIC -fsycl-targets=amdgcn-amd-amdhsa)
54
+ target_link_options (echo PUBLIC -fsycl-targets=amdgcn-amd-amdhsa)
55
+ set (SYCL_LLVM_ARCH gfx90a CACHE STRING "Run sycl-ls when in doubt." )
56
+ set (MYOFFLOAD_ARCH gfx90a gfx908 gfx906)
57
+ set_property (CACHE SYCL_LLVM_ARCH PROPERTY STRINGS ${MYOFFLOAD_ARCH} )
58
+ target_compile_options (echo PUBLIC -Xsycl-target -backend --offload-arch=${SYCL_LLVM_ARCH} )
59
+ target_link_options (echo PUBLIC -Xsycl-target -backend --offload-arch=${SYCL_LLVM_ARCH} )
60
+ message (STATUS "Set device target to AMDGCN ${SYCL_LLVM_ARCH} " )
61
+ elseif (SYCL_LLVM_CHAIN STREQUAL NVidia)
62
+ # Atm only AMD needs the arch. specified. Once needed for NVIDIA as well, do it here.
63
+ unset (SYCL_LLVM_ARCH CACHE )
64
+ target_compile_options (echo PUBLIC -fsycl-targets=nvptx64-nvidia-cuda)
65
+ target_link_options (echo PUBLIC -fsycl-targets=nvptx64-nvidia-cuda)
66
+ include (CheckLanguage)
67
+ check_language(CUDA)
68
+ if (CMAKE_CUDA_COMPILER)
69
+ enable_language (CUDA)
70
+ target_compile_options (echo PUBLIC --cuda-path =${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} /../../..)
71
+ target_link_options (echo PUBLIC --cuda-path =${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} /../../..)
72
+ #target_compile_options(echo PUBLIC --cuda-path=${CMAKE_CUDA_TOOLKIT_LIBRARY_ROOT})
73
+ #target_link_options (echo PUBLIC --cuda-path=${CMAKE_CUDA_TOOLKIT_LIBRARY_ROOT})
74
+ message (STATUS "Added explicit CUDA language." )
75
+ else ( )
76
+ message (WARNING "Explicit CUDA not found. With Codeplay NVidia plugin you should be fine. Otherwise..." )
77
+ endif ( )
78
+ message (STATUS "Set device target to NVIDIA PTX64." )
79
+ endif ( )
80
+ else ( )
81
+ unset (SYCL_LLVM_CHAIN CACHE )
82
+ unset (SYCL_LLVM_ARCH CACHE )
83
+ set (CMAKE_CXX_COMPILER "icpx" )
84
+ message (STATUS "Configuring Echo with oneAPI (Intel) Toolchain" )
54
85
message (STATUS "Set device target to SPIR-V Just-in-Time Compilation" )
55
86
#-- Stuff specific for oneAPI (for the moment)
56
87
option (ENABLE_MPI "Compile with MPI besides DPC++" OFF )
@@ -96,16 +127,26 @@ else()
96
127
endif ()
97
128
98
129
# -- DPC++ and Runtime
99
- option (GPU "Uses device selector rather than host" OFF )
100
- if (GPU)
101
- set (SUFFIX "${SUFFIX} _gpu" )
102
- target_compile_definitions (echo PRIVATE GPU)
103
- endif (GPU)
130
+ set (SYCL_DEVICE CPU CACHE STRING "Select the primary SYCL device (default/CPU/GPU/etc.). Overridden by forceDevice in echo.par" )
131
+ set (MYDEVICE DEF CPU GPU ACC FPGA)
132
+ set_property (CACHE SYCL_DEVICE PROPERTY STRINGS ${MYDEVICE} )
133
+ target_compile_definitions (echo PRIVATE DEVICE=DEV_${SYCL_DEVICE} )
134
+ if (NOT SYCL_DEVICE STREQUAL DEF )
135
+ string (TOLOWER ${SYCL_DEVICE} DEVSUFFIX)
136
+ set (SUFFIX "${SUFFIX} _${DEVSUFFIX} " )
137
+ endif ()
138
+ # TODO: Should be done way better than this! Also a10sx and s10sx were options...
139
+ if (SYCL_DEVICE STREQUAL FPGA )
140
+ message (WARNING "VERY experimental Intel FPGA workflow (probably not yet supported)!" )
141
+ target_compile_options (echo PUBLIC -fsycl-link -fintelfpga -Xshardware -Xsboard-package=/glob/development-tools/oneapi/oneapi/intel_s10sx_pac -Xsboard=pac_s10_usm)
142
+ target_link_options (echo PUBLIC -fsycl-link -fintelfpga -Xshardware -Xsboard-package=/glob/development-tools/oneapi/oneapi/intel_s10sx_pac -Xsboard=pac_s10_usm)
143
+ endif ()
104
144
145
+ # -- Compiling
105
146
try_compile (COMPILE_SUCCEEDED
106
- ${CMAKE_BINARY_DIR} /check
107
- SOURCES ${CMAKE_SOURCE_DIR} /cmake/checks/fscheck.cpp
108
- CXX_STANDARD 17
147
+ ${CMAKE_BINARY_DIR} /check
148
+ SOURCES ${CMAKE_SOURCE_DIR} /cmake/checks/fscheck.cpp
149
+ CXX_STANDARD 17
109
150
)
110
151
if (COMPILE_SUCCEEDED)
111
152
message (STATUS "C++ filesystem API available. Using that." )
@@ -116,15 +157,14 @@ endif()
116
157
CHECK_INCLUDE_FILE_CXX("filesystem.h" FSH_FOUND)
117
158
CHECK_INCLUDE_FILE_CXX(filesystem FS_FOUND)
118
159
119
-
120
160
option (ENABLE_MEMORY_SANITATION "Enable memory sanitizer to find and track invalid memory accesses. Currently disabled." OFF )
121
- # if (ENABLE_MEMORY_SANITATION AND NOT GPU)
122
- # message(STATUS "Memory sanitation enabled. Linking appropriate libraries.")
123
- # target_compile_options(echo PUBLIC -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined -fsanitize-address-use-after-scope -Wuninitialized -g)
124
- # target_link_libraries(echo PUBLIC -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined -g)
125
- # elseif(ENABLE_MEMORY_SANITATION)
126
- # message(WARNING "Memory sanitation is only available with disabled GPU for now.")
127
- # endif()
161
+ if (ENABLE_MEMORY_SANITATION) # AND NOT GPU)
162
+ message (STATUS "Memory sanitation enabled. Linking appropriate libraries." )
163
+ target_compile_options (echo PUBLIC -fno-omit-frame-pointer -Wuninitialized -g) # - fsanitize=address -fsanitize=undefined -fsanitize-address-use-after-scope
164
+ target_link_libraries (echo PUBLIC -fno-omit-frame-pointer -g) # - fsanitize=address -fsanitize=undefined
165
+ elseif (ENABLE_MEMORY_SANITATION)
166
+ message (WARNING "Memory sanitation is only available with disabled GPU for now." )
167
+ endif ()
128
168
129
169
option (SINGLE_PRECISION "Change field from double to float" OFF )
130
170
if (SINGLE_PRECISION)
0 commit comments