Repository navigation
Allow public tuning of cub::DeviceTransform - #8745
Conversation
cub::DeviceTransform
This comment has been minimized.
This comment has been minimized.
0a7baae to
2ba950e
Compare
This comment has been minimized.
This comment has been minimized.
571da53 to
8175168
Compare
This comment has been minimized.
This comment has been minimized.
|
ok, what is happening here: The corresponding source code: return {.min_bytes_in_flight = 64 * 1024,
.algorithm = cub::TransformAlgorithm::prefetch,
.prefetch = {.block_threads = 256},
.vectorized = {},
.async_copy = {}};Does nvcc translate designated initializers into a GNU extension syntax? |
927aa5b to
3e0c392
Compare
This comment has been minimized.
This comment has been minimized.
4b49850 to
8908a6d
Compare
This comment has been minimized.
This comment has been minimized.
|
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. |
|
Converting to draft to prevent accidental merging until #7671 is resolved. |
da8f281 to
9d0080b
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (7)
High-level summaryThis PR exposes the transform tuning surface for cub::DeviceTransform by replacing internal/detail tuning types with public policy types and a public algorithm enum, updates dispatch and kernel code to use those types, adjusts C++20 dispatch compatibility for older GCC, expands DeviceTransform docs, and adds tests for the public tuning API. Notable changes
Behavioral/ABI notes
Fixes / Related issues / Dependencies
Author checklist / completed items
Open questions / items remaining (require review / bikeshedding)
Estimated review effort
important: WalkthroughReplace internal transform tuning types with public TransformAlgorithm and Transform*Policy/TransformPolicy, move bulk_copy_alignment computation into device code, add a C++20 dispatch helper, and update kernels, dispatch, docs, benchmarks, and tests to the public API. ChangesTransform Tuning Policy Publicization
Assessment against linked issues
Suggested follow-up: add a compile-time assertion or test hook that can be enabled by users/tests to require the bulk-copy algorithm and fail build when not selected.
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cub/cub/device/dispatch/kernels/kernel_transform.cuh (1)
710-730: important: This changes the generated ublkcp device path, so please attach before/after benchmark data for the tuned architectures before merge. As per coding guidelines,**/*.{cpp,cu,cuh}:Do not commit SASS code changes without running benchmarks to check for performance regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 6d59960a-523b-4eb4-86a2-3f945359cce2
📒 Files selected for processing (8)
cub/benchmarks/bench/transform/common.hcub/cub/detail/cc_dispatch.cuhcub/cub/device/device_transform.cuhcub/cub/device/dispatch/dispatch_transform.cuhcub/cub/device/dispatch/kernels/kernel_transform.cuhcub/cub/device/dispatch/tuning/tuning_transform.cuhcub/test/catch2_test_device_transform_env.cucub/test/catch2_test_device_transform_env_api.cu
This comment has been minimized.
This comment has been minimized.
b258307 to
7383f8e
Compare
This comment has been minimized.
This comment has been minimized.
| return os << "TransformAlgorithm::ldgsts"; | ||
| case TransformAlgorithm::ublkcp: | ||
| return os << "TransformAlgorithm::ublkcp"; | ||
| default: |
There was a problem hiding this comment.
Don't add a default: case here (or in any switch-over-enum in general). If nothing matches a switch-case, it will fall through anyways, whilst adding a default case will stop compilers warning about uncovered cases. So for example:
enum Enum {
FOO, BAR
};
// No compiler warning
switch (e) {
case Enum::FOO: // ...
default: // ...
// oops, BAR not handled
}
// Compiler will warn "unhandled case BAR"
switch (e) {
case Enum::FOO: // ...
// oops, BAR not handled
}There was a problem hiding this comment.
Hmm, but maybe I want to print "TransformAlgorithm::" if the user casts an unknown integer to my enum? Or is that bad practice as well?
I know what you are referring to above, but that applies when the default: does not contain any code itself.
There was a problem hiding this comment.
Hmm, but maybe I want to print "TransformAlgorithm::" if the user casts an unknown integer to my enum?
You should handle this outside the switch. If no case matches in a switch-case, it simply skips the entire expression as if you had a default: break;.
There was a problem hiding this comment.
Please show a code example. What scalable condition should it put into the conditional
switch (algorithm)
{
case TransformAlgorithm::prefetch:
return os << "TransformAlgorithm::prefetch";
case TransformAlgorithm::vectorized:
return os << "TransformAlgorithm::vectorized";
case TransformAlgorithm::ldgsts:
return os << "TransformAlgorithm::ldgsts";
case TransformAlgorithm::ublkcp:
return os << "TransformAlgorithm::ublkcp";
}
if (/* HERE */) {
return os << "TransformAlgorithm::<unknown>";
}Without mentioning all of the above enumerators again?
| << policy.items_per_thread_no_input << ", .min_items_per_thread = " << policy.min_items_per_thread | ||
| << ", .max_items_per_thread = " << policy.max_items_per_thread << ", .prefetch_byte_stride = " | ||
| << policy.prefetch_byte_stride << ", .unroll_factor = " << policy.unroll_factor << " }"; | ||
| << "TransformPrefetchPolicy { .threads_per_block = " << policy.threads_per_block |
There was a problem hiding this comment.
Nit: it may be worth adding a local // clang-tidy: off here and formatting this line by line:
os << "prefetch_policy {"
<< ".threads_per_block = " << policy.threads_per_block << ", "
<< ...the current for is... quite unreadable and easy to miss added members :)
There was a problem hiding this comment.
I would rather try to have clang-format be enabled as much as possible. Also, do people still add data members by hand and not have an agent do it? ;)
| { | ||
| return {.min_bytes_in_flight = 64 * 1024, | ||
| .algorithm = cub::TransformAlgorithm::prefetch, | ||
| .prefetch = {.threads_per_block = 256}, |
There was a problem hiding this comment.
I assume that if we want to retune sth in the future we will just modify our policy-selector while the tuning parameter defaults implicit in the policy can just stay the same even if that means they are bad?
There was a problem hiding this comment.
We can now change ANYTHING we want in the future. Users will now have the ability to set their own tuning parameters, so any change we do that regresses a user can be reverted by the user specifying the old tuning policy manually.
7383f8e to
9433da7
Compare
🥳 CI Workflow Results🟩 Finished in 2h 17m: Pass: 100%/284 | Total: 11d 06h | Max: 2h 15m | Hits: 18%/1026870See results here. |
vector_load_length->vec_sizein tuning policies #8757arch_idwithcompute_capability#8728BlockThreadstoThreadsPerBlock#8835block_threads->threads_per_block#8836TransformAsyncCopyPolicyinto two, one forldgstsand one forublkcp? Then they could evolve independently. I personally see little benefit, since we can extendTransformAsyncCopyPolicyfor anything we need for bulk copy and ignore the filed for ldgsts. I am also certain that there will be no further development for the ldgsts kernel. Answer: Seems the reviewers were fineTransformAlgorithm::ldgstsandTransformAlgorithm::ublkcp? It was suggested to pick names likecopy_asyncorbulk_copy. Or include the termtma. I don't mind, but please make two consistent suggestions if you care. Answer: Seems the reviewers were fineFixes: #8585
Fixes: #5570
New public entities for
cub::DeviceTransformcub::TransformAlgorithmprefetch,vectorized,ldgsts,ublkcpcub::TransformPrefetchPolicythreads_per_block,items_per_thread_no_input,min_items_per_thread,max_items_per_thread,prefetch_byte_stride,unroll_factorcub::TransformVectorizedPolicythreads_per_block,items_per_thread,vec_sizecub::TransformAsyncCopyPolicythreads_per_block,min_items_per_thread,max_items_per_thread,unroll_factorcub::TransformPolicymin_bytes_in_flight,algorithm(TransformAlgorithm),prefetch(TransformPrefetchPolicy),vectorized(TransformVectorizedPolicy),async_copy(TransformAsyncCopyPolicy)