Skip to content

Commit

Permalink
Merge branch 'remove-get-batch-csr' into 'main'
Browse files Browse the repository at this point in the history
Remove GetBatchCsr test

See merge request gysela-developpers/gyselalibxx!622
  • Loading branch information
EmilyBourne committed Jul 31, 2024
1 parent 4ac1f4d commit 486adb5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 59 deletions.
7 changes: 3 additions & 4 deletions vendor/sll/include/sll/matrix_batch_csr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
#include <sll/matrix_batch.hpp>
#include <sll/matrix_utils.hpp>

#include <ginkgo/extensions/kokkos.hpp>
#include <ginkgo/ginkgo.hpp>

#include <Kokkos_Core.hpp>

#include "ddc/kernels/splines/ginkgo_executors.hpp"

/**
* @brief A tag to choose between the batched iterative solvers provided by Ginkgo.
*
Expand Down Expand Up @@ -85,7 +84,7 @@ class MatrixBatchCsr : public MatrixBatch<ExecSpace>
, m_preconditionner_max_block_size(preconditionner_max_block_size.value_or(
default_preconditionner_max_block_size<ExecSpace>()))
{
std::shared_ptr const gko_exec = ddc::detail::create_gko_exec<ExecSpace>();
std::shared_ptr const gko_exec = gko::ext::kokkos::create_executor(ExecSpace());
m_batch_matrix_csr = gko::share(
batch_sparse_type::
create(gko_exec,
Expand Down Expand Up @@ -126,7 +125,7 @@ class MatrixBatchCsr : public MatrixBatch<ExecSpace>
, m_preconditionner_max_block_size(preconditionner_max_block_size.value_or(
default_preconditionner_max_block_size<ExecSpace>()))
{
std::shared_ptr const gko_exec = ddc::detail::create_gko_exec<ExecSpace>();
std::shared_ptr const gko_exec = gko::ext::kokkos::create_executor(ExecSpace());
m_batch_matrix_csr = gko::share(
batch_sparse_type::
create(gko_exec,
Expand Down
7 changes: 3 additions & 4 deletions vendor/sll/include/sll/matrix_batch_ell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
#include <sll/matrix_batch.hpp>
#include <sll/matrix_utils.hpp>

#include <ginkgo/extensions/kokkos.hpp>
#include <ginkgo/ginkgo.hpp>

#include <Kokkos_Core.hpp>

#include "ddc/kernels/splines/ginkgo_executors.hpp"

/**
* @brief Matrix class which is able to manage and solve a batch of sparse linear systems. Executes on either CPU or GPU.
* It takes advantage of the sparse structure, and the only batched solver available in Ginkgo : Stabilized Bicg.
Expand Down Expand Up @@ -62,7 +61,7 @@ class MatrixBatchEll : public MatrixBatch<ExecSpace>
, m_tol(res_tol.value_or(1e-15))
, m_with_logger(logger.value_or(false))
{
std::shared_ptr const gko_exec = ddc::detail::create_gko_exec<ExecSpace>();
std::shared_ptr const gko_exec = gko::ext::kokkos::create_executor(ExecSpace());
m_batch_matrix_ell = gko::share(
batch_sparse_type::
create(gko_exec,
Expand Down Expand Up @@ -94,7 +93,7 @@ class MatrixBatchEll : public MatrixBatch<ExecSpace>


{
std::shared_ptr const gko_exec = ddc::detail::create_gko_exec<ExecSpace>();
std::shared_ptr const gko_exec = gko::ext::kokkos::create_executor(ExecSpace());
m_batch_matrix_ell = gko::share(gko::batch::matrix::Ell<double>::create(
gko_exec,
gko::batch_dim<2>(this->get_batch_size(), gko::dim<2>(get_size(), get_size())),
Expand Down
3 changes: 0 additions & 3 deletions vendor/sll/include/sll/matrix_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

#include <Kokkos_Core.hpp>

#include "ddc/kernels/splines/ginkgo_executors.hpp"


/**
* @brief A function to convert a 2D Kokkos view into a ginkgo multivector structure.
* @param gko_exec[in] A Ginkgo executor that has access to the Kokkos::View memory space
Expand Down
47 changes: 0 additions & 47 deletions vendor/sll/tests/matrix_batch_csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,53 +58,6 @@ class MatrixBatchCsrFixture : public ::testing::Test
MatrixBatchCsr<Kokkos::DefaultExecutionSpace> matrix_batch_test;
};

TEST(MatrixBatchCsrFixture, Get_batch_csr)
{
int const batch_size = 2;
int const mat_size = 4;
int const non_zero_per_system = 4;
double values[] = {2.0, 4.0, 6.0, 8.0, 3.0, 5.0, 7.0, 9.0};
int col_idxs[] = {0, 1, 2, 3};
int nnz_per_row[] = {0, 1, 2, 3, 4};
// rhs and solution
double res[] = {1., 3.5, 2., 3., 42., 17., 0.5, 1.};
double solution[]
= {1. / 2., 3.5 / 4., 2. / 6., 3. / 8., 42. / 3., 17. / 5., 1. / 14., 1. / 9.};

Kokkos::View<double**, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>
values_view_host(values, batch_size, non_zero_per_system);
Kokkos::View<int*, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>
col_idx_view_host(col_idxs, non_zero_per_system);
Kokkos::View<int*, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>
nnz_per_row_view_host(nnz_per_row, mat_size + 1);

Kokkos::View<double**, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>
res_host(res, batch_size, mat_size);

Kokkos::View<double**, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace>
res_view("res", batch_size, mat_size);
MatrixBatchCsr<Kokkos::DefaultExecutionSpace, MatrixBatchCsrSolver::BICGSTAB>
test_instance(batch_size, mat_size, non_zero_per_system, 100, 1e-6);
auto [values_view, col_idx_view, nnz_per_row_view] = test_instance.get_batch_csr();

Kokkos::deep_copy(values_view, values_view_host);
Kokkos::deep_copy(col_idx_view, col_idx_view_host);
Kokkos::deep_copy(nnz_per_row_view, nnz_per_row_view_host);
Kokkos::deep_copy(res_view, res_host);

test_instance.factorize();
test_instance.solve_inplace(res_view);

Kokkos::deep_copy(res_host, res_view);
ASSERT_EQ(test_instance.norm(0), 8);
ASSERT_EQ(test_instance.norm(1), 9);
for (int batch_idx = 0; batch_idx < batch_size; batch_idx++) {
for (int i = 0; i < mat_size; i++) {
ASSERT_FLOAT_EQ(res_host(batch_idx, i), solution[batch_idx * mat_size + i]);
}
}
}

TEST(MatrixBatchCsrFixture, Coo_to_Csr)
{
int const batch_size = 2;
Expand Down

0 comments on commit 486adb5

Please sign in to comment.