Skip to content

Commit

Permalink
Merge pull request #62 from ecmwf-ifs/naan-acc-link-fix
Browse files Browse the repository at this point in the history
Fix propagation of ACC link flags
  • Loading branch information
awnawab authored Oct 9, 2024
2 parents 4a53eb9 + c2d86d2 commit 20a401c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ foreach(prec ${precisions})
TARGET ${LIBNAME}_${prec}
SOURCES ${prec_srcs} $<TARGET_OBJECTS:${LIBNAME}>
DEFINITIONS $<$<NOT:${fiat_FOUND}>:${FIELD_API_DEFINITIONS}>
INTERFACE_LIBS
$<${HAVE_ACC}:OpenACC::OpenACC_Fortran>
PRIVATE_LIBS
$<${fiat_FOUND}:fiat>
$<${fiat_FOUND}:parkind_${prec}>
Expand All @@ -215,6 +213,10 @@ foreach(prec ${precisions})
set_target_properties( ${LIBNAME}_${prec} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include/${LIBNAME}_${prec} )
target_link_options( ${LIBNAME}_${prec} PUBLIC $<${HAVE_CUDA}:-cuda> )

if( HAVE_ACC AND CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC")
target_link_options( ${LIBNAME}_${prec} INTERFACE SHELL:${OpenACC_Fortran_FLAGS} )
endif()

# export target usage interface
target_include_directories( ${LIBNAME}_${prec}
INTERFACE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include/${LIBNAME}_${prec}>
Expand Down
7 changes: 2 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ecbuild_add_test(
$<${HAVE_ACC}:OpenACC::OpenACC_Fortran>
LINKER_LANGUAGE Fortran
)
target_link_options( main.x PRIVATE $<${HAVE_CUDA}:-cuda;-gpu=pinned> )
target_link_options( main.x PRIVATE $<${HAVE_CUDA}:-gpu=pinned> )
target_compile_definitions( main.x PRIVATE $<${HAVE_CUDA}:_CUDA> )

## Unit tests
Expand Down Expand Up @@ -119,7 +119,7 @@ foreach(TEST_FILE ${TEST_FILES})
PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include/tests
)

target_link_options( ${TEST_NAME}.x PRIVATE $<${HAVE_CUDA}:-cuda;-gpu=pinned> )
target_link_options( ${TEST_NAME}.x PRIVATE $<${HAVE_CUDA}:-gpu=pinned> )
target_compile_definitions( ${TEST_NAME}.x PRIVATE $<${HAVE_CUDA}:_CUDA> )

if( DEFAULT_PRECISION MATCHES sp )
Expand Down Expand Up @@ -167,9 +167,6 @@ ecbuild_add_test(
LINKER_LANGUAGE Fortran
CONDITION ${HAVE_SINGLE_PRECISION}
)
if( HAVE_SINGLE_PRECISION )
target_link_options( init_wrapper_mixed_precision.x PRIVATE $<${HAVE_CUDA}:-cuda> )
endif()

## Test presence of GPUs
add_executable(check_gpu_num.x check_gpu_num.F90)
Expand Down

0 comments on commit 20a401c

Please sign in to comment.