-
Notifications
You must be signed in to change notification settings - Fork 88
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
ginkgo own ILU and IC #1684
base: develop
Are you sure you want to change the base?
ginkgo own ILU and IC #1684
Conversation
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 questions and comments, but overall I am excited about this! Thanks @yhmtsai
core/factorization/ilu.cpp
Outdated
local_system_matrix->get_const_row_ptrs()))); | ||
ilu = | ||
gko::experimental::factorization::Lu<ValueType, IndexType>::build() | ||
.with_checked_lookup(true) |
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.
Same here, would prefer with_safe_lookup
or something like that, personally.
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.
IMO this should rather be a new type, LU and ILU(...) have very different use cases. That would also allow us to build a new, improved ILU preconditioner interface based on the Factorization
type instead of the slightly hacky Composition
-like type ILU is currently.
* syncfree is Ginkgo's implementation through the Lu factorization with given | ||
* sparsity. | ||
*/ | ||
enum class factorize_algorithm { sparselib, syncfree }; |
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.
Since this is specific to incomplete factorizations only (at least for now), would it be better to use ilu_algorithm
or something like that? Since it's only in the factorization
namespace, nothing specific about ILU there.
Also, nit: cuda
and hip
aren't capitalized here, but they are in the comment for the factory parameter. I think we should be consistent: either Cuda
/Hip
(like the Executors) or CUDA
/HIP
(correct names for the actual software).
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 will also use it to IC, so it will be for incomplete factorize algorithm at least.
maybe incomplete_factorize_algorithm
if the original one is too general?
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.
That makes sense. I'm mostly thinking about code readability/logicality on the user side. I do think it would be good to specify that this is only for incomplete somehow, though incomplete_factorize_algorithm
is pretty long. What if we had the same enum for both ilu and ic but with different names (ilu_algorithm
and ic_algorithm
)? But we can also go with the longer name. Maybe @upsj has thoughts on this?
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.
Thanks Mike, I'm happy to see how simple this was to extend to ILU. Some design and naming suggestions I'd like to see discussed, and maybe we should build a roadmap for the future ILU preconditioner interface.
core/factorization/factorization.cpp
Outdated
@@ -31,10 +31,25 @@ GKO_REGISTER_OPERATION(initialize_l, factorization::initialize_l); | |||
|
|||
template <typename ValueType, typename IndexType> | |||
std::unique_ptr<Factorization<ValueType, IndexType>> | |||
Factorization<ValueType, IndexType>::unpack() const | |||
Factorization<ValueType, IndexType>::unpack( |
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 think we want to improve the strategy type with 2.0 (or earlier), and the strategies have no impact on triangular solvers, so I think we should avoid adding new strategy-related functionality.
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 do not think 2.0 happens soon
if we do not want to introduce here, I can only unpack them by original code path not the unpack them.
@nbeams it should be fine, right? the unpacking codes are the same.
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.
You mean revert back to before 57c0051? It should be fine, as far as I know. I tested it before this commit, anyway.
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.
Yes.
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.
A few more minor comments, but most of my questions/issues have been addressed.
* false in order to avoid the possibility of hanging or illegal memory | ||
* accesses during the factorization process. When this is true, the | ||
* symbolic factorization must still contain the non-zero locations in | ||
* the original matrix, at minimum. | ||
*/ |
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.
Comment needs another update after the logic switch -- now "When this is true, the symbolic factorization must still contain the non-zero locations in the original matrix, at minimum" sounds like it's saying this is a requirement when the parameter is true, while it's the opposite. Maybe we can make it even more explicit, like "When not using all fill-in, ..."
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.
the later part is wrong. it tries to describe the information when the setting is true.
I have updated and reorganize it.
core/factorization/lu.cpp
Outdated
@@ -69,6 +69,9 @@ Lu<ValueType, IndexType>::parse(const config::pnode& config, | |||
if (auto& obj = config.get("skip_sorting")) { | |||
params.with_skip_sorting(config::get_value<bool>(obj)); | |||
} | |||
if (auto& obj = config.get("has_all_fillin")) { | |||
params.with_has_all_fillin(config::get_value<bool>(obj)); |
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 don't like has_all_fillin
because of this -- that we end up with with_has_all_fillin
which sounds very clunky to me. What about full_fillin
as the param name so we get with_full_fillin
?
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.
sounds good to me.
Do you think it will be a bit misleading for the case we were discussing, the factorization does not contains all values from the matrices?
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.
In what scenario are you envisioning it could be misleading? I.e., what use case? If the factorization does not contain all values from the original matrix, then full_fillin
would be false, as it should be, no?
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.
Also, based on the updated comment in lu.hpp
(the above coversation), a factorization that doesn't contain all the locations from the original matrix currently isn't allowed, anyway, right?
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.
right. The current version can not work with the factorization misses some entries from the original matrix. I just wonder whether should consider the situation when the factorization does not contains the nonzeros from the original matrix. To do so, we also need to adapt it in the initialize
function. When we allow thissituation, we definitely do not want to introduce another option to enable it.
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.
Oh, I see -- just looking to the future. I don't think it's a problem, personally -- I think "fill-in" is pretty well-understood to mean "all the additional locations of the factorization vs original matrix" so I don't think there'd be any confusion that it's meant to differentiate between incomplete factorization with or without all the original matrix locations.
- bitmap: lead wrong answer or segfault - hashmap: infinite loop
…pposite behavior). Co-authored-by: Tobias Ribizel <ribizel@kit.edu> Co-authored-by: Natalie Beams <246972+nbeams@users.noreply.github.com>
…rategy" to avoid new strategy input
|
||
/** | ||
* If the user provides the symbolic factorization, it should contain | ||
* the fill-in for the matrix. i.e., When this is true, the symbolic | ||
* factorization must contain the non-zero locations in the original | ||
* matrix and the corresponding fill-in locations during factorization. | ||
* If it does not have full fill-in, as in Ilu, this parameter must be | ||
* set to false in order to avoid the possibility of hanging or illegal | ||
* memory accesses during the factorization process. | ||
*/ | ||
bool GKO_FACTORY_PARAMETER_SCALAR(full_fillin, true); |
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.
Why this parameter? This goes against the name LU, and could as well be handled by ILU, if we hand in the sparsity pattern there as a new parameter.
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.
does it go against LU? I try to avoid copying half of functions from lu to ilu.
We do not need the sparsity pattern in ilu currently because we use the same sparsity of the matrix
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.
In its current form they use the same algorithm, but adding this parameter prevents future evolution taking advantage of structural properties of an LU that an ILU doesn't have.
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 you elaborate more?
@nbeams I assume you use the ILU on your side now not the LU interface, right?
I will copy some function into ILU.
It should still work with ILU-only interface for the case we discussed above in the future
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.
have copied
|
||
/** | ||
* If the user provides the symbolic factorization, it should contain | ||
* the fill-in for the matrix. i.e., When this is true, the symbolic | ||
* factorization must contain the non-zero locations in the original | ||
* matrix and the corresponding fill-in locations during factorization. | ||
* If it does not have full fill-in, as in Ilu, this parameter must be | ||
* set to false in order to avoid the possibility of hanging or illegal | ||
* memory accesses during the factorization process. Also, the symbolic | ||
* factorization still needs to contain all entries from the original | ||
* matrix. | ||
*/ | ||
bool GKO_FACTORY_PARAMETER_SCALAR(full_fillin, true); |
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.
Same here
Co-authored-by: Tobias Ribizel <ribizel@kit.edu>
This pr enables the ginkgo's implementation ILU through the current LU implementation.
To enable that, we need to allow LU can ignore the missing fill-in entries.
It is controlled by checked_lookup parameter, and user needs to pass the same sparsityCsr as the original one as the symbolic factor to get ILU.
Moreover, this pr also adds a parameter for algorithm selection. It will forward the information to LU and unpack them directly to return the same structure as the original sparselib.
Note. LU by default gives combined matrix but ILU gives the composition.
The first commit shows that the hashmap lookup leads the hang issue and bitmap lookup leads illegal memory access (incorrect result with -1 index return).
The second commit shows the results are wrong if we do not ignore missing fill-in entries update after fixing infinite loop of hashmap lookup
After this pr, we provide another way to factorize ILU without relying on the sparse library.
TODO