-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add a simple spinlock mutex type #607
Conversation
This will fail until acts-project/vecmem#275 is merged. |
53416c5
to
a2394c9
Compare
This is now ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the templating actually needed? Could we not just choose one specific integer type that would need to be used with mutexes? This way we just make it easier for somebody to use an inappropriate type. 🤔 (With a bunch of complicated compiler errors to follow.)
Of course in that case the functions will all need to be explicitly declared inline
. (They are currently implicitly that because of the templating.)
Also-also: Would it not be good to also provide a Unfortunately I don't think that we could use |
Unfortunately, it's not that simple. 😟 Because RAII is implicitly executed by every thread in a warp, using a naive |
The danger here is that different platform might support lock-free operations on different types. And some types may be slower than others. Although I am pretty sure something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance of adding some SYCL tests as well...? Read: Please add SYCL tests as well.
Sure, I can add some SYCL tests. But this kind of "write one piece of common code, have to write tests for all platforms" is going to quickly become unmanageable if we start doing the same for Kokkos, Alpaka, etc. 😟 |
I'm very open to suggestions. But we must test it somehow that the "common code" indeed works correctly on all backends that we want to use. If you prefer to set up just one test with Alpaka or Kokkos for all available backends, I'm fine with that. |
6312b8d
to
26b48ad
Compare
This is now ready, with SYCL tests. |
In order to facilitate some edge case handling in device code, this commit adds a very simple spinlock-type mutex using vecmem atomic references.
The purpose of this class is to provide an RAII-based mechanism for releasing locks on mutexes.
This commit adds some tests for the newly introduced `traccc::mutex` and `traccc::unique_lock` types for CUDA and SYCL platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lock
<-> _lock
names are used in a bit confusing way in the SYCL tests, but since those are just tests, this is more of a nitpick. Other than that, this seems fine.
In order to facilitate some edge case handling in device code, this commit adds a very simple spinlock-type mutex using vecmem atomic references.