Skip to content

Commit

Permalink
Refactor Loki/GPU build options
Browse files Browse the repository at this point in the history
  • Loading branch information
awnawab committed Mar 25, 2024
1 parent c9627b1 commit e7d18af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 14 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ecbuild_find_package( NAME loki )
ecwam_find_python_mods()
ecbuild_add_option( FEATURE GEN_DERIV_TYPES
DEFAULT ON
DESCRIPTION "Generate derived-type data structures using fypp pre-processor"
DESCRIPTION "Generate derived-type data structures using fypp pre-processor and yaml config"
CONDITION FYPP_FOUND AND PYYAML_FOUND )

### Set third party libraries
Expand All @@ -108,28 +108,27 @@ if( HAVE_OMP )
set( OpenMP_Fortran_LIBRARIES OpenMP::OpenMP_Fortran )
endif()

### Apply Loki source-to-source transformations to the ecWam physics
ecbuild_add_option( FEATURE WAM_LOKI
DEFAULT OFF
DESCRIPTION "Apply Loki transformations to ecWam physics"
CONDITION loki_FOUND )

# Determine Loki transformation type
if( NOT DEFINED LOKI_MODE )
set( LOKI_MODE "scc-stack" CACHE STRING "Transformation mode for Loki source transformations" )
endif()

# Workaround for the fact that CMake only sets language components to FOUND,
# so OpenACC_FOUND must be set manually
find_package( OpenACC )
if( OpenACC_Fortran_FOUND AND OpenACC_C_FOUND )
set( OpenACC_FOUND ON )
endif()
ecbuild_add_option( FEATURE ACC
DESCRIPTION "OpenACC" DEFAULT ON
DESCRIPTION "OpenACC" DEFAULT OFF
REQUIRED_PACKAGES "OpenACC"
CONDITION CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC" )

### Apply Loki source-to-source transformations to the ecWam physics
ecbuild_add_option( FEATURE WAM_LOKI
DEFAULT OFF
DESCRIPTION "Apply Loki transformations to ecWam physics"
CONDITION HAVE_LOKI )

### Apply Loki source-to-source transformations to the ecWam physics with GPU offload
ecbuild_add_option( FEATURE WAM_LOKI_GPU
DEFAULT OFF
DESCRIPTION "Apply Loki transformations to ecWam physics with GPU offload"
CONDITION HAVE_ACC AND field_api_FOUND AND HAVE_LOKI )
CONDITION HAVE_WAM_LOKI AND NOT LOKI_MODE MATCHES "idem|idem-stack" AND HAVE_GEN_DERIV_TYPES )

### Sources

Expand Down
2 changes: 1 addition & 1 deletion src/ecwam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ if( HAVE_WAM_LOKI )
set( LOKI_FRONTEND "fp" CACHE STRING "Frontend parser for Loki source transformations" )
set( SCC_ARGS "")

if( ${LOKI_DEBUG} )
if( LOKI_MODE MATCHES "idem|idem-stack" )
set( LOKI_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecwam_loki.config )
else()
set( LOKI_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecwam_loki_gpu.config )
Expand Down

0 comments on commit e7d18af

Please sign in to comment.