-
Notifications
You must be signed in to change notification settings - Fork 641
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
disable default decimation for nonlinear materials #2413
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Calling
fields::has_nonlinearities(bool parallel)
with afalse
argument means that theor_to_all
statement infields.cpp:670
(below) is never invoked. That would meanfields::has_nonlinearities(bool parallel)
returns different values for different chunks. This would seem to be a bug.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.
No, because of the subsequent
min_to_all
statement.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.
If I replace
!has_nonlinearities(false)
with!has_nonlinearities(true)
,test_adjoint_solver
deadlocks when run with two chunks (as reported previously). This seems to be due to theor_to_all
call which currently is never invoked.It's not obvious why
or_to_all
triggers a deadlock butmin_to_all
does not.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 reason why it deadlocks is that
has_nonlinearities
here only gets executed if(freq_max > 0) && (src_freq_max > 0)
is true, because&&
is a short-circuiting operator.In the DFT adjoint simulation, where the adjoint sources get placed with
add_srcdata
, which is only called on chunks where the sources are present, some of the chunks are missing information about the sources and havesrc_freq_max == 0
. In consequence, those chunks are not callinghas_nonlinearities
, so it deadlocks ifparallel == true
andor_to_all
is called.In contrast, the
min_to_all
is always called on every chunk, because it is outside of these conditionals, so it does not deadlock.Moreover, this means that the new
min_to_all
potentially fixes bugs even in linear simulations, since it was previously possible that some linear simulations over-estimated thedecimation_factor
on chunks for which no sources were present.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 it would have made the code more readable if, inside the block
if (decimation_factor == 0) { ... }
we had simply inserted:The
bool
argument tofields::has_nonlinearities()
is not necessary.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 reason I added the
bool
argument is that we need to callmin_to_all
anyway, even for linear simulations, to make sure we don't over-estimate thedecimation_factor
in cases where a chunk is missing the source term present only in another chunk. In that case, doingor_to_all
is redundant, and is not cheap because it is a second MPI reduction.