Repository navigation
Document the new CUB tuning API for developers - #8643
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
| * :ref:`tuning policy selectors <cub-policy-selectors>` | ||
|
|
||
| from the environment argument, or provide default values in case the environment does not contain them. | ||
| They typically use helper functions like ``dispatch_with_env`` and ``dispatch_with_env_and_tuning``. |
There was a problem hiding this comment.
We should document those defaults
dac8cd5 to
a936f08
Compare
0794af9 to
a39bfa5
Compare
| Device-scope APIs come in two flavors, two step APIs and environment APIs, | ||
| both return ``cudaError_t`` and take algorithm specific arguments. | ||
| The two step API accepts a ``stream`` as the last parameter (``NULL`` stream by default) | ||
| and the first two parameters are always ``void *d_temp_storage, size_t &temp_storage_bytes``. | ||
| The environment API just takes an environment as the last parameter (empty environment by default). | ||
| The implementation may consist of some minimal argument checking, but should forward as soon as possible to the dispatch layer. | ||
| Device-scope algorithms are implemented in files located in `cub/device/device_***.cuh`. |
There was a problem hiding this comment.
This section buries the lede a little bit. The primary relationship (at least as advertised in the blog post) is that single-phase is more or less a convenience wrapper over dual-phase.
I might lead with that, as it makes the following discussion much easier to follow. Once the reader appreciates that they functionally achieve the same thing, you can dive deeper into the nuts and bolts of how they differ.
There was a problem hiding this comment.
single-phase is more or less a convenience wrapper over dual-phase.
Unfortunately not. Determinism requirements and tuning are only exposed via env-overloads. The single-phase APIs cannot express this or call the corresponding algorithms (like RFA or atomic reduction).
| cuda::execution::require(requirements...), | ||
| cuda::execution::tune(policy_selectors....) |
There was a problem hiding this comment.
Likewise, I might add some inline comments here to the execution arguments. It may not be immediately obvious what they do
There was a problem hiding this comment.
I don't think this matters here, since the arguments to env are unordered, and the functions require and tune are well enough named IMO to explain what they do.
| The dispatch function is typically a simple function template called ``dispatch`` inside an algorithm-specific namespace. | ||
| It basically receives the same parameters as the public API entry point, | ||
| but they may have already been modified, extended, or generalized (to map many public APIs to the same dispatch function). | ||
| The goal of the dispatch function is to setup the execution of the algorithm on the device | ||
| by selecting the appropriate policy for the current GPU's compute capability, | ||
| preparing temporary storage and shared memory, configuring kernel launches, launching kernels, etc. |
There was a problem hiding this comment.
Nit: I would reorder this to discuss the goal of the dispatcher first, then discuss the mechanics afterwards. Consider also making those goals as a list, otherwise it's easy to lose them in the text.
There was a problem hiding this comment.
The wording here tries to be loose on purpose, since dispatch functions are just a convention we seem to follow, but nobody is forced to follow it and it may change in the future. I have ideas myself about how to change them. I don't want the docs here to get out of sync to fast.
| Since the policy selector is stateless, we can default-construct it from its type alone | ||
| and always retrieve the ``policy`` as a compile-time value. |
There was a problem hiding this comment.
You kind of already say this 4 lines above.
There was a problem hiding this comment.
Right. Removed the second occurrence.
| Because many dispatch functions are also used by CCCL.C, | ||
| which compiles them without proper type information, | ||
| we have to provide them in two forms, | ||
| a typeless and a typeful version. |
There was a problem hiding this comment.
Do we need to keep this documented now that hostjit is on the horizon? Is that not replacing CCCL.C entirely?
There was a problem hiding this comment.
I will happy delete it once hostjit is merged and all of CCCL.C has been rewritten ;) Until then, I can point people here when they ask me why we have multiple flavors of policy selectors.
e833804 to
767796b
Compare
Fixes: #8592