Skip to content

Commit

Permalink
Review updates.
Browse files Browse the repository at this point in the history
Co-authored-by: Yuhsiang Tsai <yhmtsai@gmail.com>
  • Loading branch information
tcojean and yhmtsai committed Apr 8, 2021
1 parent 0918001 commit cf34d72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test_install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if(GINKGO_BUILD_CUDA)
target_compile_options(test_install_cuda
PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:${GINKGO_CUDA_ARCH_FLAGS}>")
target_compile_definitions(test_install_cuda PRIVATE HAS_CUDA=1)
target_compile_definitions(test_install_cuda PRIVATE HAS_REFERENCE=1)
target_compile_definitions(test_install_cuda PRIVATE HAS_REFERENCE=${HAS_REFERENCE})
target_link_libraries(test_install_cuda PRIVATE Ginkgo::ginkgo)
endif()

Expand All @@ -71,7 +71,7 @@ if(GINKGO_BUILD_HIP)

target_link_libraries(test_install_hip PRIVATE Ginkgo::ginkgo)
target_compile_definitions(test_install_hip PRIVATE HAS_HIP=1)
target_compile_definitions(test_install_hip PRIVATE HAS_REFERENCE=1)
target_compile_definitions(test_install_hip PRIVATE HAS_REFERENCE=${HAS_REFERENCE})

# If we always link with CXX there is no RPATH issue
set_target_properties(test_install_hip PROPERTIES LINKER_LANGUAGE CXX)
Expand Down
4 changes: 4 additions & 0 deletions test_install/test_install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,18 @@ void check_spmv(std::shared_ptr<gko::Executor> exec,
auto x_clone = gko::clone(x);
test->read(A_raw);
test->apply(b, gko::lend(x_clone));
// x_clone has the device result if using HIP or CUDA, otherwise it is
// reference only

#if defined(HAS_HIP) || defined(HAS_CUDA)
// If we are on a device, we need to run a reference test to compare against
auto exec_ref = exec->get_master();
auto test_ref = Mtx::create(exec_ref);
auto x_ref = gko::clone(exec_ref, x);
test_ref->read(A_raw);
test_ref->apply(b, gko::lend(x_ref));

// Actually check that `x_clone` is similar to `x_ref`
auto x_clone_ref = gko::clone(exec_ref, gko::lend(x_clone));
assert_similar_matrices(gko::lend(x_clone_ref), gko::lend(x_ref), 1e-14);
#endif // defined(HAS_HIP) || defined(HAS_CUDA)
Expand Down

0 comments on commit cf34d72

Please sign in to comment.