Skip to content

Commit

Permalink
Merge pull request #250 from ecmwf/fix/cuda_host_compiler
Browse files Browse the repository at this point in the history
Fix for using default CUDA host compiler
  • Loading branch information
wdeconinck authored Dec 17, 2024
2 parents 5319b06 + e1a92f7 commit 85196ae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/atlas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,10 @@ if( HAVE_ACC AND CMAKE_Fortran_COMPILER_ID MATCHES NVHPC )
target_link_options( atlas INTERFACE
$<$<LINK_LANG_AND_ID:C,NVHPC>:SHELL:${ACC_LINK_OPTIONS}>
$<$<LINK_LANG_AND_ID:CXX,NVHPC>:SHELL:${ACC_LINK_OPTIONS}>
$<$<LINK_LANG_AND_ID:Fortran,NVHPC>:SHELL:${ACC_LINK_OPTIONS}>
$<$<LINK_LANG_AND_ID:CUDA,NVIDIA>:SHELL:${ACC_LINK_OPTIONS}> )
$<$<LINK_LANG_AND_ID:Fortran,NVHPC>:SHELL:${ACC_LINK_OPTIONS}> )
# $<$<LINK_LANG_AND_ID:CUDA,NVIDIA>:SHELL:${ACC_LINK_OPTIONS}>
#  This only works when CUDA HOST COMPILER is NVIDIA, by default it is g++ so we cannot rely on this.
# CUDA executables should set LINKER_LANGUAGE to C or CXX instead, which will have ACC_LINK_OPTIONS
endif()

target_compile_features( atlas PUBLIC cxx_std_17 )
9 changes: 5 additions & 4 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ macro( atlas_add_hic_test )
set_source_files_properties(${_PAR_SOURCES} PROPERTIES LANGUAGE HIP)
endif()

ecbuild_add_test( TARGET ${_PAR_TARGET}
SOURCES ${_PAR_SOURCES}
LIBS ${_libs}
ENVIRONMENT ${_PAR_ENVIRONMENT} )
ecbuild_add_test( TARGET ${_PAR_TARGET}
SOURCES ${_PAR_SOURCES}
LIBS ${_libs}
LINKER_LANGUAGE CXX
ENVIRONMENT ${_PAR_ENVIRONMENT} )
set_tests_properties(${_PAR_TARGET} PROPERTIES LABELS "gpu")

endif()
Expand Down
6 changes: 3 additions & 3 deletions src/tests/linalg/test_linalg_sparse_matrix_gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ void check_matrix(const SparseMatrixStorage& m) {
std::vector<Index> host_inner(host_matrix_view.inner_size());
std::vector<Value> host_value(host_matrix_view.value_size());

hicMemcpy(host_outer.data(), device_matrix_view.outer(), device_matrix_view.outer_size() * sizeof(Index), hicMemcpyDeviceToHost);
hicMemcpy(host_inner.data(), device_matrix_view.inner(), device_matrix_view.inner_size() * sizeof(Index), hicMemcpyDeviceToHost);
hicMemcpy(host_value.data(), device_matrix_view.value(), device_matrix_view.value_size() * sizeof(Value), hicMemcpyDeviceToHost);
HIC_CALL(hicMemcpy(host_outer.data(), device_matrix_view.outer(), device_matrix_view.outer_size() * sizeof(Index), hicMemcpyDeviceToHost));
HIC_CALL(hicMemcpy(host_inner.data(), device_matrix_view.inner(), device_matrix_view.inner_size() * sizeof(Index), hicMemcpyDeviceToHost));
HIC_CALL(hicMemcpy(host_value.data(), device_matrix_view.value(), device_matrix_view.value_size() * sizeof(Value), hicMemcpyDeviceToHost));

EXPECT(host_outer == expected_outer);
EXPECT(host_inner == expected_inner);
Expand Down

0 comments on commit 85196ae

Please sign in to comment.