-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixed Precision ISAI #719
Mixed Precision ISAI #719
Conversation
format! |
Codecov Report
@@ Coverage Diff @@
## develop #719 +/- ##
========================================
Coverage 94.17% 94.18%
========================================
Files 400 400
Lines 31051 31084 +33
========================================
+ Hits 29241 29275 +34
+ Misses 1810 1809 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some parts that I would really like to change before merging this PR.
Additionally, I realized that it might make sense to make SpdIsai
and GeneralIsai
separate classes or at least specialization of the current Isai
because:
- they seem to not share too much with
LowerIsai
andUpperIsai
- there is a lot of branching in all functions
- all
Isai
preconditioner (includingLowerIsai
andUpperIsai
) are stored in ELL in the current implementation get_approximate_inverse
has a lot of overhead now
template <typename OutType, typename InType> | ||
std::shared_ptr<OutType> convert_matrix_formats( | ||
std::shared_ptr<InType> in) const | ||
{ | ||
if (std::is_same<OutType, InType>::value) { | ||
return as<OutType>(in); | ||
} | ||
|
||
auto out = OutType::create(in->get_executor()); | ||
if (std::is_same< | ||
InType, gko::matrix::Csr<typename InType::value_type, | ||
typename InType::index_type>>::value) { | ||
auto tmp = gko::matrix::Csr< | ||
typename OutType::value_type, | ||
typename InType::index_type>::create(in->get_executor()); | ||
as<Csr>(in)->convert_to(tmp.get()); | ||
tmp->convert_to(out.get()); | ||
return share(out); | ||
} else { | ||
auto tmp = gko::matrix::Ell< | ||
typename OutType::value_type, | ||
typename InType::index_type>::create(in->get_executor()); | ||
as<Ell>(in)->convert_to(tmp.get()); | ||
tmp->convert_to(out.get()); | ||
return share(out); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some problems with this function:
- It should be private to not be part of the public interface
- It needs documentation
- The function can only convert CSR <-> ELL and not arbitrary conversions (which the use of templates suggest)
SonarCloud Quality Gate failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Some minor comments.
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general. To be honest though, I would rather want to wait for full mixed-precision support in Csr instead of choosing Ell just because it is the only type where we put in the effort to make it mixed-precision capable. Coo would probably also be alternative with low development effort for the changes, and could provide much better worst-case performance.
Isai<IsaiType == isai_type::lower | ||
? isai_type::upper | ||
: IsaiType == isai_type::upper ? isai_type::lower : IsaiType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we move this into a
constexpr isai_type transpose(isai_type type) {
return type == isai_type::lower ? isai_type::upper : type == isai_type::upper ? isai_type::lower : type;
}
function?
Isai<IsaiType == isai_type::lower | |
? isai_type::upper | |
: IsaiType == isai_type::upper ? isai_type::lower : IsaiType, | |
Isai<transpose(IsaiType), |
I think this PR may be obsolete with Csr now being mixed-precision capable? |
Yes, I will close it. |
This PR makes the ISAI preconditioner support reduced precision storage format.
It is based on Tobias' mp spmv approach for ell, which is slightly changed to use an accessor on both the matrix values and the input vector, for now always using the ValueType of the output vector as arithmetic type.
Points I would like to discuss are:
GKO_INSTANTIATE_FOR_EACH_VALUE_INDEX_AND_STORAGE_TYPE
in types.hpp to make this work. I'm not really happy with having this additional to the mixed value and index types Tobias already introduced, maybe we can find a better way.Todos: