From ab349fffa9a849a4ad78fb05760cd1b3fe58ac01 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 19 Jan 2024 09:22:58 -0500 Subject: [PATCH] Add Hygon support for Intel Fortran --- CHANGELOG.md | 2 ++ compiler/flags/IntelLLVM_Fortran.cmake | 11 +++++++++++ compiler/flags/Intel_Fortran.cmake | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fde51bb8..574b0cdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added support for Hygon processors with Intel Fortran + ### Changed ### Deprecated diff --git a/compiler/flags/IntelLLVM_Fortran.cmake b/compiler/flags/IntelLLVM_Fortran.cmake index 0d26fe8e..6549292a 100644 --- a/compiler/flags/IntelLLVM_Fortran.cmake +++ b/compiler/flags/IntelLLVM_Fortran.cmake @@ -63,12 +63,23 @@ set (NO_RANGE_CHECK "") cmake_host_system_information(RESULT proc_description QUERY PROCESSOR_DESCRIPTION) if (${proc_description} MATCHES "EPYC") + # AMD EPYC processors support AVX2, but only via the -march=core-avx2 flag + set (COREAVX2_FLAG "-march=core-avx2") +elseif (${proc_description} MATCHES "Hygon") + # Hygon processors support AVX2, but only via the -march=core-avx2 flag set (COREAVX2_FLAG "-march=core-avx2") elseif (${proc_description} MATCHES "Intel") + # All the Intel processors that GEOS runs on support AVX2, but to be + # consistent with the AMD processors, we use the -march=core-avx2 flag set (COREAVX2_FLAG "-march=core-avx2") # Previous versions of GEOS used this flag, which was not portable # for AMD. Keeping here for a few versions for historical purposes. #set (COREAVX2_FLAG "-xCORE-AVX2") +elseif ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64" ) + # This is a fallback for when the above doesn't work. It should work + # for most x86_64 processors, but it is not guaranteed to be optimal. + message(WARNING "Unknown processory type. Defaulting to a generic x86_64 processor. Performance may be suboptimal.") + set (COREAVX2_FLAG "") else () message(FATAL_ERROR "Unknown processor. Please file an issue at https://github.com/GEOS-ESM/ESMA_cmake") endif () diff --git a/compiler/flags/Intel_Fortran.cmake b/compiler/flags/Intel_Fortran.cmake index 3214e1d2..a5368e00 100644 --- a/compiler/flags/Intel_Fortran.cmake +++ b/compiler/flags/Intel_Fortran.cmake @@ -69,13 +69,21 @@ set (NO_RANGE_CHECK "") cmake_host_system_information(RESULT proc_description QUERY PROCESSOR_DESCRIPTION) if (${proc_description} MATCHES "EPYC") + # AMD EPYC processors support AVX2, but only via the -march=core-avx2 flag + set (COREAVX2_FLAG "-march=core-avx2") +elseif (${proc_description} MATCHES "Hygon") + # Hygon processors support AVX2, but only via the -march=core-avx2 flag set (COREAVX2_FLAG "-march=core-avx2") elseif (${proc_description} MATCHES "Intel") + # All the Intel processors that GEOS runs on support AVX2, but to be + # consistent with the AMD processors, we use the -march=core-avx2 flag set (COREAVX2_FLAG "-march=core-avx2") # Previous versions of GEOS used this flag, which was not portable # for AMD. Keeping here for a few versions for historical purposes. #set (COREAVX2_FLAG "-xCORE-AVX2") elseif ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64" ) + # This is a fallback for when the above doesn't work. It should work + # for most x86_64 processors, but it is not guaranteed to be optimal. message(WARNING "Unknown processory type. Defaulting to a generic x86_64 processor. Performance may be suboptimal.") set (COREAVX2_FLAG "") # Once you are in here, you are probably on Rosetta, but not required.