diff --git a/test_install/CMakeLists.txt b/test_install/CMakeLists.txt index 13f10f6fa92..0e74a02ca8c 100644 --- a/test_install/CMakeLists.txt +++ b/test_install/CMakeLists.txt @@ -48,7 +48,7 @@ if(GINKGO_BUILD_CUDA) target_compile_options(test_install_cuda PRIVATE "$<$:${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() @@ -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) diff --git a/test_install/test_install.cpp b/test_install/test_install.cpp index 387630fc19d..2ccd9727bce 100644 --- a/test_install/test_install.cpp +++ b/test_install/test_install.cpp @@ -67,14 +67,18 @@ void check_spmv(std::shared_ptr 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)