From 06ae6a428070baeac2dcc423f0fc7567b480dde0 Mon Sep 17 00:00:00 2001 From: Mikhail Katliar Date: Wed, 6 Nov 2024 09:06:02 +0100 Subject: [PATCH] Removed deprecated stuff from RegisterMatrix --- .../math/register_matrix/RegisterMatrix.hpp | 38 ------ test/blast/math/simd/RegisterMatrixTest.cpp | 126 ++++++++---------- 2 files changed, 54 insertions(+), 110 deletions(-) diff --git a/include/blast/math/register_matrix/RegisterMatrix.hpp b/include/blast/math/register_matrix/RegisterMatrix.hpp index c2113ee..052e4db 100644 --- a/include/blast/math/register_matrix/RegisterMatrix.hpp +++ b/include/blast/math/register_matrix/RegisterMatrix.hpp @@ -74,16 +74,6 @@ namespace blast } - /// @brief Number of matrix panels - /// - /// TODO: do we need it? deprecate? - /// - static size_t constexpr panels() - { - return RM; - } - - /// @brief Number of registers used static size_t constexpr registers() { @@ -91,16 +81,6 @@ namespace blast } - /// @brief SIMD size - /// - /// TODO: do we need it? deprecate? - /// - static size_t constexpr simdSize() - { - return SS; - } - - /// @brief Value of the matrix element at row \a i and column \a j T operator()(size_t i, size_t j) const noexcept { @@ -433,24 +413,6 @@ namespace blast struct StorageOrderHelper> : std::integral_constant {}; - // TODO: deprecate - template - struct RegisterMatrixTraits; - - - // TODO: deprecate - template - struct RegisterMatrixTraits> - { - static size_t constexpr simdSize = RegisterMatrix::SS; - static size_t constexpr rows = M; - static size_t constexpr columns = N; - static size_t constexpr elementCount = rows * columns; - - using ElementType = T; - }; - - template inline size_t constexpr rows(RegisterMatrix const& m) noexcept { diff --git a/test/blast/math/simd/RegisterMatrixTest.cpp b/test/blast/math/simd/RegisterMatrixTest.cpp index eceab1e..187f5f4 100644 --- a/test/blast/math/simd/RegisterMatrixTest.cpp +++ b/test/blast/math/simd/RegisterMatrixTest.cpp @@ -52,7 +52,6 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testDefaultCtor) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; RM ker; @@ -66,10 +65,9 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testReset) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticPanelMatrix A; + StaticPanelMatrix A; randomize(A); RM ker; @@ -90,18 +88,17 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testLoadPanel) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticPanelMatrix A; + StaticPanelMatrix A; randomize(A); RM ker; ET const beta = 0.1; ker.load(beta, ptr(A, 0, 0)); - for (size_t i = 0; i < Traits::rows; ++i) - for (size_t j = 0; j < Traits::columns; ++j) + for (size_t i = 0; i < RM::rows(); ++i) + for (size_t j = 0; j < RM::columns(); ++j) EXPECT_EQ(ker(i, j), beta * A(i, j)) << "element mismatch at (" << i << ", " << j << ")"; } @@ -109,10 +106,9 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testPartialLoadPanel) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticPanelMatrix A; + StaticPanelMatrix A; randomize(A); for (size_t m = 0; m <= rows(A); ++m) @@ -136,10 +132,9 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testPartialLoadDense) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticMatrix A; + StaticMatrix A; for (size_t i = 0; i < rows(A); ++i) for (size_t j = 0; j < columns(A); ++j) A(i, j) = 1000 * i + j; @@ -167,18 +162,17 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testLoadStore) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticPanelMatrix A, B; + StaticPanelMatrix A, B; randomize(A); RM ker; ker.load(ptr(A)); ker.store(ptr(B)); - for (size_t i = 0; i < Traits::rows; ++i) - for (size_t j = 0; j < Traits::columns; ++j) + for (size_t i = 0; i < RM::rows(); ++i) + for (size_t j = 0; j < RM::columns(); ++j) EXPECT_EQ(B(i, j), A(i, j)) << "element mismatch at (" << i << ", " << j << ")"; } @@ -186,18 +180,17 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testLoadStore2) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticMatrix A, B(0.); + StaticMatrix A, B(0.); randomize(A); RM ker; ker.load(1., ptr(A, 0, 0)); ker.store(ptr(B, 0, 0)); - for (size_t i = 0; i < Traits::rows; ++i) - for (size_t j = 0; j < Traits::columns; ++j) + for (size_t i = 0; i < RM::rows(); ++i) + for (size_t j = 0; j < RM::columns(); ++j) EXPECT_EQ(B(i, j), A(i, j)) << "element mismatch at (" << i << ", " << j << ")"; } @@ -216,10 +209,6 @@ namespace blast :: testing // store2(ker, B.data(), B.spacing()); EXPECT_EQ(ker, A); - - // for (size_t i = 0; i < ker.rows(); ++i) - // for (size_t j = 0; j < ker.columns(); ++j) - // EXPECT_EQ(ker(i, j), A(i, j)) << "element mismatch at (" << i << ", " << j << ")"; } @@ -280,28 +269,27 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testPartialStore) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticMatrix A_ref; + StaticMatrix A_ref; randomize(A_ref); - StaticPanelMatrix A, B; + StaticPanelMatrix A, B; assign(A, A_ref); RM ker; ker.load(ptr(A)); - for (size_t m = ker.rows() + 1 - ker.simdSize(); m <= Traits::rows; ++m) - for (size_t n = 1; n <= Traits::columns; ++n) + for (size_t m = ker.rows() + 1 - SimdSize_v; m <= RM::rows(); ++m) + for (size_t n = 1; n <= RM::columns(); ++n) { - if (m != Traits::rows && n != Traits::columns) + if (m != RM::rows() && n != RM::columns()) { B = 0.; ker.store(ptr(B), m, n); - for (size_t i = 0; i < Traits::rows; ++i) - for (size_t j = 0; j < Traits::columns; ++j) + for (size_t i = 0; i < RM::rows(); ++i) + for (size_t j = 0; j < RM::columns(); ++j) ASSERT_EQ(B(i, j), i < m && j < n ? A_ref(i, j) : 0.) << "element mismatch at (" << i << ", " << j << "), " << "store size = " << m << "x" << n; } @@ -312,23 +300,22 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testPartialStore2) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticMatrix A, B; + StaticMatrix A, B; randomize(A); RM ker; ker.load(1., ptr(A, 0, 0)); - for (size_t m = 0; m <= Traits::rows; ++m) - for (size_t n = 0; n <= Traits::columns; ++n) + for (size_t m = 0; m <= RM::rows(); ++m) + for (size_t n = 0; n <= RM::columns(); ++n) { B = 0.; ker.store(ptr(B, 0, 0), m, n); - for (size_t i = 0; i < Traits::rows; ++i) - for (size_t j = 0; j < Traits::columns; ++j) + for (size_t i = 0; i < RM::rows(); ++i) + for (size_t j = 0; j < RM::columns(); ++j) ASSERT_EQ(B(i, j), i < m && j < n ? A(i, j) : 0.) << "element mismatch at (" << i << ", " << j << "), " << "store size = " << m << "x" << n; } @@ -338,12 +325,11 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testGerNT) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticPanelMatrix A; - StaticPanelMatrix B; - StaticPanelMatrix C; + StaticPanelMatrix A; + StaticPanelMatrix B; + StaticPanelMatrix C; randomize(A); randomize(B); @@ -362,12 +348,11 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testGer) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - DynamicVector a(Traits::rows); - DynamicVector b(Traits::columns); - StaticMatrix C; + DynamicVector a(RM::rows()); + DynamicVector b(RM::columns()); + StaticMatrix C; randomize(a); randomize(b); @@ -388,19 +373,18 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testPartialGerNT) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - StaticPanelMatrix A; - StaticPanelMatrix B; - StaticPanelMatrix C; + StaticPanelMatrix A; + StaticPanelMatrix B; + StaticPanelMatrix C; randomize(A); randomize(B); randomize(C); - StaticMatrix D; - reference::ger(Traits::rows, Traits::columns, 1., column(ptr(A)), column(ptr(B)).trans(), ptr(C), ptr(D)); + StaticMatrix D; + reference::ger(RM::rows(), RM::columns(), 1., column(ptr(A)), column(ptr(B)).trans(), ptr(C), ptr(D)); for (size_t m = 0; m <= rows(C); ++m) { @@ -423,19 +407,18 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testPartialGerNT2) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - DynamicVector a(Traits::rows); - DynamicVector b(Traits::columns); - StaticMatrix C; + DynamicVector a(RM::rows()); + DynamicVector b(RM::columns()); + StaticMatrix C; randomize(a); randomize(b); randomize(C); - StaticMatrix D; - reference::ger(Traits::rows, Traits::columns, 1., ptr(a), ptr(trans(b)), ptr(C), ptr(D)); + StaticMatrix D; + reference::ger(RM::rows(), RM::columns(), 1., ptr(a), ptr(trans(b)), ptr(C), ptr(D)); for (size_t m = 0; m <= rows(C); ++m) { @@ -458,12 +441,11 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testGerNT2) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; - DynamicVector a(Traits::rows); - DynamicVector b(Traits::columns); - StaticMatrix C, D; + DynamicVector a(RM::rows()); + DynamicVector b(RM::columns()); + StaticMatrix C, D; randomize(a); randomize(b); @@ -474,18 +456,19 @@ namespace blast :: testing ker.ger(ET(1.), ptr(a), ptr(trans(b))); ker.store(ptr(D)); - StaticMatrix D_ref; - reference::ger(Traits::rows, Traits::columns, 1., ptr(a), ptr(trans(b)), ptr(C), ptr(D_ref)); + StaticMatrix D_ref; + reference::ger(RM::rows(), RM::columns(), 1., ptr(a), ptr(trans(b)), ptr(C), ptr(D_ref)); BLAST_EXPECT_APPROX_EQ(D, D_ref, absTol(), relTol()); } TYPED_TEST(RegisterMatrixTest, testPotrf) { - using Traits = RegisterMatrixTraits; - using ET = typename Traits::ElementType; - static size_t constexpr m = Traits::rows; - static size_t constexpr n = Traits::columns; + using RM = TypeParam; + using ET = ElementType_t; + + static size_t constexpr m = RM::rows(); + static size_t constexpr n = RM::columns(); if constexpr (m >= n) { @@ -513,17 +496,16 @@ namespace blast :: testing TYPED_TEST(RegisterMatrixTest, testTrsmRightLowerTransposePanel) { using RM = TypeParam; - using Traits = RegisterMatrixTraits; using ET = ElementType_t; RM ker; - StaticPanelMatrix A; - StaticPanelMatrix B, X; + StaticPanelMatrix A; + StaticPanelMatrix B, X; randomize(A); - for (size_t i = 0; i < Traits::columns; ++i) - A(i, i) += Traits::columns; // Improve conditioning + for (size_t i = 0; i < RM::columns(); ++i) + A(i, i) += RM::columns(); // Improve conditioning randomize(B);