Skip to content

Commit

Permalink
add tests for empty conversions from SELL-P
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed Jul 15, 2020
1 parent 33fde9b commit be178c8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cuda/test/matrix/sellp_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ class Sellp : public ::testing::Test {
{
mtx = Mtx::create(ref);
mtx->copy_from(gen_mtx(532, 231));
empty = Mtx::create(ref);
expected = gen_mtx(532, 64);
y = gen_mtx(231, 64);
alpha = gko::initialize<Vec>({2.0}, ref);
beta = gko::initialize<Vec>({-1.0}, ref);
dmtx = Mtx::create(cuda);
dmtx->copy_from(mtx.get());
dempty = Mtx::create(cuda);
dresult = Vec::create(cuda);
dresult->copy_from(expected.get());
dy = Vec::create(cuda);
Expand All @@ -134,12 +136,14 @@ class Sellp : public ::testing::Test {
std::ranlux48 rand_engine;

std::unique_ptr<Mtx> mtx;
std::unique_ptr<Mtx> empty;
std::unique_ptr<Vec> expected;
std::unique_ptr<Vec> y;
std::unique_ptr<Vec> alpha;
std::unique_ptr<Vec> beta;

std::unique_ptr<Mtx> dmtx;
std::unique_ptr<Mtx> dempty;
std::unique_ptr<Vec> dresult;
std::unique_ptr<Vec> dy;
std::unique_ptr<Vec> dalpha;
Expand Down Expand Up @@ -281,6 +285,34 @@ TEST_F(Sellp, ConvertToCsrIsEquivalentToRef)
}


TEST_F(Sellp, ConvertEmptyToDenseIsEquivalentToRef)
{
set_up_apply_matrix();

auto dense_mtx = gko::matrix::Dense<>::create(ref);
auto ddense_mtx = gko::matrix::Dense<>::create(cuda);

empty->convert_to(dense_mtx.get());
dempty->convert_to(ddense_mtx.get());

GKO_ASSERT_MTX_NEAR(dense_mtx.get(), ddense_mtx.get(), 0);
}


TEST_F(Sellp, ConvertEmptyToCsrIsEquivalentToRef)
{
set_up_apply_matrix();

auto csr_mtx = gko::matrix::Csr<>::create(ref);
auto dcsr_mtx = gko::matrix::Csr<>::create(cuda);

empty->convert_to(csr_mtx.get());
dempty->convert_to(dcsr_mtx.get());

GKO_ASSERT_MTX_NEAR(csr_mtx.get(), dcsr_mtx.get(), 0);
}


TEST_F(Sellp, CountNonzerosIsEquivalentToRef)
{
set_up_apply_matrix();
Expand Down
32 changes: 32 additions & 0 deletions hip/test/matrix/sellp_kernels.hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ class Sellp : public ::testing::Test {
{
mtx = Mtx::create(ref);
mtx->copy_from(gen_mtx(532, 231));
empty = Mtx::create(ref);
expected = gen_mtx(532, 64);
y = gen_mtx(231, 64);
alpha = gko::initialize<Vec>({2.0}, ref);
beta = gko::initialize<Vec>({-1.0}, ref);
dmtx = Mtx::create(hip);
dmtx->copy_from(mtx.get());
dempty = Mtx::create(hip);
dresult = Vec::create(hip);
dresult->copy_from(expected.get());
dy = Vec::create(hip);
Expand All @@ -133,12 +135,14 @@ class Sellp : public ::testing::Test {
std::ranlux48 rand_engine;

std::unique_ptr<Mtx> mtx;
std::unique_ptr<Mtx> empty;
std::unique_ptr<Vec> expected;
std::unique_ptr<Vec> y;
std::unique_ptr<Vec> alpha;
std::unique_ptr<Vec> beta;

std::unique_ptr<Mtx> dmtx;
std::unique_ptr<Mtx> dempty;
std::unique_ptr<Vec> dresult;
std::unique_ptr<Vec> dy;
std::unique_ptr<Vec> dalpha;
Expand Down Expand Up @@ -280,6 +284,34 @@ TEST_F(Sellp, ConvertToCsrIsEquivalentToRef)
}


TEST_F(Sellp, ConvertEmptyToDenseIsEquivalentToRef)
{
set_up_apply_matrix();

auto dense_mtx = gko::matrix::Dense<>::create(ref);
auto ddense_mtx = gko::matrix::Dense<>::create(hip);

empty->convert_to(dense_mtx.get());
dempty->convert_to(ddense_mtx.get());

GKO_ASSERT_MTX_NEAR(dense_mtx.get(), ddense_mtx.get(), 0);
}


TEST_F(Sellp, ConvertEmptyToCsrIsEquivalentToRef)
{
set_up_apply_matrix();

auto csr_mtx = gko::matrix::Csr<>::create(ref);
auto dcsr_mtx = gko::matrix::Csr<>::create(hip);

empty->convert_to(csr_mtx.get());
dempty->convert_to(dcsr_mtx.get());

GKO_ASSERT_MTX_NEAR(csr_mtx.get(), dcsr_mtx.get(), 0);
}


TEST_F(Sellp, CountNonzerosIsEquivalentToRef)
{
set_up_apply_matrix();
Expand Down

0 comments on commit be178c8

Please sign in to comment.