From 8829c249b713dddc87c2669120a9798e202ac633 Mon Sep 17 00:00:00 2001 From: Sunita Nadampalli Date: Tue, 10 Oct 2023 13:20:13 +0000 Subject: [PATCH] cmake: aarch64: Defaults to a generic cpu target This is equivalent to setting -mtune=generic -march=armv8-a. This ensures no implementation specific tuning, or architectural features beyond armv8-a are used,for portability across AArch64 systems.The DNNL_ARCH_OPT_FLAGS build option can be used to override these defaults to optimise for a specific cpu, or revision of the Armv8 architecture. --- cmake/platform.cmake | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmake/platform.cmake b/cmake/platform.cmake index 5d75452b926..841aa973df8 100644 --- a/cmake/platform.cmake +++ b/cmake/platform.cmake @@ -210,9 +210,13 @@ elseif(UNIX OR MINGW) if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") set(DEF_ARCH_OPT_FLAGS "-O3") endif() - # For native compilation tune for the host processor if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR) - append(DEF_ARCH_OPT_FLAGS "-mcpu=native") + # Defaults to a generic cpu target, equivalent to setting -mtune=generic -march=armv8-a. + # This ensures no implementation specific tuning, or architectural features beyond + # armv8-a are used, for portability across AArch64 systems. + # The DNNL_ARCH_OPT_FLAGS build option can be used to override these defaults + # to optimise for a specific cpu, or revision of the Armv8 architecture. + append(DEF_ARCH_OPT_FLAGS "-mcpu=generic") endif() elseif(DNNL_TARGET_ARCH STREQUAL "PPC64") if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -307,9 +311,13 @@ elseif(UNIX OR MINGW) if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") set(DEF_ARCH_OPT_FLAGS "-O3") endif() - # For native compilation tune for the host processor if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR) - append(DEF_ARCH_OPT_FLAGS "-mcpu=native") + # Defaults to a generic cpu target, equivalent to setting -mtune=generic -march=armv8-a. + # This ensures no implementation specific tuning, or architectural features beyond + # armv8-a are used, for portability across AArch64 systems. + # The DNNL_ARCH_OPT_FLAGS build option can be used to override these defaults + # to optimise for a specific cpu, or revision of the Armv8 architecture. + append(DEF_ARCH_OPT_FLAGS "-mcpu=generic") endif() elseif(DNNL_TARGET_ARCH STREQUAL "PPC64") if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")