Skip to content
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

build: cmake: enabling frame pointers #2244

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ endif()
if(MSVC)
set(USERCONFIG_PLATFORM "x64")
append_if(DNNL_WERROR CMAKE_CCXX_FLAGS "/WX")

# Generating frame pointers for easier performance profiling
if(DNNL_TARGET_ARCH STREQUAL "X64")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
append(CMAKE_CCXX_FLAGS "-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer")
else()
append(CMAKE_CCXX_FLAGS "/Oy-")
endif()
endif()

if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
append(CMAKE_CCXX_FLAGS "/MP")
# increase number of sections in obj file
Expand Down Expand Up @@ -233,6 +243,11 @@ elseif(UNIX OR MINGW)
append(CMAKE_CCXX_FLAGS "-Wsign-compare")
endif()

# Generating frame pointers for easier performance profiling
if(DNNL_TARGET_ARCH STREQUAL "X64")
append(CMAKE_CCXX_FLAGS "-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer")
endif()

platform_unix_and_mingw_common_ccxx_flags(CMAKE_CCXX_FLAGS)
platform_unix_and_mingw_common_cxx_flags(CMAKE_CXX_FLAGS)
platform_unix_and_mingw_noexcept_ccxx_flags(CMAKE_CMAKE_CCXX_NOEXCEPT_FLAGS)
Expand Down Expand Up @@ -280,8 +295,11 @@ elseif(UNIX OR MINGW)
if(DNNL_USE_CLANG_SANITIZER STREQUAL "MemoryWithOrigin")
append(CMAKE_CCXX_SANITIZER_FLAGS
"-fsanitize-memory-track-origins=2")
append(CMAKE_CCXX_SANITIZER_FLAGS
"-fno-omit-frame-pointer")
# Already enabled for x64
if(NOT DNNL_TARGET_ARCH STREQUAL "X64")
append(CMAKE_CCXX_SANITIZER_FLAGS
"-fno-omit-frame-pointer")
endif()
endif()
set(DNNL_ENABLED_CLANG_SANITIZER "${DNNL_USE_CLANG_SANITIZER}")
elseif(DNNL_USE_CLANG_SANITIZER STREQUAL "Undefined")
Expand All @@ -306,7 +324,12 @@ elseif(UNIX OR MINGW)
message(STATUS
"Using Clang ${DNNL_ENABLED_CLANG_SANITIZER} "
"sanitizer (experimental!)")
append(CMAKE_CCXX_SANITIZER_FLAGS "-g -fno-omit-frame-pointer")
append(CMAKE_CCXX_SANITIZER_FLAGS "-g")
# Already enabled for x64
if(NOT DNNL_TARGET_ARCH STREQUAL "X64")
append(CMAKE_CCXX_SANITIZER_FLAGS "-fno-omit-frame-pointer")
endif()

# Blacklist to ignore false-positive cases. Each case may be
# assigned to a specific sanitizer. See online doc for help.
append(CMAKE_CCXX_SANITIZER_FLAGS
Expand Down Expand Up @@ -439,9 +462,9 @@ if (DNNL_TARGET_ARCH STREQUAL "RV64")
# Check if the RVV Intrinsics can be compiled with the current toolchain and flags
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <riscv_vector.h>
int main() {
int main() {
size_t size = 64;
return vsetvl_e32m2(size);
return vsetvl_e32m2(size);
};"
CAN_COMPILE_RVV_INTRINSICS
)
Expand Down
Loading