-
Notifications
You must be signed in to change notification settings - Fork 8
[ROCm] Remove rocPRIM detail:: dependency from CUB scan kernel #792
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ limitations under the License. | |
| #include "rocm/include/rocprim/block/block_load.hpp" | ||
| #include "rocm/include/rocprim/block/block_scan.hpp" | ||
| #include "rocm/include/rocprim/block/block_store.hpp" | ||
| #include "rocm/include/rocprim/device/detail/device_config_helper.hpp" | ||
| #include "rocm/include/rocprim/device/device_scan.hpp" | ||
| #include "rocm/include/rocprim/functional.hpp" | ||
| #include "xla/stream_executor/rocm/cub_scan_kernel_rocm.h" | ||
|
|
@@ -34,17 +33,24 @@ namespace stream_executor::rocm { | |
|
|
||
| namespace { | ||
|
|
||
| // Architecture-aware tuning from rocPRIM's autotuned scan config. | ||
| // Scan config using rocPRIM's generic default formula for block size and | ||
| // items-per-thread. Hardcoded to avoid depending on rocPRIM internal | ||
| // detail:: API (default_scan_config_base was renamed/restructured since | ||
| // TheRock >= 7.11). | ||
| template <typename T> | ||
| struct ScanConfig { | ||
| using RocprimConfig = | ||
| typename rocprim::detail::default_scan_config_base<T>::type; | ||
| static constexpr int kBlockSize = RocprimConfig::block_size; | ||
| static constexpr int kItemsPerThread = RocprimConfig::items_per_thread; | ||
| static constexpr unsigned int kItemScale = | ||
| (sizeof(T) + sizeof(int) - 1) / sizeof(int); | ||
| static constexpr int kBlockSize = 256; | ||
| static constexpr int kItemsPerThread = | ||
| static_cast<int>(16u / kItemScale > 0 ? 16u / kItemScale : 1u); | ||
| static constexpr int kTileSize = kBlockSize * kItemsPerThread; | ||
| static constexpr auto kLoadMethod = RocprimConfig::block_load_method; | ||
| static constexpr auto kStoreMethod = RocprimConfig::block_store_method; | ||
| static constexpr auto kScanAlgorithm = RocprimConfig::block_scan_method; | ||
| static constexpr auto kLoadMethod = | ||
| rocprim::block_load_method::block_load_transpose; | ||
| static constexpr auto kStoreMethod = | ||
| rocprim::block_store_method::block_store_transpose; | ||
| static constexpr auto kScanAlgorithm = | ||
| rocprim::block_scan_algorithm::using_warp_scan; | ||
|
Comment on lines
+36
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Observation on performance vs. the CUDA path: the CUDA implementation uses CUB's Since this is opened for discussion, a few options to consider:
Any of these are defensible; the key is documenting the choice and the known gap. |
||
| }; | ||
|
|
||
| template <typename T> | ||
|
|
||
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.
nit: The ternary expression
16u / kItemScale > 0 ? 16u / kItemScale : 1uis correct by C++ operator precedence, but can trip up readers who have to mentally verify the binding. Considerstd::max(1u, 16u / kItemScale)— same semantics, immediately clear intent, and avoids evaluating the division expression twice (though the compiler would optimize that away for constexpr values anyway).