Skip to content

Commit

Permalink
Rename MatrixBatchSparse to MatrixBatchEll
Browse files Browse the repository at this point in the history
Closes #244

See merge request gysela-developpers/gyselalibxx!506

--------------------------------------------
  • Loading branch information
EmilyBourne committed Jun 10, 2024
1 parent fbf35a3 commit d9da711
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ std::vector<std::unique_ptr<typename InputType::unbatch_type>> unbatch(
* The simplest choice is to follow Kokkos, for that: specify Kokkos::DefaultExecutionSpace
*/
template <class ExecSpace>
class MatrixBatchSparse : public MatrixBatch<ExecSpace>
class MatrixBatchEll : public MatrixBatch<ExecSpace>
{
using batch_sparse_type = gko::batch::matrix::Ell<double, int>;
using bicgstab = gko::batch::solver::Bicgstab<double>;
Expand All @@ -80,7 +80,7 @@ class MatrixBatchSparse : public MatrixBatch<ExecSpace>
using MatrixBatch<ExecSpace>::get_size;
using MatrixBatch<ExecSpace>::get_batch_size;
/**
* @brief The constructor for MatrixBatchSparse class.
* @brief The constructor for MatrixBatchEll class.
*
* @param[in] batch_size Number of linear systems to solve.
* @param[in] mat_size Common matrix size for all the systems.
Expand All @@ -90,7 +90,7 @@ class MatrixBatchSparse : public MatrixBatch<ExecSpace>
* provided here, will be used as "implicit residual" in ginkgo solver.
* @param[in] logger boolean parameter for saving log informations such residual and interations count.
*/
MatrixBatchSparse(
MatrixBatchEll(
const int batch_size,
const int mat_size,
const int non_zeros_per_row,
Expand All @@ -111,7 +111,7 @@ class MatrixBatchSparse : public MatrixBatch<ExecSpace>
}

/**
* @brief Constructor for MatrixBatchSparse class.
* @brief Constructor for MatrixBatchEll class.
*
* @param[in] cols_idx A Kokkos view which stores the column indices of non-zero components.
* @param[in] batch_values A Kokkos view which stores the values of non-zero elements.
Expand All @@ -121,7 +121,7 @@ class MatrixBatchSparse : public MatrixBatch<ExecSpace>
* Default value is set to 1e-15.
* @param[in] logger bolean parameter to save logger information. Default value false.
*/
MatrixBatchSparse(
MatrixBatchEll(
Kokkos::View<int**, Kokkos::LayoutLeft, ExecSpace> cols_idx,
Kokkos::View<double***, Kokkos::LayoutStride, ExecSpace> batch_values,
std::optional<int> max_iter = std::nullopt,
Expand Down
2 changes: 1 addition & 1 deletion vendor/sll/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ gtest_discover_tests(bsplines_tests_sll)
add_executable(matrix_tests_sll
main.cpp
matrix.cpp
matrix_batch_sparse.cpp
matrix_batch_ell.cpp
matrix_batch_tridiag.cpp
)
target_compile_features(matrix_tests_sll PUBLIC cxx_std_17)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <ddc/ddc.hpp>

#include <sll/math_tools.hpp>
#include <sll/matrix_batch_sparse.hpp>
#include <sll/matrix_batch_ell.hpp>

#include <gtest/gtest.h>

Expand All @@ -21,13 +21,13 @@ void fill_values(Kokkos::View<int**, Kokkos::LayoutLeft, Kokkos::DefaultExecutio



class MatrixBatchSparseFixture : public ::testing::Test
class MatrixBatchEllFixture : public ::testing::Test
{
protected:
MatrixBatchSparse<Kokkos::DefaultExecutionSpace> matrix_batch_test;
MatrixBatchEll<Kokkos::DefaultExecutionSpace> matrix_batch_test;
};

TEST(MatrixBatchSparseFixture, Init)
TEST(MatrixBatchEllFixture, Init)
{
int const batch_size = 2;
int const mat_size = 4;
Expand All @@ -46,14 +46,13 @@ TEST(MatrixBatchSparseFixture, Init)
values_view(values, values_layout);
Kokkos::View<int**, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
idx_view(col_idxs, mat_size, non_zero_per_col);
MatrixBatchSparse<Kokkos::DefaultExecutionSpace>
test_instance(idx_view, values_view, 1000, 0.001);
MatrixBatchEll<Kokkos::DefaultExecutionSpace> test_instance(idx_view, values_view, 1000, 0.001);
ASSERT_EQ(test_instance.get_batch_size(), batch_size);
ASSERT_EQ(test_instance.get_size(), mat_size);
}


TEST(MatrixBatchSparseFixture, SetGetElement)
TEST(MatrixBatchEllFixture, SetGetElement)
{
int const batch_size = 2;
int const mat_size = 4;
Expand All @@ -71,16 +70,15 @@ TEST(MatrixBatchSparseFixture, SetGetElement)
values_view(values, values_layout);
Kokkos::View<int**, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
idx_view(col_idx, mat_size, non_zero_per_col);
MatrixBatchSparse<Kokkos::DefaultExecutionSpace>
test_instance(idx_view, values_view, 1000, 1e-8);
MatrixBatchEll<Kokkos::DefaultExecutionSpace> test_instance(idx_view, values_view, 1000, 1e-8);
auto [idx, vals] = test_instance.get_batch_idx_and_vals();

test_instance.set_ell_element(0, 3, 0, 42);
ASSERT_EQ(test_instance.get_ell_element(0, 3, 0), 42);
}


TEST(MatrixBatchSparseFixture, GetIdxAndVals)
TEST(MatrixBatchEllFixture, GetIdxAndVals)
{
int const batch_size = 2;
int const mat_size = 4;
Expand All @@ -104,8 +102,7 @@ TEST(MatrixBatchSparseFixture, GetIdxAndVals)
idx_host(col_idx, mat_size, non_zero_per_col);
Kokkos::deep_copy(idx_view, idx_host);
Kokkos::deep_copy(values_view, values_host);
MatrixBatchSparse<Kokkos::DefaultExecutionSpace>
test_instance(idx_view, values_view, 1000, 1e-8);
MatrixBatchEll<Kokkos::DefaultExecutionSpace> test_instance(idx_view, values_view, 1000, 1e-8);
auto [idx, vals] = test_instance.get_batch_idx_and_vals();

Kokkos::deep_copy(idx_host, idx);
Expand All @@ -125,7 +122,7 @@ TEST(MatrixBatchSparseFixture, GetIdxAndVals)
ASSERT_EQ(values_host(1, 3, 0), 8.0);
}

TEST(MatrixBatchSparseFixture, SolveDiagonal)
TEST(MatrixBatchEllFixture, SolveDiagonal)
{
int const batch_size = 2;
int const mat_size = 4;
Expand Down Expand Up @@ -161,8 +158,7 @@ TEST(MatrixBatchSparseFixture, SolveDiagonal)
Kokkos::deep_copy(values_view, values_host);
Kokkos::deep_copy(res_view, res_host);

MatrixBatchSparse<Kokkos::DefaultExecutionSpace>
test_instance(idx_view, values_view, 1000, 1e-6);
MatrixBatchEll<Kokkos::DefaultExecutionSpace> test_instance(idx_view, values_view, 1000, 1e-6);
test_instance.factorize();
test_instance.solve_inplace(res_view);

Expand All @@ -177,7 +173,7 @@ TEST(MatrixBatchSparseFixture, SolveDiagonal)
ASSERT_FLOAT_EQ(res_host(1, 3), solution[7]);
}

TEST(MatrixBatchSparseFixture, SolveSparse)
TEST(MatrixBatchEllFixture, SolveSparse)
{
int const batch_size = 2;
int const mat_size = 5;
Expand Down Expand Up @@ -243,8 +239,7 @@ TEST(MatrixBatchSparseFixture, SolveSparse)
Kokkos::deep_copy(idx_view, idx_host);
Kokkos::deep_copy(values_view, values_host);
Kokkos::deep_copy(res_view, 1.);
MatrixBatchSparse<Kokkos::DefaultExecutionSpace>
test_instance(idx_view, values_view, 1000, 1e-12);
MatrixBatchEll<Kokkos::DefaultExecutionSpace> test_instance(idx_view, values_view, 1000, 1e-12);
test_instance.factorize();
test_instance.solve_inplace(res_view);
ASSERT_EQ(test_instance.norm(0), 7);
Expand Down

0 comments on commit d9da711

Please sign in to comment.