-
Notifications
You must be signed in to change notification settings - Fork 178
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
Enable user-provided lock table for atomic_ref<T>
#990
Comments
For reference, this functionality would be extremely useful in cuCollections where we want to use |
I've been thinking about what the I was thinking something along the lines of this:
I want to put the access property in there so I can expose control to how the accesses to the mutexes are cached. My guess is that it'll be pretty important to perf to ensure the locks aren't getting thrashed out of L2. That said, I'm not sure if this will work with the current limitations of the compiler unless |
I would like to be able to use
atomic_ref<T>
forsizeof(T) > 8B
, i.e.,atomic_ref<T>::is_always_lock_free == false
.Obviously this can't rely on built-in atomic operations.Typical implementations will make use of a lock table to support this usage where you use the address of the referenced object as a lookup into a table of mutexes.
Generic support for a lock table underneath a
cuda::std::atomic_ref
would be extremely non-trivial to support on all platforms and for it to work heterogeneously.However, a less generic solution that would still be very useful would be to allow a user to provide their own lock table.
@ogiroux's idea is to partially specialize
cuda::atomic_ref
foris_always_lock_free == false
to contain a pointer to a lock table to be supplied by the user via theatomic_ref
constructor at each construction. It would likely be useful to supply an opaquecuda::atomic_lock_table<N, Scope>
type that a user could instantiate and manage however they like.A rough sketch of what this could look like:
This would depend on #949 for implementing the
atomic_lock_table
.The text was updated successfully, but these errors were encountered: