From 86a4b8eac37691788e1447b1ff61b33d774dfa86 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 12 May 2023 19:28:20 -0400 Subject: [PATCH 1/4] Find OpenACC --- esma.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esma.cmake b/esma.cmake index 6debfc16..e131691c 100644 --- a/esma.cmake +++ b/esma.cmake @@ -33,6 +33,10 @@ include (esma_compiler) find_package (OpenMP) +### OpenACC ### + +find_package (OpenACC) + ### Position independent code ### set(CMAKE_POSITION_INDEPENDENT_CODE ON) From 850a51083a8dce0e2700726a48c5e2ab390cea5f Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Sat, 24 Jun 2023 14:03:53 -0400 Subject: [PATCH 2/4] Added option GPU_PHYSICS with default value OFF --- esma.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/esma.cmake b/esma.cmake index e131691c..e5b421ad 100644 --- a/esma.cmake +++ b/esma.cmake @@ -33,9 +33,12 @@ include (esma_compiler) find_package (OpenMP) -### OpenACC ### +### GPU Physics ### -find_package (OpenACC) +option(GPU_PHYSICS "Build GPU ports of Physics components" OFF) +if (GPU_PHYSICS) + find_package (OpenACC) +endif () ### Position independent code ### From 8f2dbf48fc434af81c3ee8d6c6125217690a0a99 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 30 Jun 2023 12:24:47 -0400 Subject: [PATCH 3/4] Added a set of variables for OpenACC compilation --- CHANGELOG.md | 4 ++++ compiler/flags/GNU_Fortran.cmake | 8 ++++++++ esma.cmake | 14 +++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66d68f5c..00a45442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added option `GPU_PHYSICS` which defaults to `OFF`. When `ON`, available + OpenACC ports of Phsyics routines will be built instead of their original + versions. + ### Changed ## [3.30.0] - 2023-06-23 diff --git a/compiler/flags/GNU_Fortran.cmake b/compiler/flags/GNU_Fortran.cmake index 9140d491..608d7612 100644 --- a/compiler/flags/GNU_Fortran.cmake +++ b/compiler/flags/GNU_Fortran.cmake @@ -110,6 +110,10 @@ set (NO_ALIAS "") set (NO_RANGE_CHECK "-fno-range-check") +set (OPENACC_COMPILE "-fopenacc") +set (OPENACC_OFFLOAD_TARGETS "-foffload=nvptx-none") +set (OPENACC_OFFLOAD_OPTIONS "-lgfortran -lgomp -lm") + cmake_host_system_information(RESULT proc_description QUERY PROCESSOR_DESCRIPTION) if ( ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL aarch64 ) @@ -202,6 +206,10 @@ endif () #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") #set (GEOS_Fortran_Aggressive_FPE_Flags "${DEBINFO} ${TRACEBACK} ${MISMATCH} ${ALLOW_BOZ}") +# OpenACC flags +# ------------- +set (GEOS_Fortran_OpenACC_Flags "${OPENACC_COMPILE} ${OPENACC_OFFLOAD_TARGETS}") +set (GEOS_Fortran_OpenACC_Flags_Offload_Libs "${OPENACC_COMPILE} ${OPENACC_OFFLOAD_OPTIONS} ${OPENACC_OFFLOAD_TARGETS}") # Common variables for every compiler include(Generic_Fortran) diff --git a/esma.cmake b/esma.cmake index e5b421ad..0c5e5db7 100644 --- a/esma.cmake +++ b/esma.cmake @@ -24,6 +24,13 @@ option(BUILD_SHARED_LIBS "Build the shared library" OFF) set (ECBUILD_2_COMPAT_VALUE OFF) include (ecbuild_system NO_POLICY_SCOPE) +### GPU Physics ### + +option(GPU_PHYSICS "Build GPU ports of Physics components" OFF) +if (GPU_PHYSICS) + find_package (OpenACC) +endif () + ### Compiler Support ### list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/compiler") @@ -33,13 +40,6 @@ include (esma_compiler) find_package (OpenMP) -### GPU Physics ### - -option(GPU_PHYSICS "Build GPU ports of Physics components" OFF) -if (GPU_PHYSICS) - find_package (OpenACC) -endif () - ### Position independent code ### set(CMAKE_POSITION_INDEPENDENT_CODE ON) From 718762fb16b19128f29228e5e2309a69d3ca9043 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 30 Jun 2023 12:40:34 -0400 Subject: [PATCH 4/4] Added -foffload --- 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 608d7612..7c34c544 100644 --- a/compiler/flags/GNU_Fortran.cmake +++ b/compiler/flags/GNU_Fortran.cmake @@ -112,7 +112,7 @@ set (NO_RANGE_CHECK "-fno-range-check") set (OPENACC_COMPILE "-fopenacc") set (OPENACC_OFFLOAD_TARGETS "-foffload=nvptx-none") -set (OPENACC_OFFLOAD_OPTIONS "-lgfortran -lgomp -lm") +set (OPENACC_OFFLOAD_OPTIONS "-foffload=-lgfortran -lgomp -lm") cmake_host_system_information(RESULT proc_description QUERY PROCESSOR_DESCRIPTION)