Skip to content

Commit 8c5883a

Browse files
upsjMarcelKoch
andcommitted
review updates
- rename add_scale to scale_add - remove unused variables Co-authored-by: Marcel Koch <[email protected]>
1 parent b015950 commit 8c5883a

File tree

5 files changed

+51
-52
lines changed

5 files changed

+51
-52
lines changed

benchmark/sparse_blas/operations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class SpgeamOperation : public BenchmarkOperation {
272272

273273
void prepare() override {}
274274

275-
void run() override { mtx_out_ = mtx_->add_scale(scalar_, scalar_, mtx2_); }
275+
void run() override { mtx_out_ = mtx_->scale_add(scalar_, scalar_, mtx2_); }
276276

277277
private:
278278
const Mtx* mtx_;

core/matrix/csr.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ Csr<ValueType, IndexType>::multiply_add_reuse(
887887

888888

889889
template <typename ValueType, typename IndexType>
890-
std::unique_ptr<Csr<ValueType, IndexType>> Csr<ValueType, IndexType>::add_scale(
890+
std::unique_ptr<Csr<ValueType, IndexType>> Csr<ValueType, IndexType>::scale_add(
891891
ptr_param<const Dense<value_type>> scale_this,
892892
ptr_param<const Dense<value_type>> scale_other,
893893
ptr_param<const Csr> mtx_other) const
@@ -908,43 +908,43 @@ std::unique_ptr<Csr<ValueType, IndexType>> Csr<ValueType, IndexType>::add_scale(
908908

909909

910910
template <typename ValueType, typename IndexType>
911-
Csr<ValueType, IndexType>::add_scale_reuse_info::add_scale_reuse_info() =
911+
Csr<ValueType, IndexType>::scale_add_reuse_info::scale_add_reuse_info() =
912912
default;
913913

914914

915915
template <typename ValueType, typename IndexType>
916-
Csr<ValueType, IndexType>::add_scale_reuse_info::add_scale_reuse_info(
916+
Csr<ValueType, IndexType>::scale_add_reuse_info::scale_add_reuse_info(
917917
std::unique_ptr<lookup_data> data)
918918
: internal{std::move(data)}
919919
{}
920920

921921

922922
template <typename ValueType, typename IndexType>
923-
Csr<ValueType, IndexType>::add_scale_reuse_info::~add_scale_reuse_info() =
923+
Csr<ValueType, IndexType>::scale_add_reuse_info::~scale_add_reuse_info() =
924924
default;
925925

926926

927927
template <typename ValueType, typename IndexType>
928-
Csr<ValueType, IndexType>::add_scale_reuse_info::add_scale_reuse_info(
929-
add_scale_reuse_info&&) noexcept = default;
928+
Csr<ValueType, IndexType>::scale_add_reuse_info::scale_add_reuse_info(
929+
scale_add_reuse_info&&) noexcept = default;
930930

931931

932932
template <typename ValueType, typename IndexType>
933-
typename Csr<ValueType, IndexType>::add_scale_reuse_info&
934-
Csr<ValueType, IndexType>::add_scale_reuse_info::operator=(
935-
add_scale_reuse_info&&) noexcept = default;
933+
typename Csr<ValueType, IndexType>::scale_add_reuse_info&
934+
Csr<ValueType, IndexType>::scale_add_reuse_info::operator=(
935+
scale_add_reuse_info&&) noexcept = default;
936936

937937

938938
template <typename ValueType, typename IndexType>
939-
void Csr<ValueType, IndexType>::add_scale_reuse_info::update_values(
939+
void Csr<ValueType, IndexType>::scale_add_reuse_info::update_values(
940940
ptr_param<const Dense<value_type>> scale1, ptr_param<const Csr> mtx1,
941941
ptr_param<const Dense<value_type>> scale2, ptr_param<const Csr> mtx2,
942942
ptr_param<Csr> out) const
943943
{
944944
if (!internal) {
945945
throw InvalidStateError{
946946
__FILE__, __LINE__, __func__,
947-
"Attempting to use uninitialized add_scale_reuse_info"};
947+
"Attempting to use uninitialized scale_add_reuse_info"};
948948
}
949949
auto exec = internal->exec;
950950
GKO_ASSERT_EQUAL_DIMENSIONS(mtx1, internal->size);
@@ -967,7 +967,7 @@ void Csr<ValueType, IndexType>::add_scale_reuse_info::update_values(
967967

968968

969969
template <typename ValueType, typename IndexType>
970-
struct Csr<ValueType, IndexType>::add_scale_reuse_info::lookup_data {
970+
struct Csr<ValueType, IndexType>::scale_add_reuse_info::lookup_data {
971971
std::shared_ptr<const Executor> exec;
972972
dim<2> size;
973973
size_type nnz1;
@@ -979,7 +979,7 @@ struct Csr<ValueType, IndexType>::add_scale_reuse_info::lookup_data {
979979

980980
template <typename ValueType, typename IndexType>
981981
std::pair<std::unique_ptr<Csr<ValueType, IndexType>>,
982-
typename Csr<ValueType, IndexType>::add_scale_reuse_info>
982+
typename Csr<ValueType, IndexType>::scale_add_reuse_info>
983983
Csr<ValueType, IndexType>::add_scale_reuse(
984984
ptr_param<const Dense<value_type>> scale_this,
985985
ptr_param<const Dense<value_type>> scale_other,
@@ -998,9 +998,9 @@ Csr<ValueType, IndexType>::add_scale_reuse(
998998
result.get()));
999999
return std::make_pair(
10001000
std::move(result),
1001-
add_scale_reuse_info{
1002-
std::make_unique<typename add_scale_reuse_info::lookup_data>(
1003-
typename add_scale_reuse_info::lookup_data{
1001+
scale_add_reuse_info{
1002+
std::make_unique<typename scale_add_reuse_info::lookup_data>(
1003+
typename scale_add_reuse_info::lookup_data{
10041004
exec, this->get_size(), this->get_num_stored_elements(),
10051005
mtx_other->get_num_stored_elements(),
10061006
result->get_num_stored_elements()})});

include/ginkgo/core/matrix/csr.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -930,24 +930,24 @@ class Csr : public EnableLinOp<Csr<ValueType, IndexType>>,
930930

931931
/**
932932
* Class describing the internal lookup structures created by
933-
* add_reuse to recompute a sparse matrix-matrix sum
933+
* scale_add_reuse to recompute a sparse matrix-matrix sum
934934
* with updated values.
935935
*/
936-
class add_scale_reuse_info {
936+
class scale_add_reuse_info {
937937
friend class Csr;
938938

939939
public:
940-
explicit add_scale_reuse_info();
940+
explicit scale_add_reuse_info();
941941

942-
~add_scale_reuse_info();
942+
~scale_add_reuse_info();
943943

944-
add_scale_reuse_info(const add_scale_reuse_info&) = delete;
944+
scale_add_reuse_info(const scale_add_reuse_info&) = delete;
945945

946-
add_scale_reuse_info(add_scale_reuse_info&&) noexcept;
946+
scale_add_reuse_info(scale_add_reuse_info&&) noexcept;
947947

948-
add_scale_reuse_info& operator=(const add_scale_reuse_info&) = delete;
948+
scale_add_reuse_info& operator=(const scale_add_reuse_info&) = delete;
949949

950-
add_scale_reuse_info& operator=(add_scale_reuse_info&&) noexcept;
950+
scale_add_reuse_info& operator=(scale_add_reuse_info&&) noexcept;
951951

952952
/**
953953
* Recomputes the sparse matrix-matrix sum
@@ -963,7 +963,7 @@ class Csr : public EnableLinOp<Csr<ValueType, IndexType>>,
963963
private:
964964
struct lookup_data;
965965

966-
explicit add_scale_reuse_info(std::unique_ptr<lookup_data> data);
966+
explicit scale_add_reuse_info(std::unique_ptr<lookup_data> data);
967967

968968
std::unique_ptr<lookup_data> internal;
969969
};
@@ -982,7 +982,7 @@ class Csr : public EnableLinOp<Csr<ValueType, IndexType>>,
982982
* @return the result of the computation, stored on the same executor as
983983
* this matrix.
984984
*/
985-
std::unique_ptr<Csr> add_scale(
985+
std::unique_ptr<Csr> scale_add(
986986
ptr_param<const Dense<value_type>> scale_this,
987987
ptr_param<const Dense<value_type>> scale_other,
988988
ptr_param<const Csr> mtx_other) const;
@@ -1005,10 +1005,10 @@ class Csr : public EnableLinOp<Csr<ValueType, IndexType>>,
10051005
* scale_other. It needs to be sorted by column index,
10061006
* otherwise the result will be incorrect.
10071007
* @return std::pair containing the result of the computation, stored on
1008-
* the same executor as this matrix, and a add_scale_reuse_info
1008+
* the same executor as this matrix, and a scale_add_reuse_info
10091009
* object allowing value updates to the output matrix.
10101010
*/
1011-
std::pair<std::unique_ptr<Csr>, add_scale_reuse_info> add_scale_reuse(
1011+
std::pair<std::unique_ptr<Csr>, scale_add_reuse_info> add_scale_reuse(
10121012
ptr_param<const Dense<value_type>> scale_this,
10131013
ptr_param<const Dense<value_type>> scale_other,
10141014
ptr_param<const Csr> mtx_other) const;

reference/test/matrix/csr_kernels.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,6 @@ TYPED_TEST(Csr, MultipliesReuseUpdateWithCsrMatrix)
755755
using Vec = typename TestFixture::Vec;
756756
using T = typename TestFixture::value_type;
757757
auto [result, reuse] = this->mtx->multiply_reuse(this->mtx3_unsorted);
758-
auto orig_result = result->clone();
759758
auto alpha = gko::initialize<Vec>({-1.0}, this->exec);
760759
auto beta = gko::initialize<Vec>({2.0}, this->exec);
761760
this->mtx->scale(alpha);
@@ -921,7 +920,7 @@ TYPED_TEST(Csr, AppliesLinearCombinationToIdentityMatrix)
921920
}
922921

923922

924-
TYPED_TEST(Csr, AddsScaleCsrMatrices)
923+
TYPED_TEST(Csr, ScaleAddCsrMatrices)
925924
{
926925
using T = typename TestFixture::value_type;
927926
using Vec = typename TestFixture::Vec;
@@ -944,15 +943,15 @@ TYPED_TEST(Csr, AddsScaleCsrMatrices)
944943
I<T>{0.0, 0.0, 0.0}},
945944
this->exec);
946945

947-
auto result = a->add_scale(alpha, beta, b);
946+
auto result = a->scale_add(alpha, beta, b);
948947

949948
GKO_ASSERT_MTX_NEAR(result, expect, r<T>::value);
950949
GKO_ASSERT_MTX_EQ_SPARSITY(expect, result);
951950
ASSERT_TRUE(result->is_sorted_by_column_index());
952951
}
953952

954953

955-
TYPED_TEST(Csr, AddsScaleReuseCsrMatrices)
954+
TYPED_TEST(Csr, ScaleAddReuseCsrMatrices)
956955
{
957956
using T = typename TestFixture::value_type;
958957
using Vec = typename TestFixture::Vec;
@@ -972,13 +971,13 @@ TYPED_TEST(Csr, AddsScaleReuseCsrMatrices)
972971

973972
auto [result, reuse] = a->add_scale_reuse(alpha, beta, b);
974973

975-
auto expected = a->add_scale(alpha, beta, b);
974+
auto expected = a->scale_add(alpha, beta, b);
976975
GKO_ASSERT_MTX_EQ_SPARSITY(expected, result);
977976
ASSERT_TRUE(result->is_sorted_by_column_index());
978977
}
979978

980979

981-
TYPED_TEST(Csr, AddsScaleReuseUpdateCsrMatrices)
980+
TYPED_TEST(Csr, ScaleAddReuseUpdateCsrMatrices)
982981
{
983982
using T = typename TestFixture::value_type;
984983
using Vec = typename TestFixture::Vec;
@@ -1000,7 +999,7 @@ TYPED_TEST(Csr, AddsScaleReuseUpdateCsrMatrices)
1000999
auto zero = gko::initialize<Vec>({0.0}, this->exec);
10011000
std::fill_n(zero_a->get_values(), a->get_num_stored_elements(), T{});
10021001
std::fill_n(zero_b->get_values(), b->get_num_stored_elements(), T{});
1003-
auto expected = a->add_scale(alpha, beta, b);
1002+
auto expected = a->scale_add(alpha, beta, b);
10041003
auto [result, reuse] = zero_a->add_scale_reuse(zero, zero, zero_b);
10051004

10061005
reuse.update_values(alpha, a, beta, b, result);
@@ -1079,7 +1078,7 @@ TYPED_TEST(Csr, MultiplyAddReuseFailsOnWrongDimensions)
10791078
}
10801079

10811080

1082-
TYPED_TEST(Csr, AddScaleFailsOnWrongDimensions)
1081+
TYPED_TEST(Csr, ScaleAddFailsOnWrongDimensions)
10831082
{
10841083
using Vec = typename TestFixture::Vec;
10851084
auto s = gko::initialize<Vec>({0.0}, this->exec);
@@ -1088,13 +1087,13 @@ TYPED_TEST(Csr, AddScaleFailsOnWrongDimensions)
10881087
auto& m2 = this->mtx2;
10891088
auto& m3 = this->mtx3_sorted;
10901089

1091-
ASSERT_THROW(m1->add_scale(v, s, m2), gko::DimensionMismatch);
1092-
ASSERT_THROW(m1->add_scale(s, v, m2), gko::DimensionMismatch);
1093-
ASSERT_THROW(m1->add_scale(s, s, m3), gko::DimensionMismatch);
1090+
ASSERT_THROW(m1->scale_add(v, s, m2), gko::DimensionMismatch);
1091+
ASSERT_THROW(m1->scale_add(s, v, m2), gko::DimensionMismatch);
1092+
ASSERT_THROW(m1->scale_add(s, s, m3), gko::DimensionMismatch);
10941093
}
10951094

10961095

1097-
TYPED_TEST(Csr, AddScaleReuseFailsOnWrongDimensions)
1096+
TYPED_TEST(Csr, ScaleAddReuseFailsOnWrongDimensions)
10981097
{
10991098
using Vec = typename TestFixture::Vec;
11001099
using Mtx = typename TestFixture::Mtx;

test/matrix/csr_kernels2.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -697,30 +697,30 @@ TEST_F(Csr, AdvancedApplyToIdentityMatrixIsEquivalentToRef)
697697
}
698698

699699

700-
TEST_F(Csr, AddScaleZeroIsEquivalentToRef)
700+
TEST_F(Csr, ScaleAddZeroIsEquivalentToRef)
701701
{
702702
set_up_apply_data<Mtx::classical>();
703703
auto a = Mtx::create(ref);
704704
auto b = Mtx::create(ref);
705705
auto da = gko::clone(exec, a);
706706
auto db = gko::clone(exec, b);
707707

708-
auto result = a->add_scale(alpha, beta, b);
709-
auto dresult = da->add_scale(dalpha, dbeta, db);
708+
auto result = a->scale_add(alpha, beta, b);
709+
auto dresult = da->scale_add(dalpha, dbeta, db);
710710

711711
GKO_ASSERT_MTX_NEAR(result, dresult, 0);
712712
}
713713

714714

715-
TEST_F(Csr, AddScaleIsEquivalentToRefCrossExecutor)
715+
TEST_F(Csr, ScaleAddIsEquivalentToRefCrossExecutor)
716716
{
717717
set_up_apply_data<Mtx::classical>();
718718
auto a = gen_mtx<Mtx>(mtx_size[0], mtx_size[1], 0);
719719
auto b = gen_mtx<Mtx>(mtx_size[0], mtx_size[1], 0);
720720
auto da = gko::clone(exec, a);
721721

722-
auto result = a->add_scale(alpha, beta, b);
723-
auto dresult = da->add_scale(alpha, beta, b);
722+
auto result = a->scale_add(alpha, beta, b);
723+
auto dresult = da->scale_add(alpha, beta, b);
724724

725725
GKO_ASSERT_MTX_NEAR(result, dresult, r<value_type>::value);
726726
GKO_ASSERT_MTX_EQ_SPARSITY(result, dresult);
@@ -729,15 +729,15 @@ TEST_F(Csr, AddScaleIsEquivalentToRefCrossExecutor)
729729
}
730730

731731

732-
TEST_F(Csr, AddScaleReuseCrossExecutor)
732+
TEST_F(Csr, ScaleAddReuseCrossExecutor)
733733
{
734734
set_up_apply_data<Mtx::classical>();
735735
mtx = gen_mtx<Mtx>(mtx_size[0], mtx_size[1], 0);
736736
mtx2 = gen_mtx<Mtx>(mtx_size[0], mtx_size[1], 0);
737737
dmtx = gko::clone(exec, mtx);
738738

739739
auto [dresult, _dreuse] = dmtx->add_scale_reuse(alpha, beta, mtx2);
740-
auto expected = dmtx->add_scale(alpha, beta, mtx2);
740+
auto expected = dmtx->scale_add(alpha, beta, mtx2);
741741
auto result = expected->clone();
742742

743743
GKO_ASSERT_MTX_EQ_SPARSITY(dresult, expected);
@@ -747,22 +747,22 @@ TEST_F(Csr, AddScaleReuseCrossExecutor)
747747
}
748748

749749

750-
TEST_F(Csr, AddScaleReuseUpdateCrossExecutor)
750+
TEST_F(Csr, ScaleAddReuseUpdateCrossExecutor)
751751
{
752752
set_up_apply_data<Mtx::classical>();
753753
mtx = gen_mtx<Mtx>(mtx_size[0], mtx_size[1], 0);
754754
mtx2 = gen_mtx<Mtx>(mtx_size[0], mtx_size[1], 0);
755755
dmtx = gko::clone(exec, mtx);
756756
auto [dresult, dreuse] = dmtx->add_scale_reuse(alpha, beta, mtx2);
757-
auto expected = dmtx->add_scale(alpha, beta, mtx2);
757+
auto expected = dmtx->scale_add(alpha, beta, mtx2);
758758
auto result = expected->clone();
759759
// modify all involved matrices and scalars
760760
dmtx->scale(beta);
761761
mtx2->scale(alpha);
762762
alpha->scale(alpha);
763763
beta->scale(beta);
764764

765-
expected = dmtx->add_scale(alpha, beta, mtx2);
765+
expected = dmtx->scale_add(alpha, beta, mtx2);
766766
mtx = gko::clone(ref, dmtx);
767767
dreuse.update_values(alpha, mtx, beta, mtx2, result);
768768

0 commit comments

Comments
 (0)