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")