Skip to content

Commit

Permalink
rename precision chain
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Dec 2, 2024
1 parent edefdbd commit 18088d5
Show file tree
Hide file tree
Showing 70 changed files with 544 additions and 710 deletions.
8 changes: 4 additions & 4 deletions benchmark/utils/formats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ using hybrid = gko::matrix::Hybrid<etype, itype>;
using csr = gko::matrix::Csr<etype, itype>;
using coo = gko::matrix::Coo<etype, itype>;
using ell = gko::matrix::Ell<etype, itype>;
using ell_mixed = gko::matrix::Ell<gko::next_precision<etype>, itype>;
using ell_mixed = gko::matrix::Ell<gko::next_precision_base<etype>, itype>;


/**
Expand Down Expand Up @@ -274,7 +274,7 @@ std::unique_ptr<gko::LinOp> matrix_factory(
check_ell_admissibility(data);
}
if (format == "ell_mixed") {
gko::matrix_data<gko::next_precision<etype>, itype> conv_data;
gko::matrix_data<gko::next_precision_base<etype>, itype> conv_data;
conv_data.size = data.size;
conv_data.nonzeros.resize(data.nonzeros.size());
auto it = conv_data.nonzeros.begin();
Expand All @@ -284,8 +284,8 @@ std::unique_ptr<gko::LinOp> matrix_factory(
it->value = el.value;
++it;
}
gko::as<gko::ReadableFromMatrixData<gko::next_precision<etype>, itype>>(
mat.get())
gko::as<gko::ReadableFromMatrixData<gko::next_precision_base<etype>,
itype>>(mat.get())
->read(conv_data);
} else {
gko::as<gko::ReadableFromMatrixData<etype, itype>>(mat.get())->read(
Expand Down
10 changes: 4 additions & 6 deletions core/base/batch_multi_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void MultiVector<ValueType>::compute_norm2(

template <typename ValueType>
void MultiVector<ValueType>::convert_to(
MultiVector<next_precision_with_half<ValueType>>* result) const
MultiVector<next_precision<ValueType>>* result) const
{
result->values_ = this->values_;
result->set_size(this->get_size());
Expand All @@ -290,7 +290,7 @@ void MultiVector<ValueType>::convert_to(

template <typename ValueType>
void MultiVector<ValueType>::move_to(
MultiVector<next_precision_with_half<ValueType>>* result)
MultiVector<next_precision<ValueType>>* result)
{
this->convert_to(result);
}
Expand All @@ -299,8 +299,7 @@ void MultiVector<ValueType>::move_to(
#if GINKGO_ENABLE_HALF
template <typename ValueType>
void MultiVector<ValueType>::convert_to(
MultiVector<next_precision_with_half<next_precision_with_half<ValueType>>>*
result) const
MultiVector<next_precision<next_precision<ValueType>>>* result) const
{
result->values_ = this->values_;
result->set_size(this->get_size());
Expand All @@ -309,8 +308,7 @@ void MultiVector<ValueType>::convert_to(

template <typename ValueType>
void MultiVector<ValueType>::move_to(
MultiVector<next_precision_with_half<next_precision_with_half<ValueType>>>*
result)
MultiVector<next_precision<next_precision<ValueType>>>* result)
{
this->convert_to(result);
}
Expand Down
8 changes: 4 additions & 4 deletions core/distributed/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ Matrix<ValueType, LocalIndexType, GlobalIndexType>::create(

template <typename ValueType, typename LocalIndexType, typename GlobalIndexType>
void Matrix<ValueType, LocalIndexType, GlobalIndexType>::convert_to(
Matrix<next_precision<value_type>, local_index_type, global_index_type>*
result) const
Matrix<next_precision_base<value_type>, local_index_type,
global_index_type>* result) const
{
GKO_ASSERT(this->get_communicator().size() ==
result->get_communicator().size());
Expand All @@ -222,8 +222,8 @@ void Matrix<ValueType, LocalIndexType, GlobalIndexType>::convert_to(

template <typename ValueType, typename LocalIndexType, typename GlobalIndexType>
void Matrix<ValueType, LocalIndexType, GlobalIndexType>::move_to(
Matrix<next_precision<value_type>, local_index_type, global_index_type>*
result)
Matrix<next_precision_base<value_type>, local_index_type,
global_index_type>* result)
{
GKO_ASSERT(this->get_communicator().size() ==
result->get_communicator().size());
Expand Down
4 changes: 2 additions & 2 deletions core/distributed/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void Vector<ValueType>::fill(const ValueType value)

template <typename ValueType>
void Vector<ValueType>::convert_to(
Vector<next_precision<ValueType>>* result) const
Vector<next_precision_base<ValueType>>* result) const
{
GKO_ASSERT(this->get_communicator().size() ==
result->get_communicator().size());
Expand All @@ -293,7 +293,7 @@ void Vector<ValueType>::convert_to(


template <typename ValueType>
void Vector<ValueType>::move_to(Vector<next_precision<ValueType>>* result)
void Vector<ValueType>::move_to(Vector<next_precision_base<ValueType>>* result)
{
this->convert_to(result);
}
Expand Down
10 changes: 4 additions & 6 deletions core/matrix/batch_csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void Csr<ValueType, IndexType>::add_scaled_identity(

template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::convert_to(
Csr<next_precision_with_half<ValueType>, IndexType>* result) const
Csr<next_precision<ValueType>, IndexType>* result) const
{
result->values_ = this->values_;
result->col_idxs_ = this->col_idxs_;
Expand All @@ -257,7 +257,7 @@ void Csr<ValueType, IndexType>::convert_to(

template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::move_to(
Csr<next_precision_with_half<ValueType>, IndexType>* result)
Csr<next_precision<ValueType>, IndexType>* result)
{
this->convert_to(result);
}
Expand All @@ -266,8 +266,7 @@ void Csr<ValueType, IndexType>::move_to(
#if GINKGO_ENABLE_HALF
template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::convert_to(
Csr<next_precision_with_half<next_precision_with_half<ValueType>>,
IndexType>* result) const
Csr<next_precision<next_precision<ValueType>>, IndexType>* result) const
{
result->values_ = this->values_;
result->col_idxs_ = this->col_idxs_;
Expand All @@ -278,8 +277,7 @@ void Csr<ValueType, IndexType>::convert_to(

template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::move_to(
Csr<next_precision_with_half<next_precision_with_half<ValueType>>,
IndexType>* result)
Csr<next_precision<next_precision<ValueType>>, IndexType>* result)
{
this->convert_to(result);
}
Expand Down
11 changes: 4 additions & 7 deletions core/matrix/batch_dense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,15 @@ void Dense<ValueType>::add_scaled_identity(

template <typename ValueType>
void Dense<ValueType>::convert_to(
Dense<next_precision_with_half<ValueType>>* result) const
Dense<next_precision<ValueType>>* result) const
{
result->values_ = this->values_;
result->set_size(this->get_size());
}


template <typename ValueType>
void Dense<ValueType>::move_to(
Dense<next_precision_with_half<ValueType>>* result)
void Dense<ValueType>::move_to(Dense<next_precision<ValueType>>* result)
{
this->convert_to(result);
}
Expand All @@ -263,8 +262,7 @@ void Dense<ValueType>::move_to(
#if GINKGO_ENABLE_HALF
template <typename ValueType>
void Dense<ValueType>::convert_to(
Dense<next_precision_with_half<next_precision_with_half<ValueType>>>*
result) const
Dense<next_precision<next_precision<ValueType>>>* result) const
{
result->values_ = this->values_;
result->set_size(this->get_size());
Expand All @@ -273,8 +271,7 @@ void Dense<ValueType>::convert_to(

template <typename ValueType>
void Dense<ValueType>::move_to(
Dense<next_precision_with_half<next_precision_with_half<ValueType>>>*
result)
Dense<next_precision<next_precision<ValueType>>>* result)
{
this->convert_to(result);
}
Expand Down
10 changes: 4 additions & 6 deletions core/matrix/batch_ell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void Ell<ValueType, IndexType>::add_scaled_identity(

template <typename ValueType, typename IndexType>
void Ell<ValueType, IndexType>::convert_to(
Ell<next_precision_with_half<ValueType>, IndexType>* result) const
Ell<next_precision<ValueType>, IndexType>* result) const
{
result->values_ = this->values_;
result->col_idxs_ = this->col_idxs_;
Expand All @@ -277,7 +277,7 @@ void Ell<ValueType, IndexType>::convert_to(

template <typename ValueType, typename IndexType>
void Ell<ValueType, IndexType>::move_to(
Ell<next_precision_with_half<ValueType>, IndexType>* result)
Ell<next_precision<ValueType>, IndexType>* result)
{
this->convert_to(result);
}
Expand All @@ -286,8 +286,7 @@ void Ell<ValueType, IndexType>::move_to(
#if GINKGO_ENABLE_HALF
template <typename ValueType, typename IndexType>
void Ell<ValueType, IndexType>::convert_to(
Ell<next_precision_with_half<next_precision_with_half<ValueType>>,
IndexType>* result) const
Ell<next_precision<next_precision<ValueType>>, IndexType>* result) const
{
result->values_ = this->values_;
result->col_idxs_ = this->col_idxs_;
Expand All @@ -298,8 +297,7 @@ void Ell<ValueType, IndexType>::convert_to(

template <typename ValueType, typename IndexType>
void Ell<ValueType, IndexType>::move_to(
Ell<next_precision_with_half<next_precision_with_half<ValueType>>,
IndexType>* result)
Ell<next_precision<next_precision<ValueType>>, IndexType>* result)
{
this->convert_to(result);
}
Expand Down
10 changes: 4 additions & 6 deletions core/matrix/coo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void Coo<ValueType, IndexType>::apply2_impl(const LinOp* alpha, const LinOp* b,

template <typename ValueType, typename IndexType>
void Coo<ValueType, IndexType>::convert_to(
Coo<next_precision_with_half<ValueType>, IndexType>* result) const
Coo<next_precision<ValueType>, IndexType>* result) const
{
result->values_ = this->values_;
result->row_idxs_ = this->row_idxs_;
Expand All @@ -225,7 +225,7 @@ void Coo<ValueType, IndexType>::convert_to(

template <typename ValueType, typename IndexType>
void Coo<ValueType, IndexType>::move_to(
Coo<next_precision_with_half<ValueType>, IndexType>* result)
Coo<next_precision<ValueType>, IndexType>* result)
{
this->convert_to(result);
}
Expand All @@ -234,8 +234,7 @@ void Coo<ValueType, IndexType>::move_to(
#if GINKGO_ENABLE_HALF
template <typename ValueType, typename IndexType>
void Coo<ValueType, IndexType>::convert_to(
Coo<next_precision_with_half<next_precision_with_half<ValueType>>,
IndexType>* result) const
Coo<next_precision<next_precision<ValueType>>, IndexType>* result) const
{
result->values_ = this->values_;
result->row_idxs_ = this->row_idxs_;
Expand All @@ -246,8 +245,7 @@ void Coo<ValueType, IndexType>::convert_to(

template <typename ValueType, typename IndexType>
void Coo<ValueType, IndexType>::move_to(
Coo<next_precision_with_half<next_precision_with_half<ValueType>>,
IndexType>* result)
Coo<next_precision<next_precision<ValueType>>, IndexType>* result)
{
this->convert_to(result);
}
Expand Down
10 changes: 4 additions & 6 deletions core/matrix/csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void Csr<ValueType, IndexType>::apply_impl(const LinOp* alpha, const LinOp* b,

template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::convert_to(
Csr<next_precision_with_half<ValueType>, IndexType>* result) const
Csr<next_precision<ValueType>, IndexType>* result) const
{
result->values_ = this->values_;
result->col_idxs_ = this->col_idxs_;
Expand All @@ -316,16 +316,15 @@ void Csr<ValueType, IndexType>::convert_to(

template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::move_to(
Csr<next_precision_with_half<ValueType>, IndexType>* result)
Csr<next_precision<ValueType>, IndexType>* result)
{
this->convert_to(result);
}

#if GINKGO_ENABLE_HALF
template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::convert_to(
Csr<next_precision_with_half<next_precision_with_half<ValueType>>,
IndexType>* result) const
Csr<next_precision<next_precision<ValueType>>, IndexType>* result) const
{
result->values_ = this->values_;
result->col_idxs_ = this->col_idxs_;
Expand All @@ -337,8 +336,7 @@ void Csr<ValueType, IndexType>::convert_to(

template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::move_to(
Csr<next_precision_with_half<next_precision_with_half<ValueType>>,
IndexType>* result)
Csr<next_precision<next_precision<ValueType>>, IndexType>* result)
{
this->convert_to(result);
}
Expand Down
15 changes: 6 additions & 9 deletions core/matrix/dense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ Dense<ValueType>::Dense(Dense<ValueType>&& other) : Dense(other.get_executor())

template <typename ValueType>
void Dense<ValueType>::convert_to(
Dense<next_precision_with_half<ValueType>>* result) const
Dense<next_precision<ValueType>>* result) const
{
if (result->get_size() != this->get_size()) {
result->set_size(this->get_size());
Expand All @@ -597,8 +597,7 @@ void Dense<ValueType>::convert_to(


template <typename ValueType>
void Dense<ValueType>::move_to(
Dense<next_precision_with_half<ValueType>>* result)
void Dense<ValueType>::move_to(Dense<next_precision<ValueType>>* result)
{
this->convert_to(result);
}
Expand All @@ -607,8 +606,7 @@ void Dense<ValueType>::move_to(
#if GINKGO_ENABLE_HALF
template <typename ValueType>
void Dense<ValueType>::convert_to(
Dense<next_precision_with_half<next_precision_with_half<ValueType>>>*
result) const
Dense<next_precision<next_precision<ValueType>>>* result) const
{
if (result->get_size() != this->get_size()) {
result->set_size(this->get_size());
Expand All @@ -624,8 +622,7 @@ void Dense<ValueType>::convert_to(

template <typename ValueType>
void Dense<ValueType>::move_to(
Dense<next_precision_with_half<next_precision_with_half<ValueType>>>*
result)
Dense<next_precision<next_precision<ValueType>>>* result)
{
this->convert_to(result);
}
Expand Down Expand Up @@ -1548,8 +1545,8 @@ template <typename ValueType, typename Function>
void gather_mixed_real_complex(Function fn, LinOp* out)
{
#ifdef GINKGO_MIXED_PRECISION
run<matrix::Dense, ValueType, next_precision_with_half<ValueType>,
next_precision_with_half<next_precision_with_half<ValueType>>>(out, fn);
run<matrix::Dense, ValueType, next_precision<ValueType>,
next_precision<next_precision<ValueType>>>(out, fn);
#else
precision_dispatch<ValueType>(fn, out);
#endif
Expand Down
11 changes: 4 additions & 7 deletions core/matrix/diagonal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,15 @@ std::unique_ptr<LinOp> Diagonal<ValueType>::conj_transpose() const

template <typename ValueType>
void Diagonal<ValueType>::convert_to(
Diagonal<next_precision_with_half<ValueType>>* result) const
Diagonal<next_precision<ValueType>>* result) const
{
result->values_ = this->values_;
result->set_size(this->get_size());
}


template <typename ValueType>
void Diagonal<ValueType>::move_to(
Diagonal<next_precision_with_half<ValueType>>* result)
void Diagonal<ValueType>::move_to(Diagonal<next_precision<ValueType>>* result)
{
this->convert_to(result);
}
Expand All @@ -167,8 +166,7 @@ void Diagonal<ValueType>::move_to(
#if GINKGO_ENABLE_HALF
template <typename ValueType>
void Diagonal<ValueType>::convert_to(
Diagonal<next_precision_with_half<next_precision_with_half<ValueType>>>*
result) const
Diagonal<next_precision<next_precision<ValueType>>>* result) const
{
result->values_ = this->values_;
result->set_size(this->get_size());
Expand All @@ -177,8 +175,7 @@ void Diagonal<ValueType>::convert_to(

template <typename ValueType>
void Diagonal<ValueType>::move_to(
Diagonal<next_precision_with_half<next_precision_with_half<ValueType>>>*
result)
Diagonal<next_precision<next_precision<ValueType>>>* result)
{
this->convert_to(result);
}
Expand Down
Loading

0 comments on commit 18088d5

Please sign in to comment.