From 7d11ea328e8861f04a9f538810f8adaacf217ca0 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Tue, 7 Jun 2022 12:24:06 -0400 Subject: [PATCH 1/5] Changes needed to run GEOS on M1 --- compiler/flags/GNU_Fortran.cmake | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/compiler/flags/GNU_Fortran.cmake b/compiler/flags/GNU_Fortran.cmake index 6329d3ca..8240510f 100644 --- a/compiler/flags/GNU_Fortran.cmake +++ b/compiler/flags/GNU_Fortran.cmake @@ -7,6 +7,7 @@ set (FOPT1 "-O1") set (FOPT2 "-O2") set (FOPT3 "-O3") set (FOPT4 "-O3") +set (FOPTFAST "-Ofast") set (DEBINFO "-g") set (FPE0 "") @@ -117,10 +118,11 @@ if ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL aarch64 ) elseif ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL arm64 ) # For now the only arm64 we have tested is Apple M1. This # might need to be revisited for M1 Max/Ultra and M2+. - # Also, fail if a Linux Arm64 + # Also, fail if a Linux Arm64. Testing show GEOS fails + # with -march=native if (APPLE) set (GNU_TARGET_ARCH "armv8-a") - set (GNU_NATIVE_ARCH "native") + set (GNU_NATIVE_ARCH ${GNU_TARGET_ARCH}) endif () elseif (${proc_decription} MATCHES "EPYC") set (GNU_TARGET_ARCH "znver2") @@ -177,8 +179,18 @@ set (GEOS_Fortran_Vect_FPE_Flags ${GEOS_Fortran_Release_FPE_Flags}) # NOTE2: This uses -march=native so compile on your target architecture!!! # Options per Jerry DeLisle on GCC Fortran List -set (GEOS_Fortran_Aggressive_Flags "${FOPT2} -march=${GNU_NATIVE_ARCH} -ffast-math -ftree-vectorize -funroll-loops --param max-unroll-times=4 ${PREFER_AVX128} ${NO_FMA}") -set (GEOS_Fortran_Aggressive_FPE_Flags "${DEBINFO} ${TRACEBACK} ${MISMATCH} ${ALLOW_BOZ}") +if ( APPLE AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL arm64 ) + # For now the only arm64 we have tested is Apple M1. This + # might need to be revisited for M1 Max/Ultra and M2+. + # Testing has not yet found any aggressive flags better than + # the release so for now, use those + set (GEOS_Fortran_Aggressive_Flags "${GEOS_Fortran_Release_Flags}") + set (GEOS_Fortran_Aggressive_FPE_Flags "${GEOS_Fortran_Release_FPE_Flags}") +else () + set (GEOS_Fortran_Aggressive_Flags "${FOPT2} -march=${GNU_NATIVE_ARCH} -ffast-math -ftree-vectorize -funroll-loops --param max-unroll-times=4 ${PREFER_AVX128} ${NO_FMA}") + set (GEOS_Fortran_Aggressive_FPE_Flags "${DEBINFO} ${TRACEBACK} ${MISMATCH} ${ALLOW_BOZ}") +endif () + # Options per Jerry DeLisle on GCC Fortran List with SVML (does not seem to help) #set (GEOS_Fortran_Aggressive_Flags "-O2 -march=native -ffast-math -ftree-vectorize -funroll-loops --param max-unroll-times=4 ${PREFER_AVX128} -mno-fma -mveclibabi=svml") From f7646e4d8d21445b289be52a2b54189fe00d9822 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Tue, 7 Jun 2022 12:27:45 -0400 Subject: [PATCH 2/5] Update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd9b294e..e1b34b16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed + +- Update M1 flags on GNU from GEOS testing + ### Fixed ### Removed ### Added From cf32ba2de4a7690953a5d51c26f1b4a384c748f0 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 8 Jun 2022 11:27:14 -0400 Subject: [PATCH 3/5] Clean up and add Rosetta2 M1 flags --- CHANGELOG.md | 1 + compiler/flags/GNU_Fortran.cmake | 24 +++++++++++++++--------- compiler/flags/Intel_Fortran.cmake | 6 +++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1b34b16..4a5e2271 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Update M1 flags on GNU from GEOS testing +- Also add M1-Rosetta2 flags from @climbfuji ### Fixed ### Removed diff --git a/compiler/flags/GNU_Fortran.cmake b/compiler/flags/GNU_Fortran.cmake index 8240510f..42b3ef87 100644 --- a/compiler/flags/GNU_Fortran.cmake +++ b/compiler/flags/GNU_Fortran.cmake @@ -110,25 +110,31 @@ set (NO_ALIAS "") set (NO_RANGE_CHECK "-fno-range-check") -cmake_host_system_information(RESULT proc_decription QUERY PROCESSOR_DESCRIPTION) +cmake_host_system_information(RESULT proc_description QUERY PROCESSOR_DESCRIPTION) + +message (STATUS "proc_description: ${proc_description}") +message (STATUS "CMAKE_HOST_SYSTEM_PROCESSOR: ${CMAKE_HOST_SYSTEM_PROCESSOR}") if ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL aarch64 ) set (GNU_TARGET_ARCH "armv8.2-a+crypto+crc+fp16+rcpc+dotprod") set (GNU_NATIVE_ARCH ${GNU_TARGET_ARCH}) -elseif ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL arm64 ) - # For now the only arm64 we have tested is Apple M1. This - # might need to be revisited for M1 Max/Ultra and M2+. - # Also, fail if a Linux Arm64. Testing show GEOS fails - # with -march=native - if (APPLE) +elseif (${proc_description} MATCHES "Apple M1") + if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "arm64") + # Testing show GEOS fails with -march=native on M1 in native mode set (GNU_TARGET_ARCH "armv8-a") set (GNU_NATIVE_ARCH ${GNU_TARGET_ARCH}) + elseif (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") + # Rosetta2 flags per tests by @climbfuji + set (GNU_TARGET_ARCH "westmere") + set (GNU_NATIVE_ARCH "native") + set (PREFER_AVX128 "-mprefer-avx128") + set (NO_FMA "-mno-fma") endif () -elseif (${proc_decription} MATCHES "EPYC") +elseif (${proc_description} MATCHES "EPYC") set (GNU_TARGET_ARCH "znver2") set (GNU_NATIVE_ARCH "native") set (NO_FMA "-mno-fma") -elseif (${proc_decription} MATCHES "Intel") +elseif (${proc_description} MATCHES "Intel") set (GNU_TARGET_ARCH "westmere") set (GNU_NATIVE_ARCH "native") set (PREFER_AVX128 "-mprefer-avx128") diff --git a/compiler/flags/Intel_Fortran.cmake b/compiler/flags/Intel_Fortran.cmake index 2ce35707..f06e5ad6 100644 --- a/compiler/flags/Intel_Fortran.cmake +++ b/compiler/flags/Intel_Fortran.cmake @@ -47,10 +47,10 @@ set (USE_SVML "-fimf-use-svml=true") set (NO_RANGE_CHECK "") -cmake_host_system_information(RESULT proc_decription QUERY PROCESSOR_DESCRIPTION) -if (${proc_decription} MATCHES "EPYC") +cmake_host_system_information(RESULT proc_description QUERY PROCESSOR_DESCRIPTION) +if (${proc_description} MATCHES "EPYC") set (COREAVX2_FLAG "-march=core-avx2") -elseif (${proc_decription} MATCHES "Intel") +elseif (${proc_description} MATCHES "Intel") 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. From 9cf3e4f305424668e14340142c7d561e397310f2 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 8 Jun 2022 11:28:17 -0400 Subject: [PATCH 4/5] Remove messages --- compiler/flags/GNU_Fortran.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/flags/GNU_Fortran.cmake b/compiler/flags/GNU_Fortran.cmake index 42b3ef87..72dab6fa 100644 --- a/compiler/flags/GNU_Fortran.cmake +++ b/compiler/flags/GNU_Fortran.cmake @@ -112,9 +112,6 @@ set (NO_RANGE_CHECK "-fno-range-check") cmake_host_system_information(RESULT proc_description QUERY PROCESSOR_DESCRIPTION) -message (STATUS "proc_description: ${proc_description}") -message (STATUS "CMAKE_HOST_SYSTEM_PROCESSOR: ${CMAKE_HOST_SYSTEM_PROCESSOR}") - if ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL aarch64 ) set (GNU_TARGET_ARCH "armv8.2-a+crypto+crc+fp16+rcpc+dotprod") set (GNU_NATIVE_ARCH ${GNU_TARGET_ARCH}) From 3cb1a8c457f2480009ae846db43e2ebab514ff99 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 8 Jun 2022 11:29:31 -0400 Subject: [PATCH 5/5] Make Aggressive consistent --- compiler/flags/GNU_Fortran.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/flags/GNU_Fortran.cmake b/compiler/flags/GNU_Fortran.cmake index 72dab6fa..3f7da5d8 100644 --- a/compiler/flags/GNU_Fortran.cmake +++ b/compiler/flags/GNU_Fortran.cmake @@ -182,7 +182,7 @@ set (GEOS_Fortran_Vect_FPE_Flags ${GEOS_Fortran_Release_FPE_Flags}) # NOTE2: This uses -march=native so compile on your target architecture!!! # Options per Jerry DeLisle on GCC Fortran List -if ( APPLE AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL arm64 ) +if (${proc_description} MATCHES "Apple M1" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "arm64") # For now the only arm64 we have tested is Apple M1. This # might need to be revisited for M1 Max/Ultra and M2+. # Testing has not yet found any aggressive flags better than