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 issue 1794 monitor_nd atomic listmode #1796

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

willend
Copy link
Contributor

@willend willend commented Dec 11, 2024

It turned out that the cure was to do an "atomic capture" to define a local TRACE copy of the "particle count", to be used everywhere in TRACE.

In a CPU setting where only one thread is active at a time we can of course make do with the usual, global variable on the structure:

  #ifdef OPENACC
  /* For the OPENACC list buffer we need a local copy of the
     atomically updated Neutron_counter - captured below under list mode */
  long long ParticleCount=0;
  #else
  /* On CPU can make do with the global, declared one... */
  #define ParticleCount Vars->Neutron_Counter
  #endif

At the "incrementation-point" we capture atomically from the GPU in OPENACC settings:

        #ifdef OPENACC
        #pragma acc atomic capture
        {
	  ParticleCount=Vars->Neutron_Counter++ ;
        } 
        #else
        ParticleCount++;
	#endif	

@willend willend merged commit 4662602 into main Dec 11, 2024
32 checks passed
@willend willend deleted the fix-issue-1794-monitor_nd-atomic-listmode branch December 16, 2024 10:20
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.

1 participant