From aa40e0aa8c1a193a444786fc3664d1655e28de0e Mon Sep 17 00:00:00 2001 From: Pratik Nayak Date: Sun, 26 Nov 2023 11:41:10 +0100 Subject: [PATCH] Review updates Co-authored-by: Marcel Koch --- core/matrix/batch_struct.hpp | 28 +++++++++------------------- core/test/matrix/batch_csr.cpp | 7 ++----- cuda/matrix/batch_struct.hpp | 2 -- dpcpp/matrix/batch_struct.hpp | 2 -- hip/matrix/batch_struct.hip.hpp | 2 -- reference/matrix/batch_struct.hpp | 2 -- test/matrix/batch_csr_kernels.cpp | 2 +- 7 files changed, 12 insertions(+), 33 deletions(-) diff --git a/core/matrix/batch_struct.hpp b/core/matrix/batch_struct.hpp index ae07e2ec112..a1136b0fda4 100644 --- a/core/matrix/batch_struct.hpp +++ b/core/matrix/batch_struct.hpp @@ -30,7 +30,6 @@ struct batch_item { ValueType* values; const index_type* col_idxs; const index_type* row_ptrs; - index_type stride; index_type num_rows; index_type num_cols; }; @@ -49,7 +48,6 @@ struct uniform_batch { const index_type* col_idxs; const index_type* row_ptrs; size_type num_batch_items; - index_type stride; index_type num_rows; index_type num_cols; index_type num_nnz_per_item; @@ -155,7 +153,7 @@ template GKO_ATTRIBUTES GKO_INLINE csr::batch_item to_const(const csr::batch_item& b) { - return {b.values, b.col_idxs, b.row_ptrs, b.stride, b.num_rows, b.num_cols}; + return {b.values, b.col_idxs, b.row_ptrs, b.num_rows, b.num_cols}; } @@ -163,8 +161,8 @@ template GKO_ATTRIBUTES GKO_INLINE csr::uniform_batch to_const(const csr::uniform_batch& ub) { - return {ub.values, ub.col_idxs, ub.row_ptrs, ub.num_batch_items, - ub.stride, ub.num_rows, ub.num_cols, ub.num_nnz_per_item}; + return {ub.values, ub.col_idxs, ub.row_ptrs, ub.num_batch_items, + ub.num_rows, ub.num_cols, ub.num_nnz_per_item}; } @@ -173,28 +171,20 @@ GKO_ATTRIBUTES GKO_INLINE csr::batch_item extract_batch_item(const csr::uniform_batch& batch, const size_type batch_idx) { - return {batch.values + batch_idx * batch.num_nnz_per_item, - batch.col_idxs, - batch.row_ptrs, - batch.stride, - batch.num_rows, - batch.num_cols}; + return {batch.values + batch_idx * batch.num_nnz_per_item, batch.col_idxs, + batch.row_ptrs, batch.num_rows, batch.num_cols}; } template GKO_ATTRIBUTES GKO_INLINE csr::batch_item extract_batch_item(ValueType* const batch_values, IndexType* const batch_col_idxs, - IndexType* const batch_row_ptrs, const int stride, - const int num_rows, const int num_cols, int num_nnz_per_item, + IndexType* const batch_row_ptrs, const int num_rows, + const int num_cols, int num_nnz_per_item, const size_type batch_idx) { - return {batch_values + batch_idx * num_nnz_per_item, - batch_col_idxs, - batch_row_ptrs, - stride, - num_rows, - num_cols}; + return {batch_values + batch_idx * num_nnz_per_item, batch_col_idxs, + batch_row_ptrs, num_rows, num_cols}; } diff --git a/core/test/matrix/batch_csr.cpp b/core/test/matrix/batch_csr.cpp index 053d4f607e8..a9a0ff80453 100644 --- a/core/test/matrix/batch_csr.cpp +++ b/core/test/matrix/batch_csr.cpp @@ -301,7 +301,7 @@ TYPED_TEST(Csr, CanBeConstructedFromCsrMatricesByDuplication) auto m = gko::batch::create_from_item(this->exec, 3, mat1.get(), 2); - GKO_ASSERT_BATCH_MTX_NEAR(bat_m.get(), m.get(), 1e-14); + GKO_ASSERT_BATCH_MTX_NEAR(bat_m.get(), m.get(), 0.); } @@ -324,7 +324,7 @@ TYPED_TEST(Csr, CanBeConstructedByDuplicatingCsrMatrices) auto m2 = gko::batch::duplicate(this->exec, 3, m.get(), 2); - GKO_ASSERT_BATCH_MTX_NEAR(m2.get(), m_ref.get(), 1e-14); + GKO_ASSERT_BATCH_MTX_NEAR(m2.get(), m_ref.get(), 0.); } @@ -349,7 +349,6 @@ TYPED_TEST(Csr, CanBeListConstructed) using value_type = typename TestFixture::value_type; using index_type = typename TestFixture::index_type; using BatchCsrMtx = typename TestFixture::BatchCsrMtx; - using CsrMtx = typename TestFixture::CsrMtx; auto m = gko::batch::initialize({{0.0, -1.0}, {0.0, -5.0}}, this->exec, 1); @@ -452,7 +451,6 @@ TYPED_TEST(Csr, ThrowsForDataWithDifferentNnz) { using value_type = typename TestFixture::value_type; using index_type = typename TestFixture::index_type; - using BatchCsrMtx = typename TestFixture::BatchCsrMtx; auto vec_data = std::vector>{}; vec_data.emplace_back( gko::matrix_data({2, 3}, { @@ -474,7 +472,6 @@ TYPED_TEST(Csr, ThrowsForDataWithDifferentSparsity) { using value_type = typename TestFixture::value_type; using index_type = typename TestFixture::index_type; - using BatchCsrMtx = typename TestFixture::BatchCsrMtx; auto vec_data = std::vector>{}; vec_data.emplace_back( gko::matrix_data({2, 3}, { diff --git a/cuda/matrix/batch_struct.hpp b/cuda/matrix/batch_struct.hpp index aef0220dced..a1016fca5cc 100644 --- a/cuda/matrix/batch_struct.hpp +++ b/cuda/matrix/batch_struct.hpp @@ -44,7 +44,6 @@ get_batch_struct(const batch::matrix::Csr* const op) op->get_const_col_idxs(), op->get_const_row_ptrs(), op->get_num_batch_items(), - static_cast(op->get_common_size()[1]), static_cast(op->get_common_size()[0]), static_cast(op->get_common_size()[1]), static_cast(op->get_num_elements_per_item())}; @@ -62,7 +61,6 @@ get_batch_struct(batch::matrix::Csr* const op) op->get_col_idxs(), op->get_row_ptrs(), op->get_num_batch_items(), - static_cast(op->get_common_size()[1]), static_cast(op->get_common_size()[0]), static_cast(op->get_common_size()[1]), static_cast(op->get_num_elements_per_item())}; diff --git a/dpcpp/matrix/batch_struct.hpp b/dpcpp/matrix/batch_struct.hpp index 830af4db7c9..40c63c33827 100644 --- a/dpcpp/matrix/batch_struct.hpp +++ b/dpcpp/matrix/batch_struct.hpp @@ -42,7 +42,6 @@ get_batch_struct(const batch::matrix::Csr* const op) op->get_const_col_idxs(), op->get_const_row_ptrs(), op->get_num_batch_items(), - static_cast(op->get_common_size()[1]), static_cast(op->get_common_size()[0]), static_cast(op->get_common_size()[1]), static_cast(op->get_num_elements_per_item())}; @@ -60,7 +59,6 @@ inline batch::matrix::csr::uniform_batch get_batch_struct( op->get_col_idxs(), op->get_row_ptrs(), op->get_num_batch_items(), - static_cast(op->get_common_size()[1]), static_cast(op->get_common_size()[0]), static_cast(op->get_common_size()[1]), static_cast(op->get_num_elements_per_item())}; diff --git a/hip/matrix/batch_struct.hip.hpp b/hip/matrix/batch_struct.hip.hpp index 8a3fd108a54..f1bba81d4dd 100644 --- a/hip/matrix/batch_struct.hip.hpp +++ b/hip/matrix/batch_struct.hip.hpp @@ -44,7 +44,6 @@ get_batch_struct(const batch::matrix::Csr* const op) op->get_const_col_idxs(), op->get_const_row_ptrs(), op->get_num_batch_items(), - static_cast(op->get_common_size()[1]), static_cast(op->get_common_size()[0]), static_cast(op->get_common_size()[1]), static_cast(op->get_num_elements_per_item())}; @@ -62,7 +61,6 @@ get_batch_struct(batch::matrix::Csr* const op) op->get_col_idxs(), op->get_row_ptrs(), op->get_num_batch_items(), - static_cast(op->get_common_size()[1]), static_cast(op->get_common_size()[0]), static_cast(op->get_common_size()[1]), static_cast(op->get_num_elements_per_item())}; diff --git a/reference/matrix/batch_struct.hpp b/reference/matrix/batch_struct.hpp index adb0cd4437e..3062b819405 100644 --- a/reference/matrix/batch_struct.hpp +++ b/reference/matrix/batch_struct.hpp @@ -47,7 +47,6 @@ get_batch_struct(const batch::matrix::Csr* const op) op->get_const_col_idxs(), op->get_const_row_ptrs(), op->get_num_batch_items(), - static_cast(op->get_common_size()[1]), static_cast(op->get_common_size()[0]), static_cast(op->get_common_size()[1]), static_cast(op->get_num_elements_per_item())}; @@ -65,7 +64,6 @@ inline batch::matrix::csr::uniform_batch get_batch_struct( op->get_col_idxs(), op->get_row_ptrs(), op->get_num_batch_items(), - static_cast(op->get_common_size()[1]), static_cast(op->get_common_size()[0]), static_cast(op->get_common_size()[1]), static_cast(op->get_num_elements_per_item())}; diff --git a/test/matrix/batch_csr_kernels.cpp b/test/matrix/batch_csr_kernels.cpp index aee5eb7b574..8b9dbdab598 100644 --- a/test/matrix/batch_csr_kernels.cpp +++ b/test/matrix/batch_csr_kernels.cpp @@ -77,7 +77,7 @@ class Csr : public CommonTestFixture { dresult = gko::clone(exec, expected); } - std::ranlux48 rand_engine; + std::default_random_engine rand_engine; const gko::size_type batch_size = 11; std::unique_ptr mat;