Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
* remove a few unused variables
* fix a ParILU and ILU(0) test

Co-authored-by: Thomas Grützmacher <thomas.gruetzmacher@kit.edu>
Co-authored-by: Marcel Koch <marcel.koch@kit.edu>
  • Loading branch information
3 people committed Jul 23, 2021
1 parent d38dd4c commit a0b5421
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 30 deletions.
2 changes: 1 addition & 1 deletion reference/factorization/ic_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ template <typename ValueType, typename IndexType>
void compute(std::shared_ptr<const DefaultExecutor> exec,
matrix::Csr<ValueType, IndexType> *m)
{
vector<IndexType> diagonals{m->get_size()[0], -1, {exec}};
vector<IndexType> diagonals{m->get_size()[0], -1, exec};
const auto row_ptrs = m->get_const_row_ptrs();
const auto col_idxs = m->get_const_col_idxs();
const auto values = m->get_values();
Expand Down
6 changes: 2 additions & 4 deletions reference/factorization/ilu_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ template <typename ValueType, typename IndexType>
void compute_lu(std::shared_ptr<const DefaultExecutor> exec,
matrix::Csr<ValueType, IndexType> *m)
{
vector<IndexType> diagonals{m->get_size()[0], -1, {exec}};
vector<IndexType> diagonals{m->get_size()[0], -1, exec};
const auto row_ptrs = m->get_const_row_ptrs();
const auto col_idxs = m->get_const_col_idxs();
const auto values = m->get_values();
Expand All @@ -71,9 +71,7 @@ void compute_lu(std::shared_ptr<const DefaultExecutor> exec,
diagonals[row] = nz;
}
auto value = values[nz];
const auto l_begin = begin;
const auto l_end = end;
for (auto l_nz = l_begin; l_nz < l_end; l_nz++) {
for (auto l_nz = begin; l_nz < end; l_nz++) {
// for each lower triangular entry l_ik
const auto l_col = col_idxs[l_nz];
if (l_col >= min(row, col)) {
Expand Down
22 changes: 4 additions & 18 deletions reference/test/factorization/ic_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,38 +96,21 @@ class Ic : public ::testing::Test {
{-6., 18., 17., 14.},
{-3., 24., 14., 18.}},
ref)),
mtx_l_system(gko::initialize<Csr>({{9., 0., 0., 0.},
{0., 36., 0., 0.},
{-6., 18., 17., 0.},
{-3., 24., 14., 18.}},
ref)),
mtx_l_system_coo(Coo::create(exec)),
mtx_l_init_expect(gko::initialize<Csr>(
{{3., 0., 0., 0.},
{0., 6., 0., 0.},
{-6., 18., static_cast<value_type>(sqrt(17.)), 0.},
{-3., 24., 14., static_cast<value_type>(sqrt(18.))}},
ref)),
mtx_l_it_expect(gko::initialize<Csr>({{3., 0., 0., 0.},
{0., 6., 0., 0.},
{-2., 3., 2., 0.},
{-1., 4., 0., 1.}},
ref)),
fact_fact(factorization_type::build().on(exec)),
tol{r<value_type>::value}
{
mtx_l_system->convert_to(gko::lend(mtx_l_system_coo));
}
{}

std::shared_ptr<const gko::ReferenceExecutor> ref;
std::shared_ptr<const gko::Executor> exec;
std::shared_ptr<Csr> identity;
std::shared_ptr<Csr> banded;
std::shared_ptr<Csr> banded_l_expect;
std::shared_ptr<Csr> mtx_system;
std::unique_ptr<Csr> mtx_l_system;
std::unique_ptr<Coo> mtx_l_system_coo;
std::unique_ptr<Csr> mtx_l_init_expect;
std::unique_ptr<Csr> mtx_l_it_expect;
std::unique_ptr<typename factorization_type::Factory> fact_fact;
gko::remove_complex<value_type> tol;
Expand Down Expand Up @@ -201,6 +184,7 @@ TYPED_TEST(Ic, GenerateDenseIdentity)
using Dense = typename TestFixture::Dense;
auto dense_id = Dense::create(this->exec, this->identity->get_size());
this->identity->convert_to(dense_id.get());

auto fact = this->fact_fact->generate(gko::share(dense_id));

GKO_ASSERT_MTX_NEAR(fact->get_l_factor(), this->identity, this->tol);
Expand All @@ -212,6 +196,7 @@ TYPED_TEST(Ic, GenerateBanded)
{
using factorization_type = typename TestFixture::factorization_type;
using Csr = typename TestFixture::Csr;

auto fact =
factorization_type::build().on(this->exec)->generate(this->banded);

Expand All @@ -226,6 +211,7 @@ TYPED_TEST(Ic, GenerateGeneral)
{
using factorization_type = typename TestFixture::factorization_type;
using Csr = typename TestFixture::Csr;

auto fact =
factorization_type::build().on(this->exec)->generate(this->mtx_system);

Expand Down
7 changes: 1 addition & 6 deletions reference/test/factorization/ilu_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ class Ilu : public ::testing::Test {
: ref(gko::ReferenceExecutor::create()),
exec(std::static_pointer_cast<const gko::Executor>(ref)),
// clang-format off
empty_csr(gko::initialize<Csr>(
{{0., 0., 0.},
{0., 0., 0.},
{0., 0., 0.}}, exec)),
identity(gko::initialize<Dense>(
{{1., 0., 0.},
{0., 1., 0.},
Expand Down Expand Up @@ -186,7 +182,6 @@ class Ilu : public ::testing::Test {

std::shared_ptr<const gko::ReferenceExecutor> ref;
std::shared_ptr<const gko::Executor> exec;
std::shared_ptr<const Csr> empty_csr;
std::shared_ptr<const Dense> identity;
std::shared_ptr<const Dense> lower_triangular;
std::shared_ptr<const Dense> upper_triangular;
Expand Down Expand Up @@ -436,7 +431,7 @@ TYPED_TEST(Ilu, GenerateForDenseBig)
TYPED_TEST(Ilu, GenerateForDenseBigSort)
{
using value_type = typename TestFixture::value_type;
auto factors = this->ilu_factory_skip->generate(this->mtx_big);
auto factors = this->ilu_factory_sort->generate(this->mtx_big);
auto l_factor = factors->get_l_factor();
auto u_factor = factors->get_u_factor();

Expand Down
3 changes: 3 additions & 0 deletions reference/test/factorization/par_ic_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ TYPED_TEST(ParIc, GenerateDenseIdentity)
using Dense = typename TestFixture::Dense;
auto dense_id = Dense::create(this->exec, this->identity->get_size());
this->identity->convert_to(dense_id.get());

auto fact = this->fact_fact->generate(gko::share(dense_id));

GKO_ASSERT_MTX_NEAR(fact->get_l_factor(), this->identity, this->tol);
Expand All @@ -252,6 +253,7 @@ TYPED_TEST(ParIc, GenerateBanded)
{
using factorization_type = typename TestFixture::factorization_type;
using Csr = typename TestFixture::Csr;

auto fact =
factorization_type::build().on(this->exec)->generate(this->banded);

Expand All @@ -266,6 +268,7 @@ TYPED_TEST(ParIc, GenerateGeneral)
{
using factorization_type = typename TestFixture::factorization_type;
using Csr = typename TestFixture::Csr;

auto fact =
factorization_type::build().on(this->exec)->generate(this->mtx_system);

Expand Down
2 changes: 1 addition & 1 deletion reference/test/factorization/par_ilu_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ TYPED_TEST(ParIlu, GenerateForDenseBig)
TYPED_TEST(ParIlu, GenerateForDenseBigSort)
{
using value_type = typename TestFixture::value_type;
auto factors = this->ilu_factory_skip->generate(this->mtx_big);
auto factors = this->ilu_factory_sort->generate(this->mtx_big);
auto l_factor = factors->get_l_factor();
auto u_factor = factors->get_u_factor();

Expand Down

0 comments on commit a0b5421

Please sign in to comment.