45
45
46
46
# SPDX-License-Identifier: BSD-3-Clause
47
47
48
- cmake_minimum_required (VERSION 2.8 )
48
+ cmake_minimum_required (VERSION 2.80 )
49
49
project (qs LANGUAGES CXX )
50
50
51
51
set (CMAKE_CXX_STANDARD 17 )
52
52
set (CMAKE_CXX_STANDARD_REQUIRED ON )
53
53
54
- # SET(CMAKE_BUILD_TYPE "Debug")
55
- # SET(CMAKE_BUILD_TYPE "Release")
56
- # set(CMAKE_VERBOSE_MAKEFILE on)
57
54
option (ENABLE_KERNEL_PROFILING "Build using kernel profiling" OFF )
58
55
option (GPU_AOT "Build AOT for Intel GPU" OFF )
59
56
option (USE_NVIDIA_BACKEND "Build for NVIDIA backend" OFF )
60
57
option (USE_AMDHIP_BACKEND "Build for AMD HIP backend" OFF )
61
58
option (USE_SM "Specifies which streaming multiprocessor architecture to use" OFF )
62
59
63
- # set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -std=c++11 -O0 -Wall -g -lpthread -ggdb -pg")
64
- # set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -fsycl -Wall -g -lpthread -ggdb -pg -std=c++11")
65
- # set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -fsycl -Wall -std=c++11")
66
- set (CMAKE_CXX_FLAGS_DEBUG ${CXXFLAGS} "-fsycl -Wall -O1 -Wextra -pg" )
67
- set (CMAKE_CXX_FLAGS_RELEASE ${CXXFLAGS} "-fsycl -Wall -O3 -Wextra -ffp-contract=fast" )
68
-
69
60
include_directories (
70
61
${CMAKE_SOURCE_DIR} /src/
71
62
)
@@ -121,28 +112,42 @@ if(DEBUG)
121
112
add_definitions (-DDEBUG )
122
113
endif ()
123
114
124
- if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "Release" )
125
- message ("-- NOTE: setting build_type to release" )
126
- SET (CMAKE_BUILD_TYPE "Release" )
127
- else ()
128
- message ("-- NOTE: setting build_type to debug" )
129
- SET (CMAKE_BUILD_TYPE "Debug" )
130
- endif ()
131
-
132
- set (USE_DEFAULT_FLAGS ON )
133
- set (INTEL_GPU_CXX_FLAGS " -O2 -std=c++17 -DRUN_ON_GPU=1 -DHAVE_SYCL=1" )
134
- set (NVIDIA_GPU_CXX_FLAGS " -O3 -fsycl -DHAVE_SYCL" )
135
- set (AMD_GPU_CXX_FLAGS " -O0 -fsycl -DUNIFIED_HOST=1 -DHAVE_SYCL" )
136
-
137
- if ("${CMAKE_CXX_FLAGS} " STREQUAL "" )
138
- message (STATUS "Using DEFAULT compilation flags for the application" )
139
- string (APPEND CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for NV backend
140
- else ()
141
- message (STATUS "OVERRIDING compilation flags" )
142
- set (USE_DEFAULT_FLAGS OFF )
115
+ set (DEF_INTEL_WL_CXX_FLAGS " -DRUN_ON_GPU=1 -DHAVE_SYCL=1 " )
116
+ set (DEF_NVIDIA_WL_CXX_FLAGS " -DHAVE_SYCL=1 " )
117
+ set (DEF_AMD_WL_CXX_FLAGS " -DUNIFIED_HOST=1 -DHAVE_SYCL=1 " )
118
+
119
+ set (DEF_INTEL_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
120
+ set (DEF_NVIDIA_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
121
+ set (DEF_AMD_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
122
+
123
+
124
+ # -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
125
+ # -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
126
+ # passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
127
+
128
+ #set(USE_DEFAULT_FLAGS OFF)
129
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
130
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
131
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
132
+ message (STATUS "Using DEFAULT compilation flags" )
133
+ set (INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
134
+ set (NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
135
+ set (AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
136
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
137
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
138
+ set (INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
139
+ set (NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
140
+ set (AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
141
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
142
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
143
+ set (INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
144
+ set (NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
145
+ set (AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
143
146
endif ()
144
147
145
148
if (GPU_AOT )
149
+ message (STATUS "Enabling INTEL backend" )
150
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
146
151
if ((${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ))
147
152
message (STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT} " )
148
153
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \" -device 0x0bd5 -revision_id 0x2f\" -Xs \" -options -ze-opt-large-register-file\" " )
@@ -152,21 +157,19 @@ if(GPU_AOT)
152
157
endif ()
153
158
elseif (USE_NVIDIA_BACKEND )
154
159
message (STATUS "Enabling NVIDIA backend" )
155
-
156
- if (USE_DEFAULT_FLAGS )
157
- set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " ) # Default flags for NV backend
158
- endif ()
159
-
160
- string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} " ) # -O3 will be used, even though -O2 was set earlier
160
+ set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " )
161
+ string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} " )
161
162
elseif (USE_AMDHIP_BACKEND )
162
163
message (STATUS "Enabling AMD HIP backend for ${USE_AMDHIP_BACKEND} AMD architecture" )
163
-
164
- if (USE_DEFAULT_FLAGS )
165
- set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
166
- endif ()
167
-
164
+ set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
168
165
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} " )
166
+ else ()
167
+ # JIT case
168
+ message (STATUS "Enabling INTEL backend" )
169
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
169
170
endif ()
170
171
172
+ message (STATUS "CXX Compilation flags set to: ${CMAKE_CXX_FLAGS} " )
173
+
171
174
add_executable (qs ${SRC_LIST} )
172
175
target_link_libraries (qs sycl stdc++ stdc++fs )
0 commit comments