Skip to content
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

fix deadlock in add_srcdata via new require_source_components() function #1521

Merged
merged 6 commits into from
Mar 6, 2021

Conversation

stevengj
Copy link
Collaborator

@stevengj stevengj commented Mar 5, 2021

@mochen4 has been seeing some deadlocks when using near2far adjoints on multiple processors. I think this PR fixes the underlying problem.

fields::add_srcdata was calling fields::require_component(c) to ensure that the fields corresponding to the source component were added, but require_component is a collective function — it must be called from all processes with the same c. Because of the low-level way in which add_srcdata is constructed, however, the list of sources can be different on each processor, and in particular sources were only added on processors whose chunks overlap with the DFT near-field region.

To solve this, I did some refactoring and added a new fields::require_source_components() function which can be called collectively after all of the sources are added, allocating the necessary fields. Python now calls this by default after it adds sources, just in case one of the sources used add_srcdata (an IndexedSource in Python).

@smartalecH
Copy link
Collaborator

Fixes #1434

src/fields.cpp Show resolved Hide resolved
@stevengj stevengj merged commit 1d59e6b into master Mar 6, 2021
@stevengj stevengj deleted the require_source_components branch March 6, 2021 16:22
bencbartlett pushed a commit to bencbartlett/meep that referenced this pull request Sep 9, 2021
…ion (NanoComp#1521)

* fix deadlock in add_srcdata via new require_source_components() function

* typo

* rm redundant reduction

* timing

* don't call self.fields.require_source_components if there were no sources

* actually we should call init_sim in add_sources, in case only some processes have sources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants