Skip to content

Commit 39398e5

Browse files
author
skambapugithub
committed
Updated SYCL CMake with ovverride flags
1 parent 483f2ef commit 39398e5

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

QuickSilver/SYCL/CMakeLists.txt

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,12 @@ project(qs LANGUAGES CXX)
5151
set(CMAKE_CXX_STANDARD 17)
5252
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5353

54-
# SET(CMAKE_BUILD_TYPE "Debug")
55-
# SET(CMAKE_BUILD_TYPE "Release")
56-
# set(CMAKE_VERBOSE_MAKEFILE on)
5754
option(ENABLE_KERNEL_PROFILING "Build using kernel profiling" OFF)
5855
option(GPU_AOT "Build AOT for Intel GPU" OFF)
5956
option(USE_NVIDIA_BACKEND "Build for NVIDIA backend" OFF)
6057
option(USE_AMDHIP_BACKEND "Build for AMD HIP backend" OFF)
6158
option(USE_SM "Specifies which streaming multiprocessor architecture to use" OFF)
6259

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-
6960
include_directories(
7061
${CMAKE_SOURCE_DIR}/src/
7162
)
@@ -121,25 +112,37 @@ if(DEBUG)
121112
add_definitions(-DDEBUG)
122113
endif()
123114

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}")
143146
endif()
144147

145148
if(GPU_AOT)
@@ -152,21 +155,19 @@ if(GPU_AOT)
152155
endif()
153156
elseif(USE_NVIDIA_BACKEND)
154157
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
158+
set(CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS}")
159+
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} ")
161160
elseif(USE_AMDHIP_BACKEND)
162161
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-
162+
set(CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS}")
168163
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} ")
164+
else()
165+
# JIT case
166+
message(STATUS "Enabling INTEL backend")
167+
set(CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS}")
169168
endif()
170169

170+
message(STATUS "CXX Compilation flags set to: ${CMAKE_CXX_FLAGS}")
171+
171172
add_executable(qs ${SRC_LIST})
172173
target_link_libraries(qs sycl stdc++ stdc++fs)

0 commit comments

Comments
 (0)