30 #ifndef HIPCUB_ROCPRIM_BLOCK_BLOCK_REDUCE_HPP_
31 #define HIPCUB_ROCPRIM_BLOCK_BLOCK_REDUCE_HPP_
33 #include <type_traits>
35 #include <rocprim/block/block_reduce.hpp>
37 BEGIN_HIPCUB_NAMESPACE
42 typename std::underlying_type<::rocprim::block_reduce_algorithm>::type
43 to_BlockReduceAlgorithm_enum(::rocprim::block_reduce_algorithm v)
45 using utype = std::underlying_type<::rocprim::block_reduce_algorithm>::type;
46 return static_cast<utype
>(v);
50 enum BlockReduceAlgorithm
52 BLOCK_REDUCE_RAKING_COMMUTATIVE_ONLY
53 = detail::to_BlockReduceAlgorithm_enum(::rocprim::block_reduce_algorithm::raking_reduce_commutative_only),
55 = detail::to_BlockReduceAlgorithm_enum(::rocprim::block_reduce_algorithm::raking_reduce),
56 BLOCK_REDUCE_WARP_REDUCTIONS
57 = detail::to_BlockReduceAlgorithm_enum(::rocprim::block_reduce_algorithm::using_warp_reduce)
63 BlockReduceAlgorithm ALGORITHM = BLOCK_REDUCE_WARP_REDUCTIONS,
66 int ARCH = HIPCUB_ARCH
69 :
private ::rocprim::block_reduce<
72 static_cast<::rocprim::block_reduce_algorithm>(ALGORITHM),
78 BLOCK_DIM_X * BLOCK_DIM_Y * BLOCK_DIM_Z > 0,
79 "BLOCK_DIM_X * BLOCK_DIM_Y * BLOCK_DIM_Z must be greater than 0"
83 typename ::rocprim::block_reduce<
86 static_cast<::rocprim::block_reduce_algorithm
>(ALGORITHM),
92 typename base_type::storage_type& temp_storage_;
95 using TempStorage =
typename base_type::storage_type;
103 BlockReduce(TempStorage& temp_storage) : temp_storage_(temp_storage)
110 base_type::reduce(input, input, temp_storage_);
115 T Sum(T input,
int valid_items)
117 base_type::reduce(input, input, valid_items, temp_storage_);
121 template<
int ITEMS_PER_THREAD>
123 T Sum(T(&input)[ITEMS_PER_THREAD])
126 base_type::reduce(input, output, temp_storage_);
130 template<
typename ReduceOp>
132 T Reduce(T input, ReduceOp reduce_op)
134 base_type::reduce(input, input, temp_storage_, reduce_op);
138 template<
typename ReduceOp>
140 T Reduce(T input, ReduceOp reduce_op,
int valid_items)
142 base_type::reduce(input, input, valid_items, temp_storage_, reduce_op);
146 template<
int ITEMS_PER_THREAD,
typename ReduceOp>
148 T Reduce(T(&input)[ITEMS_PER_THREAD], ReduceOp reduce_op)
151 base_type::reduce(input, output, temp_storage_, reduce_op);
157 TempStorage& private_storage()
159 HIPCUB_SHARED_MEMORY TempStorage private_storage;
160 return private_storage;
Definition: block_reduce.hpp:76