Skip to content

Commit 9beebb2

Browse files
Assert offset type in DispatchScan[ByKey] to be unsigned (#3992)
1 parent f578ea9 commit 9beebb2

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

cub/benchmarks/bench/scan/exclusive/by_key.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*
2626
******************************************************************************/
2727

28+
#include <cub/detail/choose_offset.cuh>
2829
#include <cub/device/device_scan.cuh>
2930

3031
#include <look_back_helper.cuh>
@@ -82,7 +83,7 @@ static void scan(nvbench::state& state, nvbench::type_list<KeyT, ValueT, OffsetT
8283
using val_input_it_t = const ValueT*;
8384
using val_output_it_t = ValueT*;
8485
using equality_op_t = ::cuda::std::equal_to<>;
85-
using offset_t = OffsetT;
86+
using offset_t = cub::detail::choose_offset_t<OffsetT>;
8687

8788
#if !TUNE_BASE
8889
using policy_t = policy_hub_t;

cub/cub/device/dispatch/dispatch_scan.cuh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ template <
165165
typename KernelLauncherFactory = detail::TripleChevronFactory>
166166
struct DispatchScan
167167
{
168+
static_assert(::cuda::std::is_unsigned_v<OffsetT> && sizeof(OffsetT) >= 4,
169+
"DispatchScan only supports unsigned offset types of at least 4-bytes");
170+
168171
//---------------------------------------------------------------------
169172
// Constants and Types
170173
//---------------------------------------------------------------------

cub/cub/device/dispatch/dispatch_scan_by_key.cuh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ template <
241241
detail::scan_by_key::policy_hub<KeysInputIteratorT, AccumT, cub::detail::it_value_t<ValuesInputIteratorT>, ScanOpT>>
242242
struct DispatchScanByKey
243243
{
244+
static_assert(::cuda::std::is_unsigned_v<OffsetT> && sizeof(OffsetT) >= 4,
245+
"DispatchScan only supports unsigned offset types of at least 4-bytes");
246+
244247
//---------------------------------------------------------------------
245248
// Constants and Types
246249
//---------------------------------------------------------------------

0 commit comments

Comments
 (0)