Repository navigation
Description
Is your feature request related to a problem? Please describe.
There is a significant amount of redundancy among the static_map/static_multimap/static_reduction_map classes. This is a large maintenance overhead and means optimizations made to one data structure do not translate to the others.
Furthermore, there are several configuration options we'd like to enable, like using AoS vs SOA, scalar vs. CG operations, etc.
I'd also like to enable adding a static_set and static_multiset classes that could share the same backend.
Describe the solution you'd like
List of things I'd like to address:
- Use atomic_ref when possible (4B/8B key/value types) [FEA] Migrate from
cuda::atomictocuda::atomic_ref#183 - Falls back on atomic when necessary (<4B, >8B key/value types)
- For <4B, we should probably just widen them ourselves and still use
atomic_refinstead ofatomic.
- For <4B, we should probably just widen them ourselves and still use
- Eliminates redundancy among static_map/reduction_map/multimap
- Enables AoS vs SoA layout ([FEA] Add option to select between Struct of Arrays vs Array of Structs #103)
- Enables statically sized device views
- We should use a pattern like
std::spanwithstd::dynamic_extentto support both dynamic and statically sized capacities.
- We should use a pattern like
- Enables adding
static_setandstatic_multiset - Supports the various insert schemes: packed/back2back/cas+dependent write
- Switch between scalar/CG operations
- Stream support everywhere ([FEA] CUDA stream support #65)
- Consistent use of
bitwise_equal - Asynchronous size computation ([FEA] On-demand size computation to solve #65 and #39 #102, Size computation slows bulk insert significantly #237 )
- rehashing ([FEA] static_map::rehash #21)
My current thinking is to create an open_address_impl class that provides an abstraction for a logical array of "slots" and exposes operations on those slots. All the core logic and switching for things like AoS/SoA, atomic_ref/atomic can/should be implemented in this common impl class.
Activity
jrhemstad commentedon Nov 12, 2021
Something that came up with @PointKernel in the review of the
static_multimapthat we ultimately decided to wait on was enabling user configuration of using "scalar" vs "vector" loading. I think this should be exposed via theProbingSchemetype and adding anitems_per_threadnon-type template parameter that controls how many slots are loaded per-thread.I also want to be able to disable using the CG algorithms all together via the
ProbingScheme. You can current setCGSize == 1, but that will be inefficient as it still uses the CG code paths instead of the scalar code paths. We can either specialize forCGSize == 1or add a special sentinel value forCGSize(likestd::numerc_limits<size_t>::max())that selects using non-CG code paths.PointKernel commentedon Dec 6, 2021
Another improvement we should try: using one CG to insert/retrieve multiple keys instead of a single key to amortize CG overhead.
jrhemstad commentedon Aug 5, 2022
Status of the latest ideas we have discussed:
static_setor other data structures with a variety of configuration parameters, we want to use a variadic constructor pattern that is similar to this example: https://godbolt.org/z/T4oP1nsoWget_or_default<T>function looking for a concrete typeT, it could look for the first type that satisfies a given conceptC, e.g.,get_or_default<C>.vector< pair<key,value> >orvector<key>andvector<value>(i.e., AoS vs SoA) could be valid implementations ofStorage.k, aProbingSequenceprovides a sequence ofNpotentially non-contiguous locations (or values)[i0, i1, i2, ... iN, EMPTY_SENTINEL]where ifkexists it is present in[i0, iN]. Optionally, the sequence may be provided as a set of "windows" that partition the space into 1D "windows" of a fixed-size "W"Additional host interface functions:
Experimental work in defining these entities:
jrhemstad commentedon Aug 8, 2022
Some open questions that still need answers:
Where is the CG size/window size defined?
Storage?ProbingScheme?Different flavors of cooperative device-side overloads. E.g.,
contains:Nthreads ingroupcallcontainswith the exact samek. AllNthreads cooperate to find the singlek. The same result value is returned to all threads.Nthreads ingroupcallcontainseach with potentially distinct values fork(k0, k1, ..., kN). AllNthreads cooperate to find eachki. The returned result is potentially unique to each threadtidepending on the existence ofki.sleeepyjack commentedon Aug 9, 2022
We could use different signatures for
contains(CG g, key_type key, ..)contains(CG g, KeyIter first, KeyIter last, ..)The latter could implement a WCWS overload for when the key/value types can be shuffled around among group ranks.
If the input range is wider than the group (notice this also implements the device bulk API idea we had), we would need to write the results to an output range instead of placing them as return values of the function.
jrhemstad commentedon Aug 9, 2022
I'm not sure this solves the problem. Would the semantics of this function be such that each thread in the group is providing a distinct
[first,last)range? Or the same?I think a
containsfunction that takes an iterator range is orthogonal to the cooperative semantics of the function.sleeepyjack commentedon Aug 9, 2022
I don't see the benefit of the former variant, as you can simply call the function in a loop. I was referring to the latter variant: A coop group is assigned to a range of keys, implementing a "mini" parallel bulk version of the operation. If the data types allow for warp shuffles, we can make use of WCWS, i.e., coalesced load from the input range then iteratively broadcast each loaded datum to all ranks and subsequently call the cooperative insert/contains.
jrhemstad commentedon Aug 11, 2022
I want APIs that don't require me to think about launching
input_size * CG_sizenumber of threads and wrangle the CG throughout the whole kernel.I just want to launch
input_sizethreads and then create an ad hoc CG to do a cooperative insert/find.In other words, I want to keep the simple "one work item per thread" model of work assignment, but benefit from the cooperative execution by threads donating themselves to carrying out the work for another threads work item.
Add data structure base classes and `cuco::static_set` (#278)
Add experimental `static_map` (#314)
Clean up `cuco::pair` (#319)