Skip to content

Threaded timers break GetConnections() #3468

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

Closed
heplesser opened this issue Apr 15, 2025 · 2 comments
Closed

Threaded timers break GetConnections() #3468

heplesser opened this issue Apr 15, 2025 · 2 comments
Assignees
Labels
I: Behavior changes Introduces changes that produce different results for some users S: High Should be handled next T: Bug Wrong statements in the code or documentation

Comments

@heplesser
Copy link
Contributor

A NEST built with -Dwith-detailed-timers=ON -Dwith-threaded-timers=ON will trigger a failing assertion upon the following:

python -c "import nest ; nest.local_num_threads = 2 ; nest.GetConnections()"   

The assertion is triggered by the call to is_source_table_cleared() here:

if ( is_source_table_cleared() )
, which is called in a serial context. With a few intermediate steps, this calls PerThreadBoolIndicator::all_true() here:
PerThreadBoolIndicator::all_true() const
, which in turn starts a stopwatch.

This all happens in a serial context. But threaded timers require that they be started and stopped in a thread-parallel context, see

kernel().vp_manager.assert_thread_parallel();
.

The idea behind the assertion was that threaded timers would only be started/stopped from parallel contexts. But the all/any_true/false() methods may be called from serial and parallel contexts, and then the timers in them need to support this.

So I think we should remove the assertions from the start() and stop() methods, as well as from is_running() and elapsed(). If called from a serial context, the time would be for thread 0.

For print() I am uncertain what would be the best choice and implementation, but thread-parallel writing to an ostream does not seem optimal.

@heplesser heplesser added I: Behavior changes Introduces changes that produce different results for some users S: High Should be handled next T: Bug Wrong statements in the code or documentation labels Apr 15, 2025
@heplesser heplesser added this to Kernel Apr 15, 2025
@github-project-automation github-project-automation bot moved this to To do (open issues) in Kernel Apr 15, 2025
@JanVogelsang
Copy link
Contributor

Isn't this a duplicate of #3442 which will be fixed by #3445?

@heplesser
Copy link
Contributor Author

@JanVogelsang You are right, I should have remembered that! I will close this one and adjust the title of #3442 to include the threaded timers.

@github-project-automation github-project-automation bot moved this from To do (open issues) to Done in Kernel Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: Behavior changes Introduces changes that produce different results for some users S: High Should be handled next T: Bug Wrong statements in the code or documentation
Projects
Status: Done
Development

No branches or pull requests

2 participants