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

Protect writes ParticleForce #5060

Open
5 tasks
RudolfWeeber opened this issue Mar 16, 2025 · 0 comments
Open
5 tasks

Protect writes ParticleForce #5060

RudolfWeeber opened this issue Mar 16, 2025 · 0 comments

Comments

@RudolfWeeber
Copy link
Contributor

In preparation for shared memory parallelism.
to thread might add forces/torques to the same particle at the same time. This would happen, for example, when calculating bonded forces in parallel.

Probably the easiest way to solve this is to only allow for atomic writes to the particle force/torque

Tentative steps

  • Add Functions add_force/torque(Vector3d), set_fprce/torque(Vector3d) to ParticleForce. Also only allow read access to torque/force via a function, returning a value rather than a reference.
  • Adapt access to the force/torque in Particle accordingly
  • Roll thouse out throughout ESPResSo where forces are accessed. Mainly the propagation schemes, LB Coupling, P3M
  • Make the data members of ParticleForce private
  • change the data type of the member variables to std::array<std::atomic,3>` and adapt the setters/adeders/getters to use store/fetch_add/load members of the std::atomic
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

No branches or pull requests

1 participant