-
Notifications
You must be signed in to change notification settings - Fork 18
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
Make the System Sync + Send #132
Conversation
And here are the benchmarks!
I don't get why there is a win in all cases, maybe the optimizer doing different stuff with the |
As I told you my PR was not really meant to be merged, I did not really think about it :). Basically it was because the I'll run the benchmarks on my machine, the difference seems weird : all these changes are not supposed to affect any performance critical part of the code. |
The results are more moderate on my machine:
On my side I'm OK to merge, you'll just need to resolve the merge conflicts. |
This is acheived by making all GlobalPotential Send + Sync, and adding a SharedEwald(RwLock<Ewald>) struct to handle Ewalds caching needs. This means that non-caching global potential no longer pay the cost of RefCell.
Rebased!
OK. I went with the 'manually implement Clone' solution. It might be a bit more maintenance work, but this code is expected to go away anyway.
Yes, there should not be any difference. The only explanation I see would be the optimizer kicking in at some place. |
To make the System
Send + Sync
I applied the following changes:GlobalPotential
trait now requireSend + Sync
;GlobalPotential
andGlobalCache
take self by non-mutable reference;This means that the System no longer has special knowledge of the global potentials and the RefCell are gone in Interactions.
This also means that we can not implement
CoulombicPotential
for Ewald right away, but we need to go throughstruct SharedEwald(RwLock<Ewald>)
to get both interior mutability and Send + Sync.@antoinewdg, in #131 you used
Arc<Mutex<_>>
for this, why theArc
?