Skip to content

Commit

Permalink
CMake: Only search for OpenACC if the corresponding option is active (#…
Browse files Browse the repository at this point in the history
…31)

* CMake: Only search for OpenACC if the corresponding option is active

* Do not require OpenACC_C
  • Loading branch information
reuterbal authored Sep 24, 2024
1 parent 59bfa01 commit 2a9135a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if( NOT DEFINED OCEAN_PREC )
endif()
string( TOLOWER "${OCEAN_PREC}" ocean_prec )

ecbuild_add_option( FEATURE OCEAN_COUPLING
ecbuild_add_option( FEATURE OCEAN_COUPLING
DEFAULT ON
DESCRIPTION "Support ocean coupling"
REQUIRED_PACKAGES "nemo_${ocean_prec}" )
Expand Down Expand Up @@ -113,7 +113,8 @@ ecbuild_add_option( FEATURE LOKI
set( LOKI_MODE "scc-hoist" CACHE STRING "Transformation mode for Loki source transformations" )

### OpenACC
if( ${CMAKE_VERSION} VERSION_LESS "3.25" AND (NOT DEFINED ENABLE_ACC OR ENABLE_ACC ) )
if( ${CMAKE_VERSION} VERSION_LESS "3.25" AND HAVE_LOKI AND NOT LOKI_MODE MATCHES "idem|idem-stack" )
if ( ${PNAME}_ENABLE_ACC OR (NOT DEFINED ${PNAME}_ENABLE_ACC AND ENABLE_ACC) )
# Incredibly inconvenient: FindOpenACC does _not_ set OpenACC_FOUND, only
# the language-specific components OpenACC_Fortran_FOUND and OpenACC_C_FOUND.
# This means, even internally CMake considers OpenACC as not found.
Expand All @@ -124,19 +125,20 @@ if( ${CMAKE_VERSION} VERSION_LESS "3.25" AND (NOT DEFINED ENABLE_ACC OR ENABLE_A
# and rectifies CMake's internal bookkeeping in the process.
# This has been fixed in CMake 3.25
find_package( OpenACC )
if( OpenACC_Fortran_FOUND AND OpenACC_C_FOUND )
if( OpenACC_Fortran_FOUND )
set( OpenACC_FOUND ON )
endif()
endif()
endif()
ecbuild_add_option( FEATURE ACC
DESCRIPTION "OpenACC" DEFAULT OFF
REQUIRED_PACKAGES "OpenACC"
REQUIRED_PACKAGES "OpenACC COMPONENTS Fortran"
CONDITION HAVE_LOKI AND NOT LOKI_MODE MATCHES "idem|idem-stack" )

### CUDA-aware MPI
ecbuild_add_option( FEATURE GPU_AWARE_MPI
DEFAULT OFF
DESCRIPTION "Enable GPU-aware MPI"
DESCRIPTION "Enable GPU-aware MPI"
CONDITION HAVE_ACC AND MPI_Fortran_HAVE_F08_MODULE )

### Sources
Expand All @@ -161,4 +163,3 @@ add_subdirectory(doc)
ecbuild_install_project( NAME ${PROJECT_NAME} )

ecbuild_print_summary()

0 comments on commit 2a9135a

Please sign in to comment.