From a02d707991ff6cfce6f71d45d64b6a33b1851131 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Fri, 23 Sep 2022 08:52:10 +0200 Subject: [PATCH] review updates and fixes --- dev_tools/scripts/config | 2 +- omp/test/stop/residual_norm_kernels.cpp | 709 ------------------------ reference/test/matrix/csr_kernels.cpp | 10 +- test/components/prefix_sum_kernels.cpp | 2 +- test/factorization/par_ilu_kernels.cpp | 6 +- test/matrix/csr_kernels2.cpp | 8 +- test/matrix/ell_kernels.cpp | 6 - test/matrix/fbcsr_kernels.cpp | 185 +++---- test/matrix/hybrid_kernels.cpp | 2 +- test/matrix/matrix.cpp | 5 +- test/solver/gmres_kernels.cpp | 5 +- test/solver/multigrid_kernels.cpp | 33 +- 12 files changed, 108 insertions(+), 865 deletions(-) delete mode 100644 omp/test/stop/residual_norm_kernels.cpp diff --git a/dev_tools/scripts/config b/dev_tools/scripts/config index 8eb0bfd1667..0ebaa462bc4 100644 --- a/dev_tools/scripts/config +++ b/dev_tools/scripts/config @@ -39,7 +39,7 @@ - PathPrefix: "ginkgo/core" - PathIgnore: "0" - RemoveTest: "true" -- "^test/matric/csr_kernels2.cpp" +- "^test/matrix/csr_kernels2.cpp" - CoreSuffix: "_kernels2" - PathPrefix: "ginkgo/core" - PathIgnore: "0" diff --git a/omp/test/stop/residual_norm_kernels.cpp b/omp/test/stop/residual_norm_kernels.cpp deleted file mode 100644 index 938b0951737..00000000000 --- a/omp/test/stop/residual_norm_kernels.cpp +++ /dev/null @@ -1,709 +0,0 @@ -/************************************************************* -Copyright (c) 2017-2022, the Ginkgo authors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*************************************************************/ - -#include - - -#include - - -#include - - -#include "core/test/utils.hpp" - - -namespace { - - -template -class ResidualNorm : public ::testing::Test { -protected: - using Mtx = gko::matrix::Dense; - using NormVector = gko::matrix::Dense>; - - ResidualNorm() - { - exec = gko::OmpExecutor::create(); - factory = gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec); - rel_factory = gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .with_baseline(gko::stop::mode::initial_resnorm) - .on(exec); - abs_factory = gko::stop::ResidualNorm::build() - .with_reduction_factor(r::value) - .with_baseline(gko::stop::mode::absolute) - .on(exec); - } - - std::unique_ptr::Factory> factory; - std::unique_ptr::Factory> rel_factory; - std::unique_ptr::Factory> abs_factory; - std::shared_ptr exec; -}; - -TYPED_TEST_SUITE(ResidualNorm, gko::test::ValueTypes, TypenameNameGenerator); - - -TYPED_TEST(ResidualNorm, WaitsTillResidualGoal) -{ - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - auto initial_res = gko::initialize({100.0}, this->exec); - std::shared_ptr rhs = gko::initialize({10.0}, this->exec); - auto criterion = - this->factory->generate(nullptr, rhs, nullptr, initial_res.get()); - auto rel_criterion = - this->rel_factory->generate(nullptr, rhs, nullptr, initial_res.get()); - auto abs_criterion = - this->abs_factory->generate(nullptr, rhs, nullptr, initial_res.get()); - { - auto res_norm = gko::initialize({10.0}, this->exec); - auto rhs_norm = gko::initialize({100.0}, this->exec); - gko::as(rhs)->compute_norm2(rhs_norm.get()); - constexpr gko::uint8 RelativeStoppingId{1}; - bool one_changed{}; - gko::array stop_status(this->exec, 1); - stop_status.get_data()[0].reset(); - - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0) = r::value * 1.1 * res_norm->at(0); - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_FALSE(stop_status.get_data()[0].has_converged()); - ASSERT_FALSE(one_changed); - - res_norm->at(0) = r::value * 0.9 * res_norm->at(0); - ASSERT_TRUE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - } - { - auto res_norm = gko::initialize({100.0}, this->exec); - constexpr gko::uint8 RelativeStoppingId{1}; - bool one_changed{}; - gko::array stop_status(this->exec, 1); - stop_status.get_data()[0].reset(); - - ASSERT_FALSE( - rel_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0) = r::value * 1.1 * res_norm->at(0); - ASSERT_FALSE( - rel_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_FALSE(stop_status.get_data()[0].has_converged()); - ASSERT_FALSE(one_changed); - - res_norm->at(0) = r::value * 0.9 * res_norm->at(0); - ASSERT_TRUE( - rel_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - } - { - auto res_norm = gko::initialize({100.0}, this->exec); - constexpr gko::uint8 RelativeStoppingId{1}; - bool one_changed{}; - gko::array stop_status(this->exec, 1); - stop_status.get_data()[0].reset(); - - ASSERT_FALSE( - abs_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0) = r::value * 1.1; - ASSERT_FALSE( - abs_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_FALSE(stop_status.get_data()[0].has_converged()); - ASSERT_FALSE(one_changed); - - res_norm->at(0) = r::value * 0.9; - ASSERT_TRUE( - abs_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - } -} - - -TYPED_TEST(ResidualNorm, WaitsTillResidualGoalMultipleRHS) -{ - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - using T = TypeParam; - using T_nc = gko::remove_complex; - auto res = gko::initialize({I{100.0, 100.0}}, this->exec); - std::shared_ptr rhs = - gko::initialize({I{10.0, 10.0}}, this->exec); - auto criterion = this->factory->generate(nullptr, rhs, nullptr, res.get()); - auto rel_criterion = - this->rel_factory->generate(nullptr, rhs, nullptr, res.get()); - auto abs_criterion = - this->abs_factory->generate(nullptr, rhs, nullptr, res.get()); - { - auto res_norm = - gko::initialize({I{100.0, 100.0}}, this->exec); - auto rhs_norm = - gko::initialize({I{100.0, 100.0}}, this->exec); - gko::as(rhs)->compute_norm2(rhs_norm.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 2); - stop_status.get_data()[0].reset(); - stop_status.get_data()[1].reset(); - - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0, 0) = r::value * 0.9 * rhs_norm->at(0, 0); - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - - res_norm->at(0, 1) = r::value * 0.9 * rhs_norm->at(0, 1); - ASSERT_TRUE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[1].has_converged()); - ASSERT_TRUE(one_changed); - } - { - auto res_norm = - gko::initialize({I{100.0, 100.0}}, this->exec); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 2); - stop_status.get_data()[0].reset(); - stop_status.get_data()[1].reset(); - - ASSERT_FALSE( - rel_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0, 0) = r::value * 0.9 * res_norm->at(0, 0); - ASSERT_FALSE( - rel_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - - res_norm->at(0, 1) = r::value * 0.9 * res_norm->at(0, 1); - ASSERT_TRUE( - rel_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[1].has_converged()); - ASSERT_TRUE(one_changed); - } - { - auto res_norm = - gko::initialize({I{100.0, 100.0}}, this->exec); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 2); - stop_status.get_data()[0].reset(); - stop_status.get_data()[1].reset(); - - ASSERT_FALSE( - abs_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0, 0) = r::value * 0.9; - ASSERT_FALSE( - abs_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - - res_norm->at(0, 1) = r::value * 0.9; - ASSERT_TRUE( - abs_criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[1].has_converged()); - ASSERT_TRUE(one_changed); - } -} - - -template -class ResidualNormWithInitialResnorm : public ::testing::Test { -protected: - using Mtx = gko::matrix::Dense; - using NormVector = gko::matrix::Dense>; - - ResidualNormWithInitialResnorm() - { - exec = gko::OmpExecutor::create(); - factory = gko::stop::ResidualNorm::build() - .with_baseline(gko::stop::mode::initial_resnorm) - .with_reduction_factor(r::value) - .on(exec); - } - - std::unique_ptr::Factory> factory; - std::shared_ptr exec; -}; - -TYPED_TEST_SUITE(ResidualNormWithInitialResnorm, gko::test::ValueTypes, - TypenameNameGenerator); - - -TYPED_TEST(ResidualNormWithInitialResnorm, WaitsTillResidualGoal) -{ - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - auto initial_res = gko::initialize({100.0}, this->exec); - std::shared_ptr rhs = gko::initialize({10.0}, this->exec); - auto res_norm = gko::initialize({100.0}, this->exec); - auto criterion = - this->factory->generate(nullptr, rhs, nullptr, initial_res.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 1); - stop_status.get_data()[0].reset(); - - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0) = r::value * 1.1 * res_norm->at(0); - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_FALSE(stop_status.get_data()[0].has_converged()); - ASSERT_FALSE(one_changed); - - res_norm->at(0) = r::value * 0.9 * res_norm->at(0); - ASSERT_TRUE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); -} - - -TYPED_TEST(ResidualNormWithInitialResnorm, WaitsTillResidualGoalMultipleRHS) -{ - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - using T = TypeParam; - using T_nc = gko::remove_complex; - auto res = gko::initialize({I{100.0, 100.0}}, this->exec); - auto res_norm = - gko::initialize({I{100.0, 100.0}}, this->exec); - std::shared_ptr rhs = - gko::initialize({I{10.0, 10.0}}, this->exec); - auto criterion = this->factory->generate(nullptr, rhs, nullptr, res.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 2); - stop_status.get_data()[0].reset(); - stop_status.get_data()[1].reset(); - - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0, 0) = r::value * 0.9 * res_norm->at(0, 0); - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - - res_norm->at(0, 1) = r::value * 0.9 * res_norm->at(0, 1); - ASSERT_TRUE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[1].has_converged()); - ASSERT_TRUE(one_changed); -} - - -template -class ResidualNormWithRhsNorm : public ::testing::Test { -protected: - using Mtx = gko::matrix::Dense; - using NormVector = gko::matrix::Dense>; - - ResidualNormWithRhsNorm() - { - exec = gko::OmpExecutor::create(); - factory = gko::stop::ResidualNorm::build() - .with_baseline(gko::stop::mode::rhs_norm) - .with_reduction_factor(r::value) - .on(exec); - } - - std::unique_ptr::Factory> factory; - std::shared_ptr exec; -}; - -TYPED_TEST_SUITE(ResidualNormWithRhsNorm, gko::test::ValueTypes, - TypenameNameGenerator); - - -TYPED_TEST(ResidualNormWithRhsNorm, WaitsTillResidualGoal) -{ - using T = TypeParam; - using T_nc = gko::remove_complex; - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - auto initial_res = gko::initialize({100.0}, this->exec); - std::shared_ptr rhs = gko::initialize({10.0}, this->exec); - auto rhs_norm = gko::initialize({I{0.0}}, this->exec); - gko::as(rhs)->compute_norm2(rhs_norm.get()); - auto res_norm = gko::initialize({100.0}, this->exec); - auto criterion = - this->factory->generate(nullptr, rhs, nullptr, initial_res.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 1); - stop_status.get_data()[0].reset(); - - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0) = r::value * 1.1 * rhs_norm->at(0); - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_FALSE(stop_status.get_data()[0].has_converged()); - ASSERT_FALSE(one_changed); - - res_norm->at(0) = r::value * 0.9 * rhs_norm->at(0); - ASSERT_TRUE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); -} - - -TYPED_TEST(ResidualNormWithRhsNorm, WaitsTillResidualGoalMultipleRHS) -{ - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - using T = TypeParam; - using T_nc = gko::remove_complex; - auto res = gko::initialize({I{100.0, 100.0}}, this->exec); - auto res_norm = - gko::initialize({I{100.0, 100.0}}, this->exec); - std::shared_ptr rhs = - gko::initialize({I{10.0, 10.0}}, this->exec); - auto rhs_norm = - gko::initialize({I{0.0, 0.0}}, this->exec); - gko::as(rhs)->compute_norm2(rhs_norm.get()); - auto criterion = this->factory->generate(nullptr, rhs, nullptr, res.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 2); - stop_status.get_data()[0].reset(); - stop_status.get_data()[1].reset(); - - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0, 0) = r::value * 0.9 * rhs_norm->at(0, 0); - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - - res_norm->at(0, 1) = r::value * 0.9 * rhs_norm->at(0, 1); - ASSERT_TRUE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[1].has_converged()); - ASSERT_TRUE(one_changed); -} - - -template -class ImplicitResidualNorm : public ::testing::Test { -protected: - using Mtx = gko::matrix::Dense; - using NormVector = gko::matrix::Dense>; - - ImplicitResidualNorm() - { - exec = gko::OmpExecutor::create(); - factory = gko::stop::ImplicitResidualNorm::build() - .with_reduction_factor(r::value) - .on(exec); - } - - std::unique_ptr::Factory> - factory; - std::shared_ptr exec; -}; - -TYPED_TEST_SUITE(ImplicitResidualNorm, gko::test::ValueTypes, - TypenameNameGenerator); - - -TYPED_TEST(ImplicitResidualNorm, WaitsTillResidualGoal) -{ - using T = TypeParam; - using T_nc = gko::remove_complex; - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - auto initial_res = gko::initialize({100.0}, this->exec); - std::shared_ptr rhs = gko::initialize({10.0}, this->exec); - auto res_norm = gko::initialize({100.0}, this->exec); - auto rhs_norm = gko::initialize({I{0.0}}, this->exec); - gko::as(rhs)->compute_norm2(rhs_norm.get()); - auto criterion = - this->factory->generate(nullptr, rhs, nullptr, initial_res.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 1); - stop_status.get_data()[0].reset(); - - ASSERT_FALSE( - criterion->update() - .implicit_sq_residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0) = std::pow(r::value * 1.1 * rhs_norm->at(0), 2); - ASSERT_FALSE( - criterion->update() - .implicit_sq_residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_FALSE(stop_status.get_data()[0].has_converged()); - ASSERT_FALSE(one_changed); - - res_norm->at(0) = std::pow(r::value * 0.9 * rhs_norm->at(0), 2); - ASSERT_TRUE( - criterion->update() - .implicit_sq_residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); -} - - -TYPED_TEST(ImplicitResidualNorm, WaitsTillResidualGoalMultipleRHS) -{ - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - using T = TypeParam; - using T_nc = gko::remove_complex; - auto res = gko::initialize({I{100.0, 100.0}}, this->exec); - auto res_norm = gko::initialize({I{100.0, 100.0}}, this->exec); - std::shared_ptr rhs = - gko::initialize({I{10.0, 10.0}}, this->exec); - auto rhs_norm = - gko::initialize({I{0.0, 0.0}}, this->exec); - gko::as(rhs)->compute_norm2(rhs_norm.get()); - auto criterion = this->factory->generate(nullptr, rhs, nullptr, res.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 2); - stop_status.get_data()[0].reset(); - stop_status.get_data()[1].reset(); - - ASSERT_FALSE( - criterion->update() - .implicit_sq_residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0, 0) = - std::pow(r::value * 0.9 * rhs_norm->at(0, 0), 2); - ASSERT_FALSE( - criterion->update() - .implicit_sq_residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - - res_norm->at(0, 1) = - std::pow(r::value * 0.9 * rhs_norm->at(0, 1), 2); - ASSERT_TRUE( - criterion->update() - .implicit_sq_residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[1].has_converged()); - ASSERT_TRUE(one_changed); -} - - -template -class ResidualNormWithAbsolute : public ::testing::Test { -protected: - using Mtx = gko::matrix::Dense; - using NormVector = gko::matrix::Dense>; - - ResidualNormWithAbsolute() - { - exec = gko::OmpExecutor::create(); - factory = gko::stop::ResidualNorm::build() - .with_baseline(gko::stop::mode::absolute) - .with_reduction_factor(r::value) - .on(exec); - } - - std::unique_ptr::Factory> factory; - std::shared_ptr exec; -}; - -TYPED_TEST_SUITE(ResidualNormWithAbsolute, gko::test::ValueTypes, - TypenameNameGenerator); - - -TYPED_TEST(ResidualNormWithAbsolute, WaitsTillResidualGoal) -{ - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - auto initial_res = gko::initialize({100.0}, this->exec); - std::shared_ptr rhs = gko::initialize({10.0}, this->exec); - auto res_norm = gko::initialize({100.0}, this->exec); - auto criterion = - this->factory->generate(nullptr, rhs, nullptr, initial_res.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 1); - stop_status.get_data()[0].reset(); - - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0) = r::value * 1.1; - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_FALSE(stop_status.get_data()[0].has_converged()); - ASSERT_FALSE(one_changed); - - res_norm->at(0) = r::value * 0.9; - ASSERT_TRUE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); -} - - -TYPED_TEST(ResidualNormWithAbsolute, WaitsTillResidualGoalMultipleRHS) -{ - using Mtx = typename TestFixture::Mtx; - using NormVector = typename TestFixture::NormVector; - using T = TypeParam; - using T_nc = gko::remove_complex; - auto res = gko::initialize({I{100.0, 100.0}}, this->exec); - auto res_norm = - gko::initialize({I{100.0, 100.0}}, this->exec); - std::shared_ptr rhs = - gko::initialize({I{10.0, 10.0}}, this->exec); - auto criterion = this->factory->generate(nullptr, rhs, nullptr, res.get()); - bool one_changed{}; - constexpr gko::uint8 RelativeStoppingId{1}; - gko::array stop_status(this->exec, 2); - stop_status.get_data()[0].reset(); - stop_status.get_data()[1].reset(); - - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - - res_norm->at(0, 0) = r::value * 0.9; - ASSERT_FALSE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[0].has_converged()); - ASSERT_TRUE(one_changed); - - res_norm->at(0, 1) = r::value * 0.9; - ASSERT_TRUE( - criterion->update() - .residual_norm(res_norm.get()) - .check(RelativeStoppingId, true, &stop_status, &one_changed)); - ASSERT_TRUE(stop_status.get_data()[1].has_converged()); - ASSERT_TRUE(one_changed); -} - - -} // namespace diff --git a/reference/test/matrix/csr_kernels.cpp b/reference/test/matrix/csr_kernels.cpp index f7899cf7c89..6fdc543b132 100644 --- a/reference/test/matrix/csr_kernels.cpp +++ b/reference/test/matrix/csr_kernels.cpp @@ -600,8 +600,9 @@ TYPED_TEST(Csr, ConvertsToPrecision) tmp->convert_to(res.get()); GKO_ASSERT_MTX_NEAR(this->mtx2, res, residual); - ASSERT_EQ(typeid(*this->mtx2->get_strategy()), - typeid(*res->get_strategy())); + auto first_strategy = this->mtx2->get_strategy(); + auto second_strategy = res->get_strategy(); + ASSERT_EQ(typeid(*first_strategy), typeid(*second_strategy)); } @@ -624,8 +625,9 @@ TYPED_TEST(Csr, MovesToPrecision) tmp->move_to(res.get()); GKO_ASSERT_MTX_NEAR(this->mtx2, res, residual); - ASSERT_EQ(typeid(*this->mtx2->get_strategy()), - typeid(*res->get_strategy())); + auto first_strategy = this->mtx2->get_strategy(); + auto second_strategy = res->get_strategy(); + ASSERT_EQ(typeid(*first_strategy), typeid(*second_strategy)); } diff --git a/test/components/prefix_sum_kernels.cpp b/test/components/prefix_sum_kernels.cpp index 6a54c851edb..7b21f31f1cb 100644 --- a/test/components/prefix_sum_kernels.cpp +++ b/test/components/prefix_sum_kernels.cpp @@ -86,7 +86,7 @@ TYPED_TEST(PrefixSum, EqualsReference) { using gko::size_type; for (auto size : - {size_type{0}, size_type{1}, size_type{100}, this->total_size}) { + {size_type{0}, size_type{1}, size_type{131}, this->total_size}) { SCOPED_TRACE(size); gko::kernels::reference::components::prefix_sum( this->ref, this->vals.get_data(), size); diff --git a/test/factorization/par_ilu_kernels.cpp b/test/factorization/par_ilu_kernels.cpp index f7e4fb12845..d422452d5e2 100644 --- a/test/factorization/par_ilu_kernels.cpp +++ b/test/factorization/par_ilu_kernels.cpp @@ -76,12 +76,10 @@ class ParIlu : public CommonTestFixture { std::string file_name(gko::matrices::location_ani4_mtx); auto input_file = std::ifstream(file_name, std::ios::in); auto mtx_temp = gko::read(input_file, ref); - auto dmtx_temp = gko::clone(exec, mtx_temp); // Make sure there are diagonal elements present gko::kernels::reference::factorization::add_diagonal_elements( ref, mtx_temp.get(), false); - gko::kernels::EXEC_NAMESPACE::factorization::add_diagonal_elements( - exec, dmtx_temp.get(), false); + auto dmtx_temp = gko::clone(exec, mtx_temp); mtx = gko::give(mtx_temp); dmtx = gko::give(dmtx_temp); } @@ -143,7 +141,7 @@ class ParIlu : public CommonTestFixture { initialize_row_ptrs(l_row_ptrs.get_data(), u_row_ptrs.get_data(), dl_row_ptrs.get_data(), du_row_ptrs.get_data()); // Since `initialize_row_ptrs` was already tested, it is expected that - // `*` and `*d` contain identical values + // `*` and `d*` contain identical values auto l_nnz = l_row_ptrs.get_const_data()[num_row_ptrs - 1]; auto u_nnz = u_row_ptrs.get_const_data()[num_row_ptrs - 1]; diff --git a/test/matrix/csr_kernels2.cpp b/test/matrix/csr_kernels2.cpp index 97a2a69744c..86023257129 100644 --- a/test/matrix/csr_kernels2.cpp +++ b/test/matrix/csr_kernels2.cpp @@ -556,6 +556,10 @@ TEST_F(Csr, SimpleApplySparseToSparseCsrMatrixIsEquivalentToRef) } +// TODO: broken in ROCm <= 4.5 +#ifndef GKO_COMPILING_HIP + + TEST_F(Csr, SimpleApplyToEmptyCsrMatrixIsEquivalentToRef) { set_up_apply_data(); @@ -573,6 +577,9 @@ TEST_F(Csr, SimpleApplyToEmptyCsrMatrixIsEquivalentToRef) } +#endif + + TEST_F(Csr, AdvancedApplyToIdentityMatrixIsEquivalentToRef) { set_up_apply_data(); @@ -1223,7 +1230,6 @@ TEST_F(Csr, CanDetectMissingDiagonalEntry) TEST_F(Csr, CanDetectWhenAllDiagonalEntriesArePresent) { - using T = double; using Csr = Mtx; auto ref_mtx = gen_mtx(103, 98, 10); gko::utils::ensure_all_diagonal_entries(ref_mtx.get()); diff --git a/test/matrix/ell_kernels.cpp b/test/matrix/ell_kernels.cpp index 401a1ff5e16..384221a62c4 100644 --- a/test/matrix/ell_kernels.cpp +++ b/test/matrix/ell_kernels.cpp @@ -412,9 +412,6 @@ TEST_F(Ell, MixedAdvancedApplyWithStrideToDenseMatrixIsEquivalentToRef3) } -#ifndef GKO_COMPILING_OMP - - TEST_F(Ell, SimpleApplyByAtomicIsEquivalentToRef) { set_up_apply_data(10, 10000); @@ -459,9 +456,6 @@ TEST_F(Ell, AdvancedByAtomicToDenseMatrixApplyIsEquivalentToRef) } -#endif // !defined(GKO_COMPILING_OMP) - - TEST_F(Ell, SimpleApplyOnSmallMatrixIsEquivalentToRef) { set_up_apply_data(1, 10); diff --git a/test/matrix/fbcsr_kernels.cpp b/test/matrix/fbcsr_kernels.cpp index eb99f309ea3..d6f156653b8 100644 --- a/test/matrix/fbcsr_kernels.cpp +++ b/test/matrix/fbcsr_kernels.cpp @@ -119,18 +119,13 @@ TYPED_TEST(Fbcsr, TransposeIsEquivalentToRefSortedBS3) using Mtx = typename TestFixture::Mtx; using value_type = typename Mtx::value_type; using index_type = typename Mtx::index_type; - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); - auto trans_ref_linop = this->rsorted->transpose(); - std::unique_ptr trans_ref = - gko::as(std::move(trans_ref_linop)); + auto drand = gko::clone(this->exec, this->rsorted); - auto trans_cuda_linop = drand->transpose(); - std::unique_ptr trans_cuda = - gko::as(std::move(trans_cuda_linop)); + auto trans = gko::as(this->rsorted->transpose()); + auto dtrans = gko::as(drand->transpose()); - GKO_ASSERT_MTX_EQ_SPARSITY(trans_ref, trans_cuda); - GKO_ASSERT_MTX_NEAR(trans_ref, trans_cuda, 0.0); + GKO_ASSERT_MTX_EQ_SPARSITY(trans, dtrans); + GKO_ASSERT_MTX_NEAR(trans, dtrans, 0.0); } @@ -148,15 +143,11 @@ TYPED_TEST(Fbcsr, TransposeIsEquivalentToRefSortedBS7) std::default_random_engine(43)); drand->copy_from(gko::lend(rsorted2)); - auto trans_ref_linop = rsorted2->transpose(); - std::unique_ptr trans_ref = - gko::as(std::move(trans_ref_linop)); - auto trans_cuda_linop = drand->transpose(); - std::unique_ptr trans_cuda = - gko::as(std::move(trans_cuda_linop)); + auto trans = gko::as(rsorted2->transpose()); + auto dtrans = gko::as(drand->transpose()); - GKO_ASSERT_MTX_EQ_SPARSITY(trans_ref, trans_cuda); - GKO_ASSERT_MTX_NEAR(trans_ref, trans_cuda, 0.0); + GKO_ASSERT_MTX_EQ_SPARSITY(trans, dtrans); + GKO_ASSERT_MTX_NEAR(trans, dtrans, 0.0); } @@ -165,22 +156,20 @@ TYPED_TEST(Fbcsr, SpmvIsEquivalentToRefSorted) using Mtx = typename TestFixture::Mtx; using Dense = typename TestFixture::Dense; using value_type = typename Mtx::value_type; - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); - auto x_ref = + auto drand = gko::clone(this->exec, this->rsorted); + auto x = Dense::create(this->ref, gko::dim<2>(this->rsorted->get_size()[1], 1)); - this->generate_sin(x_ref.get()); - auto x_cuda = Dense::create(this->exec); - x_cuda->copy_from(x_ref.get()); - auto prod_ref = + this->generate_sin(x.get()); + auto dx = gko::clone(this->exec, x); + auto prod = Dense::create(this->ref, gko::dim<2>(this->rsorted->get_size()[0], 1)); - auto prod_cuda = Dense::create(this->exec, prod_ref->get_size()); + auto dprod = Dense::create(this->exec, prod->get_size()); - drand->apply(x_cuda.get(), prod_cuda.get()); - this->rsorted->apply(x_ref.get(), prod_ref.get()); + drand->apply(dx.get(), dprod.get()); + this->rsorted->apply(x.get(), prod.get()); const double tol = r::value; - GKO_ASSERT_MTX_NEAR(prod_ref, prod_cuda, 5 * tol); + GKO_ASSERT_MTX_NEAR(prod, dprod, 5 * tol); } @@ -189,22 +178,20 @@ TYPED_TEST(Fbcsr, SpmvMultiIsEquivalentToRefSorted) using Mtx = typename TestFixture::Mtx; using Dense = typename TestFixture::Dense; using value_type = typename Mtx::value_type; - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); - auto x_ref = + auto drand = gko::clone(this->exec, this->rsorted); + auto x = Dense::create(this->ref, gko::dim<2>(this->rsorted->get_size()[1], 3)); - this->generate_sin(x_ref.get()); - auto x_cuda = Dense::create(this->exec); - x_cuda->copy_from(x_ref.get()); - auto prod_ref = + this->generate_sin(x.get()); + auto dx = gko::clone(this->exec, x); + auto prod = Dense::create(this->ref, gko::dim<2>(this->rsorted->get_size()[0], 3)); - auto prod_cuda = Dense::create(this->exec, prod_ref->get_size()); + auto dprod = Dense::create(this->exec, prod->get_size()); - drand->apply(x_cuda.get(), prod_cuda.get()); - this->rsorted->apply(x_ref.get(), prod_ref.get()); + drand->apply(dx.get(), dprod.get()); + this->rsorted->apply(x.get(), prod.get()); const double tol = r::value; - GKO_ASSERT_MTX_NEAR(prod_ref, prod_cuda, 5 * tol); + GKO_ASSERT_MTX_NEAR(prod, dprod, 5 * tol); } @@ -214,34 +201,27 @@ TYPED_TEST(Fbcsr, AdvancedSpmvIsEquivalentToRefSorted) using Dense = typename TestFixture::Dense; using value_type = typename TestFixture::value_type; using real_type = typename TestFixture::real_type; - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); - auto x_ref = + auto drand = gko::clone(this->exec, this->rsorted); + auto x = Dense::create(this->ref, gko::dim<2>(this->rsorted->get_size()[1], 1)); - this->generate_sin(x_ref.get()); - auto x_cuda = Dense::create(this->exec); - x_cuda->copy_from(x_ref.get()); - auto prod_ref = + this->generate_sin(x.get()); + auto dx = gko::clone(this->exec, x); + auto prod = Dense::create(this->ref, gko::dim<2>(this->rsorted->get_size()[0], 1)); - this->generate_sin(prod_ref.get()); - auto prod_cuda = Dense::create(this->exec); - prod_cuda->copy_from(prod_ref.get()); - auto alpha_ref = Dense::create(this->ref, gko::dim<2>(1, 1)); - alpha_ref->get_values()[0] = - static_cast(2.4) + this->get_random_value(); - auto beta_ref = Dense::create(this->ref, gko::dim<2>(1, 1)); - beta_ref->get_values()[0] = -1.2; - auto alpha = Dense::create(this->exec); - alpha->copy_from(alpha_ref.get()); - auto beta = Dense::create(this->exec); - beta->copy_from(beta_ref.get()); - - drand->apply(alpha.get(), x_cuda.get(), beta.get(), prod_cuda.get()); - this->rsorted->apply(alpha_ref.get(), x_ref.get(), beta_ref.get(), - prod_ref.get()); + this->generate_sin(prod.get()); + auto dprod = gko::clone(this->exec, prod); + auto alpha = Dense::create(this->ref, gko::dim<2>(1, 1)); + alpha->at(0, 0) = static_cast(2.4) + this->get_random_value(); + auto beta = Dense::create(this->ref, gko::dim<2>(1, 1)); + beta->at(0, 0) = -1.2; + auto dalpha = gko::clone(this->exec, alpha); + auto dbeta = gko::clone(this->exec, beta); + + drand->apply(dalpha.get(), dx.get(), dbeta.get(), dprod.get()); + this->rsorted->apply(alpha.get(), x.get(), beta.get(), prod.get()); const double tol = r::value; - GKO_ASSERT_MTX_NEAR(prod_ref, prod_cuda, 5 * tol); + GKO_ASSERT_MTX_NEAR(prod, dprod, 5 * tol); } @@ -251,34 +231,27 @@ TYPED_TEST(Fbcsr, AdvancedSpmvMultiIsEquivalentToRefSorted) using Dense = typename TestFixture::Dense; using value_type = typename TestFixture::value_type; using real_type = typename TestFixture::real_type; - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); - auto x_ref = + auto drand = gko::clone(this->exec, this->rsorted); + auto x = Dense::create(this->ref, gko::dim<2>(this->rsorted->get_size()[1], 3)); - this->generate_sin(x_ref.get()); - auto x_cuda = Dense::create(this->exec); - x_cuda->copy_from(x_ref.get()); - auto prod_ref = + this->generate_sin(x.get()); + auto dx = gko::clone(this->exec, x); + auto prod = Dense::create(this->ref, gko::dim<2>(this->rsorted->get_size()[0], 3)); - this->generate_sin(prod_ref.get()); - auto prod_cuda = Dense::create(this->exec); - prod_cuda->copy_from(prod_ref.get()); - auto alpha_ref = Dense::create(this->ref, gko::dim<2>(1, 1)); - alpha_ref->get_values()[0] = - static_cast(2.4) + this->get_random_value(); - auto beta_ref = Dense::create(this->ref, gko::dim<2>(1, 1)); - beta_ref->get_values()[0] = -1.2; - auto alpha = Dense::create(this->exec); - alpha->copy_from(alpha_ref.get()); - auto beta = Dense::create(this->exec); - beta->copy_from(beta_ref.get()); - - drand->apply(alpha.get(), x_cuda.get(), beta.get(), prod_cuda.get()); - this->rsorted->apply(alpha_ref.get(), x_ref.get(), beta_ref.get(), - prod_ref.get()); + this->generate_sin(prod.get()); + auto dprod = gko::clone(this->exec, prod); + auto alpha = Dense::create(this->ref, gko::dim<2>(1, 1)); + alpha->at(0, 0) = static_cast(2.4) + this->get_random_value(); + auto beta = Dense::create(this->ref, gko::dim<2>(1, 1)); + beta->at(0, 0) = -1.2; + auto dalpha = gko::clone(this->exec, alpha); + auto dbeta = gko::clone(this->exec, beta); + + drand->apply(dalpha.get(), dx.get(), dbeta.get(), dprod.get()); + this->rsorted->apply(alpha.get(), x.get(), beta.get(), prod.get()); const double tol = r::value; - GKO_ASSERT_MTX_NEAR(prod_ref, prod_cuda, 5 * tol); + GKO_ASSERT_MTX_NEAR(prod, dprod, 5 * tol); } @@ -287,26 +260,20 @@ TYPED_TEST(Fbcsr, ConjTransposeIsEquivalentToRefSortedBS3) using Mtx = typename TestFixture::Mtx; using value_type = typename Mtx::value_type; using index_type = typename Mtx::index_type; - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); - auto trans_ref_linop = this->rsorted->conj_transpose(); - std::unique_ptr trans_ref = - gko::as(std::move(trans_ref_linop)); + auto drand = gko::clone(this->exec, this->rsorted); - auto trans_cuda_linop = drand->conj_transpose(); - std::unique_ptr trans_cuda = - gko::as(std::move(trans_cuda_linop)); + auto trans = gko::as(this->rsorted->conj_transpose()); + auto dtrans = gko::as(drand->conj_transpose()); - GKO_ASSERT_MTX_EQ_SPARSITY(trans_ref, trans_cuda); - GKO_ASSERT_MTX_NEAR(trans_ref, trans_cuda, 0.0); + GKO_ASSERT_MTX_EQ_SPARSITY(trans, dtrans); + GKO_ASSERT_MTX_NEAR(trans, dtrans, 0.0); } TYPED_TEST(Fbcsr, RecognizeSortedMatrix) { using Mtx = typename TestFixture::Mtx; - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); + auto drand = gko::clone(this->exec, this->rsorted); ASSERT_TRUE(drand->is_sorted_by_column_index()); } @@ -319,10 +286,9 @@ TYPED_TEST(Fbcsr, RecognizeUnsortedMatrix) auto mat = this->rsorted->clone(); index_type* const colinds = mat->get_col_idxs(); std::swap(colinds[0], colinds[1]); - auto unsrt_cuda = Mtx::create(this->exec); - unsrt_cuda->copy_from(gko::lend(mat)); + auto dunsrt = gko::clone(this->exec, mat); - ASSERT_FALSE(unsrt_cuda->is_sorted_by_column_index()); + ASSERT_FALSE(dunsrt->is_sorted_by_column_index()); } @@ -330,16 +296,14 @@ TYPED_TEST(Fbcsr, InplaceAbsoluteMatrixIsEquivalentToRef) { using Mtx = typename TestFixture::Mtx; using value_type = typename Mtx::value_type; - auto rand_ref = Mtx::create(this->ref); - rand_ref->copy_from(this->rsorted.get()); - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); + auto rand = gko::clone(this->ref, this->rsorted); + auto drand = gko::clone(this->exec, this->rsorted); - rand_ref->compute_absolute_inplace(); + rand->compute_absolute_inplace(); drand->compute_absolute_inplace(); const double tol = r::value; - GKO_ASSERT_MTX_NEAR(rand_ref, drand, tol); + GKO_ASSERT_MTX_NEAR(rand, drand, tol); } @@ -347,8 +311,7 @@ TYPED_TEST(Fbcsr, OutplaceAbsoluteMatrixIsEquivalentToRef) { using Mtx = typename TestFixture::Mtx; using value_type = typename Mtx::value_type; - auto drand = Mtx::create(this->exec); - drand->copy_from(gko::lend(this->rsorted)); + auto drand = gko::clone(this->exec, this->rsorted); auto abs_mtx = this->rsorted->compute_absolute(); auto dabs_mtx = drand->compute_absolute(); diff --git a/test/matrix/hybrid_kernels.cpp b/test/matrix/hybrid_kernels.cpp index 413c325cbdc..7f72323ecab 100644 --- a/test/matrix/hybrid_kernels.cpp +++ b/test/matrix/hybrid_kernels.cpp @@ -76,7 +76,7 @@ class Hybrid : public CommonTestFixture { { return gko::test::generate_random_matrix( num_rows, num_cols, - std::uniform_int_distribution<>(min_nnz_row, num_cols), + std::uniform_int_distribution<>(min_nnz_row, max_nnz_row), std::normal_distribution(-1.0, 1.0), rand_engine, ref); } diff --git a/test/matrix/matrix.cpp b/test/matrix/matrix.cpp index 011d0500d17..1b6ba11d089 100644 --- a/test/matrix/matrix.cpp +++ b/test/matrix/matrix.cpp @@ -153,8 +153,9 @@ struct CsrWithDefaultStrategy : CsrBase { static void assert_empty_state(const matrix_type* mtx) { CsrBase::assert_empty_state(mtx); - ASSERT_EQ(typeid(*mtx->create_default()->get_strategy()), - typeid(*mtx->get_strategy())); + auto first_strategy = mtx->create_default()->get_strategy(); + auto second_strategy = mtx->get_strategy(); + ASSERT_EQ(typeid(*first_strategy), typeid(*second_strategy)); } }; diff --git a/test/solver/gmres_kernels.cpp b/test/solver/gmres_kernels.cpp index 54fa6f2608c..ed1a0f878db 100644 --- a/test/solver/gmres_kernels.cpp +++ b/test/solver/gmres_kernels.cpp @@ -77,7 +77,7 @@ class Gmres : public CommonTestFixture { .with_criteria( gko::stop::Iteration::build().with_max_iters(246u).on(exec), gko::stop::ResidualNorm::build() - .with_reduction_factor(1e-15) + .with_reduction_factor(value_type{1e-15}) .on(exec)) .on(exec); @@ -86,7 +86,7 @@ class Gmres : public CommonTestFixture { .with_criteria( gko::stop::Iteration::build().with_max_iters(246u).on(ref), gko::stop::ResidualNorm::build() - .with_reduction_factor(1e-15) + .with_reduction_factor(value_type{1e-15}) .on(ref)) .on(ref); } @@ -317,6 +317,5 @@ TEST_F(Gmres, GmresApplyOneRHSIsEquivalentToRef) ref_solver->apply(b.get(), x.get()); exec_solver->apply(d_b.get(), d_x.get()); - GKO_ASSERT_MTX_NEAR(d_b, b, r::value * 50); GKO_ASSERT_MTX_NEAR(d_x, x, r::value * 50); } diff --git a/test/solver/multigrid_kernels.cpp b/test/solver/multigrid_kernels.cpp index 6669cc2cf8f..ff933f1da38 100644 --- a/test/solver/multigrid_kernels.cpp +++ b/test/solver/multigrid_kernels.cpp @@ -83,28 +83,17 @@ class Multigrid : public CommonTestFixture { this->modify_norm(old_norm, new_norm); this->modify_scalar(alpha, rho, beta, gamma, zeta); - d_v = Mtx::create(exec); - d_v->copy_from(v.get()); - d_d = Mtx::create(exec); - d_d->copy_from(d.get()); - d_g = Mtx::create(exec); - d_g->copy_from(g.get()); - d_e = Mtx::create(exec); - d_e->copy_from(e.get()); - d_alpha = Mtx::create(exec); - d_alpha->copy_from(alpha.get()); - d_rho = Mtx::create(exec); - d_rho->copy_from(rho.get()); - d_beta = Mtx::create(exec); - d_beta->copy_from(beta.get()); - d_gamma = Mtx::create(exec); - d_gamma->copy_from(gamma.get()); - d_zeta = Mtx::create(exec); - d_zeta->copy_from(zeta.get()); - d_old_norm = Mtx::create(exec); - d_old_norm->copy_from(old_norm.get()); - d_new_norm = Mtx::create(exec); - d_new_norm->copy_from(new_norm.get()); + d_v = gko::clone(exec, v); + d_d = gko::clone(exec, d); + d_g = gko::clone(exec, g); + d_e = gko::clone(exec, e); + d_alpha = gko::clone(exec, alpha); + d_rho = gko::clone(exec, rho); + d_beta = gko::clone(exec, beta); + d_gamma = gko::clone(exec, gamma); + d_zeta = gko::clone(exec, zeta); + d_old_norm = gko::clone(exec, old_norm); + d_new_norm = gko::clone(exec, new_norm); } void modify_norm(std::unique_ptr& old_norm,