-
Notifications
You must be signed in to change notification settings - Fork 0
[Mirror] MueLu: Kokkos::abort if a NaN or inf is encountered in SOC algorithms #71
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -609,6 +609,7 @@ class DropFunctor { | |
| } | ||
| #endif | ||
|
|
||
| bool nonFiniteValueEncountered = false; | ||
| for (local_ordinal_type k = 0; k < row.length; ++k) { | ||
| auto clid = row.colidx(k); | ||
|
|
||
|
|
@@ -623,11 +624,14 @@ class DropFunctor { | |
| auto aiiajj = ATS::magnitude(diag(rlid)) * ATS::magnitude(diag(clid)); // |a_ii|*|a_jj| | ||
| auto aij2 = ATS::magnitude(val) * ATS::magnitude(val); // |a_ij|^2 | ||
|
|
||
| nonFiniteValueEncountered |= !is_finite_type_safe(aiiajj) || !is_finite_type_safe(aij2); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check |
||
|
|
||
| results(offset + k) = Kokkos::max((aij2 <= eps * eps * aiiajj) ? DROP : KEEP, | ||
| results(offset + k)); | ||
| } else if constexpr (measure == Misc::SignedRugeStuebenMeasure) { | ||
| auto neg_aij = -ATS::real(val); | ||
| auto max_neg_aik = eps * ATS::real(diag(rlid)); | ||
| auto neg_aij = -ATS::real(val); | ||
| auto max_neg_aik = eps * ATS::real(diag(rlid)); | ||
| nonFiniteValueEncountered |= !is_finite_type_safe(neg_aij) || !is_finite_type_safe(max_neg_aik); | ||
| results(offset + k) = Kokkos::max((neg_aij < max_neg_aik) ? DROP : KEEP, | ||
| results(offset + k)); | ||
| } else if constexpr (measure == Misc::SignedSmoothedAggregationMeasure) { | ||
|
|
@@ -637,10 +641,19 @@ class DropFunctor { | |
| // + |a_ij|^2, if a_ij < 0, - |a_ij|^2 if a_ij >=0 | ||
| if (!is_nonpositive) | ||
| aij2 = -aij2; | ||
| nonFiniteValueEncountered |= !is_finite_type_safe(aiiajj) || !is_finite_type_safe(aij2); | ||
| results(offset + k) = Kokkos::max((aij2 <= eps * eps * aiiajj) ? DROP : KEEP, | ||
| results(offset + k)); | ||
| } | ||
| } | ||
|
|
||
| if (nonFiniteValueEncountered) { | ||
| const char* message = | ||
| "Error encountered in MueLu::DistanceLaplacian::DropFunctor::operator():\n" | ||
| "Non-finite values encountered in strength-of-connection measure.\n" | ||
| "A potential fix is to enable rebalancing and/or perform an initial rebalance.\n"; | ||
| Kokkos::abort(message); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -736,6 +749,7 @@ class VectorDropFunctor { | |
| } | ||
| #endif | ||
|
|
||
| bool nonFiniteValueEncountered = false; | ||
| for (local_ordinal_type k = 0; k < row.length; ++k) { | ||
| auto clid = row.colidx(k); | ||
| auto bclid = ghosted_point_to_block(clid); | ||
|
|
@@ -751,11 +765,14 @@ class VectorDropFunctor { | |
| auto aiiajj = ATS::magnitude(diag(brlid)) * ATS::magnitude(diag(bclid)); // |a_ii|*|a_jj| | ||
| auto aij2 = ATS::magnitude(val) * ATS::magnitude(val); // |a_ij|^2 | ||
|
|
||
| nonFiniteValueEncountered |= !is_finite_type_safe(aiiajj) || !is_finite_type_safe(aij2); | ||
|
|
||
| results(offset + k) = Kokkos::max((aij2 <= eps * eps * aiiajj) ? DROP : KEEP, | ||
| results(offset + k)); | ||
| } else if constexpr (measure == Misc::SignedRugeStuebenMeasure) { | ||
| auto neg_aij = -ATS::real(val); | ||
| auto max_neg_aik = eps * ATS::real(diag(brlid)); | ||
| auto neg_aij = -ATS::real(val); | ||
| auto max_neg_aik = eps * ATS::real(diag(brlid)); | ||
| nonFiniteValueEncountered |= !is_finite_type_safe(neg_aij) || !is_finite_type_safe(max_neg_aik); | ||
| results(offset + k) = Kokkos::max((neg_aij < max_neg_aik) ? DROP : KEEP, | ||
| results(offset + k)); | ||
| } else if constexpr (measure == Misc::SignedSmoothedAggregationMeasure) { | ||
|
|
@@ -765,10 +782,19 @@ class VectorDropFunctor { | |
| // + |a_ij|^2, if a_ij < 0, - |a_ij|^2 if a_ij >=0 | ||
| if (!is_nonpositive) | ||
| aij2 = -aij2; | ||
| nonFiniteValueEncountered |= !is_finite_type_safe(aiiajj) || !is_finite_type_safe(aij2); | ||
| results(offset + k) = Kokkos::max((aij2 <= eps * eps * aiiajj) ? DROP : KEEP, | ||
| results(offset + k)); | ||
| } | ||
| } | ||
|
|
||
| if (nonFiniteValueEncountered) { | ||
| const char* message = | ||
| "Error encountered in MueLu::DistanceLaplacian::VectorDropFunctor::operator():\n" | ||
| "Non-finite values encountered in strength-of-connection measure.\n" | ||
| "A potential fix is to enable rebalancing and/or perform an initial rebalance.\n"; | ||
| Kokkos::abort(message); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
|
|
||
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.
This loop contains redundant finiteness checks. Since
xat iterationiis the same asyfrom iterationi-1,x_aijhas already been validated in the previous step. To improve efficiency, consider checking the first element ofrow_permutationonce before the loop and then only checkingy_aijinside the loop. Additionally, since a non-finite value is a fatal error, using an immediateKokkos::abortor abreakwould avoid unnecessary processing of the remaining elements in the row.