Skip to content

Commit

Permalink
review updates
Browse files Browse the repository at this point in the history
Actually use the padded vector in coo_kernels tests,
and fix the resulting issues

Co-authored-by: Yuhsiang Tsai <yhmtsai@gmail.com>
  • Loading branch information
upsj and yhmtsai committed Jul 1, 2021
1 parent ca2c8cf commit aba4f73
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
5 changes: 1 addition & 4 deletions cuda/matrix/coo_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/matrix/dense.hpp>


#include "core/components/fill_array.hpp"
#include "core/matrix/dense_kernels.hpp"
#include "cuda/base/config.hpp"
#include "cuda/base/cusparse_bindings.hpp"
Expand Down Expand Up @@ -82,9 +81,7 @@ void spmv(std::shared_ptr<const CudaExecutor> exec,
const matrix::Coo<ValueType, IndexType> *a,
const matrix::Dense<ValueType> *b, matrix::Dense<ValueType> *c)
{
components::fill_array(exec, c->get_values(), c->get_num_stored_elements(),
zero<ValueType>());

dense::fill(exec, c, zero<ValueType>());
spmv2(exec, a, b, c);
}

Expand Down
8 changes: 4 additions & 4 deletions cuda/test/matrix/coo_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ TEST_F(Coo, SimpleApplyDoesntOverwritePadding)
dresult_padded->get_values() + 1);

mtx->apply(y.get(), expected.get());
dmtx->apply(dy.get(), dresult.get());
dmtx->apply(dy.get(), dresult_padded.get());

GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
GKO_ASSERT_MTX_NEAR(dresult_padded, expected, 1e-14);
ASSERT_EQ(cuda->copy_val_to_host(dresult_padded->get_values() + 1), 1234.0);
}

Expand Down Expand Up @@ -193,9 +193,9 @@ TEST_F(Coo, AdvancedApplyDoesntOverwritePadding)
dresult_padded->get_values() + 1);

mtx->apply(alpha.get(), y.get(), beta.get(), expected.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult_padded.get());

GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
GKO_ASSERT_MTX_NEAR(dresult_padded, expected, 1e-14);
ASSERT_EQ(cuda->copy_val_to_host(dresult_padded->get_values() + 1), 1234.0);
}

Expand Down
5 changes: 1 addition & 4 deletions hip/matrix/coo_kernels.hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/matrix/dense.hpp>


#include "core/components/fill_array.hpp"
#include "core/matrix/dense_kernels.hpp"
#include "hip/base/config.hip.hpp"
#include "hip/base/hipsparse_bindings.hip.hpp"
Expand Down Expand Up @@ -85,9 +84,7 @@ void spmv(std::shared_ptr<const HipExecutor> exec,
const matrix::Coo<ValueType, IndexType> *a,
const matrix::Dense<ValueType> *b, matrix::Dense<ValueType> *c)
{
components::fill_array(exec, c->get_values(), c->get_num_stored_elements(),
zero<ValueType>());

dense::fill(exec, c, zero<ValueType>());
spmv2(exec, a, b, c);
}

Expand Down
8 changes: 4 additions & 4 deletions hip/test/matrix/coo_kernels.hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ TEST_F(Coo, SimpleApplyDoesntOverwritePadding)
dresult_padded->get_values() + 1);

mtx->apply(y.get(), expected.get());
dmtx->apply(dy.get(), dresult.get());
dmtx->apply(dy.get(), dresult_padded.get());

GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
GKO_ASSERT_MTX_NEAR(dresult_padded, expected, 1e-14);
ASSERT_EQ(hip->copy_val_to_host(dresult_padded->get_values() + 1), 1234.0);
}

Expand Down Expand Up @@ -194,9 +194,9 @@ TEST_F(Coo, AdvancedApplyDoesntOverwritePadding)
dresult_padded->get_values() + 1);

mtx->apply(alpha.get(), y.get(), beta.get(), expected.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult_padded.get());

GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
GKO_ASSERT_MTX_NEAR(dresult_padded, expected, 1e-14);
ASSERT_EQ(hip->copy_val_to_host(dresult_padded->get_values() + 1), 1234.0);
}

Expand Down
8 changes: 4 additions & 4 deletions omp/test/matrix/coo_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ TEST_F(Coo, SimpleApplyDoesntOverwritePadding)
dresult_padded->get_values()[1] = 1234.0;

mtx->apply(y.get(), expected.get());
dmtx->apply(dy.get(), dresult.get());
dmtx->apply(dy.get(), dresult_padded.get());

GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
GKO_ASSERT_MTX_NEAR(dresult_padded, expected, 1e-14);
ASSERT_EQ(dresult_padded->get_values()[1], 1234.0);
}

Expand All @@ -193,9 +193,9 @@ TEST_F(Coo, AdvancedApplyDoesntOverwritePadding)
dresult_padded->get_values()[1] = 1234.0;

mtx->apply(alpha.get(), y.get(), beta.get(), expected.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult_padded.get());

GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
GKO_ASSERT_MTX_NEAR(dresult_padded, expected, 1e-14);
ASSERT_EQ(dresult_padded->get_values()[1], 1234.0);
}

Expand Down

0 comments on commit aba4f73

Please sign in to comment.