Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/public' into public
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyBourne committed Jul 31, 2024
2 parents d9f8501 + 486adb5 commit e28567c
Showing 1 changed file with 0 additions and 47 deletions.
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 e28567c

Please sign in to comment.