@@ -34,9 +34,41 @@ option(USE_NVIDIA_BACKEND "Build for NVIDIA backend" OFF)
34
34
option (USE_AMDHIP_BACKEND "Build for AMD HIP backend" OFF )
35
35
option (DEVICE_TIMER "Build using Device Timer" OFF )
36
36
37
- set (INTEL_GPU_CXX_FLAGS " -O3 -fsycl -ffast-math -DMKL_ILP64" )
38
- set (NVIDIA_GPU_CXX_FLAGS " -O3 -fsycl -ffast-math -DUSE_CUBLAS" )
39
- set (AMD_GPU_CXX_FLAGS " -O3 -fsycl -ffast-math -DUSE_ROCBLAS -D__HIP_PLATFORM_AMD__" )
37
+ set (DEF_INTEL_WL_CXX_FLAGS " -DMKL_ILP64 " )
38
+ set (DEF_NVIDIA_WL_CXX_FLAGS " -DUSE_CUBLAS " )
39
+ set (DEF_AMD_WL_CXX_FLAGS " -DUSE_ROCBLAS -D__HIP_PLATFORM_AMD__ " )
40
+
41
+ set (DEF_INTEL_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
42
+ set (DEF_NVIDIA_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
43
+ set (DEF_AMD_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
44
+
45
+
46
+ # -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
47
+ # -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
48
+ # passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
49
+
50
+ #set(USE_DEFAULT_FLAGS OFF)
51
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
52
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
53
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
54
+ message (STATUS "Using DEFAULT compilation flags" )
55
+ set (INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
56
+ set (NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
57
+ set (AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
58
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
59
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
60
+ set (INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
61
+ set (NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
62
+ set (AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
63
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
64
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
65
+ set (INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
66
+ set (NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
67
+ set (AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
68
+ endif ()
69
+
70
+
71
+
40
72
41
73
if (NOT DEFINED DNNLROOT AND DEFINED ENV{DNNLROOT} )
42
74
set (DNNLROOT "$ENV{DNNLROOT} " CACHE STRING "" )
@@ -119,13 +151,7 @@ message(STATUS "DNNLROOT set to: ${DNNLROOT}")
119
151
# -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags
120
152
121
153
122
- set (USE_DEFAULT_FLAGS ON )
123
- if ("${CMAKE_CXX_FLAGS} " STREQUAL "" )
124
- message (STATUS "Using DEFAULT compilation flags" )
125
- else ()
126
- message (STATUS "OVERRIDING DEFAULT compilation flags" )
127
- set (USE_DEFAULT_FLAGS OFF )
128
- endif ()
154
+
129
155
130
156
add_compile_options (-DRUN_ON_GPU )
131
157
#add_compile_options(-DKERNEL_USE_PROFILE "0")
@@ -148,9 +174,7 @@ endif()
148
174
# JIT compilation
149
175
if (GPU_AOT )
150
176
message (STATUS "Enabling INTEL backend" )
151
- if (USE_DEFAULT_FLAGS )
152
- set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for Intel backend
153
- endif ()
177
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
154
178
if ( (${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ) )
155
179
message (STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT} " )
156
180
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \" -device 0x0bd5 -revision_id 3\" " )
@@ -160,19 +184,17 @@ if(GPU_AOT)
160
184
endif ()
161
185
elseif (USE_NVIDIA_BACKEND )
162
186
message (STATUS "Enabling NVIDIA backend" )
163
- if (USE_DEFAULT_FLAGS )
164
- set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " ) # Default flags for NV backend
165
- endif ()
187
+ set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " )
166
188
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvidia_gpu_sm_${USE_SM} " )
167
189
elseif (USE_AMD_BACKEND )
168
190
message (STATUS "Enabling AMD backend" )
169
191
message (STATUS "Enabling AMD HIP backend for ${USE_AMD_ARCH} AMD architecture" )
170
- if (USE_DEFAULT_FLAGS )
171
- set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " ) # Default flags for AMD backend (gfx908 for MI100)
172
- endif ()
173
- #string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amd_gpu_gfx${USE_AMD_ARCH}")
174
- #string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} ")
192
+ set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
175
193
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMD_ARCH} " )
194
+ else ()
195
+ # JIT case
196
+ message (STATUS "Enabling INTEL backend" )
197
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
176
198
endif ()
177
199
178
200
# Output the compiler flags that were constructed for visual inspection
0 commit comments