Skip to content

Enhance build flags for Debug and RelWithDebInfo configurations #1671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ endif()

# Only for debugging. Save building time by shrinking translation unit scope.
set(BUILD_SEPARATE_OPS $ENV{BUILD_SEPARATE_OPS})
if(CMAKE_BUILD_TYPE MATCHES "(Debug|RelWithDebInfo)")
set(BUILD_SEPARATE_OPS TRUE)
endif()
set(BUILD_SPLIT_KERNEL_LIB $ENV{BUILD_SPLIT_KERNEL_LIB})
add_subdirectory(${TORCH_XPU_OPS_ROOT}/src)

Expand Down
15 changes: 11 additions & 4 deletions cmake/BuildFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
list(APPEND SYCL_HOST_FLAGS -g)
list(APPEND SYCL_HOST_FLAGS -O0)
endif(CMAKE_BUILD_TYPE MATCHES Debug)

list(APPEND SYCL_HOST_FLAGS -g -fno-omit-frame-pointer -O0)
elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
list(APPEND SYCL_HOST_FLAGS -g -O2)
endif()
if(USE_PER_OPERATOR_HEADERS)
list(APPEND SYCL_HOST_FLAGS -DAT_PER_OPERATOR_HEADERS)
endif()
Expand Down Expand Up @@ -84,6 +84,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -Wno-absolute-value)
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -no-ftz)
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -g -O0 -Rno-debug-disables-optimization)
elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -gline-tables-only -O2)
endif()

set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -D__INTEL_LLVM_COMPILER_VERSION=${__INTEL_LLVM_COMPILER})

CHECK_SYCL_FLAG("-fsycl-fp64-conv-emu" SUPPORTS_FP64_CONV_EMU)
Expand Down
Loading