Skip to content

Commit 9e2b5c6

Browse files
author
Anudeep Kambapu
authored
Merge pull request #14 from oneapi-src/quicksilver/cmake_update
[Quicksilver] SYCL CMake update with additional override flags
2 parents 6a40bc3 + 96055c8 commit 9e2b5c6

File tree

1 file changed

+43
-40
lines changed

1 file changed

+43
-40
lines changed

QuickSilver/SYCL/CMakeLists.txt

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,18 @@
4545

4646
# SPDX-License-Identifier: BSD-3-Clause
4747

48-
cmake_minimum_required(VERSION 2.8)
48+
cmake_minimum_required(VERSION 2.80)
4949
project(qs LANGUAGES CXX)
5050

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,28 +112,42 @@ 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)
149+
message(STATUS "Enabling INTEL backend")
150+
set(CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS}")
146151
if((${GPU_AOT} STREQUAL "pvc") OR(${GPU_AOT} STREQUAL "PVC"))
147152
message(STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT}")
148153
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)
152157
endif()
153158
elseif(USE_NVIDIA_BACKEND)
154159
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} ")
161162
elseif(USE_AMDHIP_BACKEND)
162163
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}")
168165
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}")
169170
endif()
170171

172+
message(STATUS "CXX Compilation flags set to: ${CMAKE_CXX_FLAGS}")
173+
171174
add_executable(qs ${SRC_LIST})
172175
target_link_libraries(qs sycl stdc++ stdc++fs)

0 commit comments

Comments
 (0)