43 #ifndef OPENCV_CUDA_REDUCE_HPP
44 #define OPENCV_CUDA_REDUCE_HPP
47 #define THRUST_DEBUG 0
50 #include <thrust/tuple.h>
51 #include "detail/reduce.hpp"
52 #include "detail/reduce_key_val.hpp"
60 namespace cv {
namespace cuda {
namespace device
62 template <
int N,
typename T,
class Op>
63 __device__ __forceinline__
void reduce(
volatile T* smem,
T& val,
unsigned int tid,
const Op& op)
65 reduce_detail::Dispatcher<N>::reductor::template reduce<volatile T*, T&, const Op&>(smem, val, tid, op);
67 template <
unsigned int N,
typename K,
typename V,
class Cmp>
68 __device__ __forceinline__
void reduceKeyVal(
volatile K* skeys, K& key,
volatile V* svals,
V& val,
unsigned int tid,
const Cmp& cmp)
70 reduce_key_val_detail::Dispatcher<N>::reductor::template reduce<volatile K*, K&, volatile V*, V&, const Cmp&>(skeys, key, svals, val, tid, cmp);
72 #if (CUDART_VERSION < 12040)
74 typename P0,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7,
typename P8,
typename P9,
75 typename R0,
typename R1,
typename R2,
typename R3,
typename R4,
typename R5,
typename R6,
typename R7,
typename R8,
typename R9,
76 class Op0,
class Op1,
class Op2,
class Op3,
class Op4,
class Op5,
class Op6,
class Op7,
class Op8,
class Op9>
77 __device__ __forceinline__
void reduce(
const thrust::tuple<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9>& smem,
78 const thrust::tuple<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9>& val,
80 const thrust::tuple<Op0, Op1, Op2, Op3, Op4, Op5, Op6, Op7, Op8, Op9>& op)
82 reduce_detail::Dispatcher<N>::reductor::template
reduce<
83 const thrust::tuple<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9>&,
84 const thrust::tuple<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9>&,
85 const thrust::tuple<Op0, Op1, Op2, Op3, Op4, Op5, Op6, Op7, Op8, Op9>&>(smem, val, tid, op);
88 template <
unsigned int N,
90 typename VP0,
typename VP1,
typename VP2,
typename VP3,
typename VP4,
typename VP5,
typename VP6,
typename VP7,
typename VP8,
typename VP9,
91 typename VR0,
typename VR1,
typename VR2,
typename VR3,
typename VR4,
typename VR5,
typename VR6,
typename VR7,
typename VR8,
typename VR9,
93 __device__ __forceinline__
void reduceKeyVal(
volatile K* skeys, K& key,
94 const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>& svals,
95 const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& val,
96 unsigned int tid,
const Cmp& cmp)
98 reduce_key_val_detail::Dispatcher<N>::reductor::template
reduce<
volatile K*, K&,
99 const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>&,
100 const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>&,
101 const Cmp&>(skeys, key, svals, val, tid, cmp);
104 template <
unsigned int N,
105 typename KP0,
typename KP1,
typename KP2,
typename KP3,
typename KP4,
typename KP5,
typename KP6,
typename KP7,
typename KP8,
typename KP9,
106 typename KR0,
typename KR1,
typename KR2,
typename KR3,
typename KR4,
typename KR5,
typename KR6,
typename KR7,
typename KR8,
typename KR9,
107 typename VP0,
typename VP1,
typename VP2,
typename VP3,
typename VP4,
typename VP5,
typename VP6,
typename VP7,
typename VP8,
typename VP9,
108 typename VR0,
typename VR1,
typename VR2,
typename VR3,
typename VR4,
typename VR5,
typename VR6,
typename VR7,
typename VR8,
typename VR9,
109 class Cmp0,
class Cmp1,
class Cmp2,
class Cmp3,
class Cmp4,
class Cmp5,
class Cmp6,
class Cmp7,
class Cmp8,
class Cmp9>
110 __device__ __forceinline__
void reduceKeyVal(
const thrust::tuple<KP0, KP1, KP2, KP3, KP4, KP5, KP6, KP7, KP8, KP9>& skeys,
111 const thrust::tuple<KR0, KR1, KR2, KR3, KR4, KR5, KR6, KR7, KR8, KR9>& key,
112 const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>& svals,
113 const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>& val,
115 const thrust::tuple<Cmp0, Cmp1, Cmp2, Cmp3, Cmp4, Cmp5, Cmp6, Cmp7, Cmp8, Cmp9>& cmp)
117 reduce_key_val_detail::Dispatcher<N>::reductor::template
reduce<
118 const thrust::tuple<KP0, KP1, KP2, KP3, KP4, KP5, KP6, KP7, KP8, KP9>&,
119 const thrust::tuple<KR0, KR1, KR2, KR3, KR4, KR5, KR6, KR7, KR8, KR9>&,
120 const thrust::tuple<VP0, VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9>&,
121 const thrust::tuple<VR0, VR1, VR2, VR3, VR4, VR5, VR6, VR7, VR8, VR9>&,
122 const thrust::tuple<Cmp0, Cmp1, Cmp2, Cmp3, Cmp4, Cmp5, Cmp6, Cmp7, Cmp8, Cmp9>&
123 >(skeys, key, svals, val, tid, cmp);
126 template <
int N,
typename... P,
typename...
R,
class... Op>
127 __device__ __forceinline__
void reduce(
const thrust::tuple<P...>& smem,
const thrust::tuple<R...>& val,
unsigned int tid,
const thrust::tuple<Op...>& op)
129 reduce_detail::Dispatcher<N>::reductor::template
reduce<
const thrust::tuple<P...>&,
const thrust::tuple<
R...>&,
const thrust::tuple<Op...>&>(smem, val, tid, op);
132 template <
unsigned int N,
typename K,
typename... VP,
typename... VR,
class Cmp>
133 __device__ __forceinline__
void reduceKeyVal(
volatile K* skeys, K& key,
const thrust::tuple<VP...>& svals,
const thrust::tuple<VR...>& val,
unsigned int tid,
const Cmp& cmp)
135 reduce_key_val_detail::Dispatcher<N>::reductor::template
reduce<
volatile K*, K&,
const thrust::tuple<VP...>&,
const thrust::tuple<VR...>&,
const Cmp&>(skeys, key, svals, val, tid, cmp);
138 template <
unsigned int N,
typename... KP,
typename... KR,
typename... VP,
typename... VR,
class... Cmp>
139 __device__ __forceinline__
void reduceKeyVal(
const thrust::tuple<KP...>& skeys,
const thrust::tuple<KR...>& key,
const thrust::tuple<VP...>& svals,
const thrust::tuple<VR...>& val,
unsigned int tid,
const thrust::tuple<Cmp...>& cmp)
141 reduce_key_val_detail::Dispatcher<N>::reductor::template
reduce<
const thrust::tuple<KP...>&,
const thrust::tuple<KR...>&,
const thrust::tuple<VP...>&,
const thrust::tuple<VR...>&,
const thrust::tuple<Cmp...>&>(skeys, key, svals, val, tid, cmp);
147 template <
typename T0>
148 __device__ __forceinline__
149 thrust::tuple<volatile T0*>
152 return thrust::make_tuple((
volatile T0*) t0);
155 template <
typename T0,
typename T1>
156 __device__ __forceinline__
157 thrust::tuple<volatile T0*, volatile T1*>
158 smem_tuple(T0* t0, T1* t1)
160 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1);
163 template <
typename T0,
typename T1,
typename T2>
164 __device__ __forceinline__
165 thrust::tuple<volatile T0*, volatile T1*, volatile T2*>
166 smem_tuple(T0* t0, T1* t1, T2* t2)
168 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1, (
volatile T2*) t2);
171 template <
typename T0,
typename T1,
typename T2,
typename T3>
172 __device__ __forceinline__
173 thrust::tuple<volatile T0*, volatile T1*, volatile T2*, volatile T3*>
174 smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3)
176 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1, (
volatile T2*) t2, (
volatile T3*) t3);
179 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
180 __device__ __forceinline__
181 thrust::tuple<volatile T0*, volatile T1*, volatile T2*, volatile T3*, volatile T4*>
182 smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4)
184 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1, (
volatile T2*) t2, (
volatile T3*) t3, (
volatile T4*) t4);
187 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
188 __device__ __forceinline__
189 thrust::tuple<volatile T0*, volatile T1*, volatile T2*, volatile T3*, volatile T4*, volatile T5*>
190 smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5)
192 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1, (
volatile T2*) t2, (
volatile T3*) t3, (
volatile T4*) t4, (
volatile T5*) t5);
195 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
196 __device__ __forceinline__
197 thrust::tuple<volatile T0*, volatile T1*, volatile T2*, volatile T3*, volatile T4*, volatile T5*, volatile T6*>
198 smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6)
200 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1, (
volatile T2*) t2, (
volatile T3*) t3, (
volatile T4*) t4, (
volatile T5*) t5, (
volatile T6*) t6);
203 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
204 __device__ __forceinline__
205 thrust::tuple<volatile T0*, volatile T1*, volatile T2*, volatile T3*, volatile T4*, volatile T5*, volatile T6*, volatile T7*>
206 smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7)
208 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1, (
volatile T2*) t2, (
volatile T3*) t3, (
volatile T4*) t4, (
volatile T5*) t5, (
volatile T6*) t6, (
volatile T7*) t7);
211 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8>
212 __device__ __forceinline__
213 thrust::tuple<volatile T0*, volatile T1*, volatile T2*, volatile T3*, volatile T4*, volatile T5*, volatile T6*, volatile T7*, volatile T8*>
214 smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7, T8* t8)
216 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1, (
volatile T2*) t2, (
volatile T3*) t3, (
volatile T4*) t4, (
volatile T5*) t5, (
volatile T6*) t6, (
volatile T7*) t7, (
volatile T8*) t8);
219 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9>
220 __device__ __forceinline__
221 thrust::tuple<volatile T0*, volatile T1*, volatile T2*, volatile T3*, volatile T4*, volatile T5*, volatile T6*, volatile T7*, volatile T8*, volatile T9*>
222 smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7, T8* t8, T9* t9)
224 return thrust::make_tuple((
volatile T0*) t0, (
volatile T1*) t1, (
volatile T2*) t2, (
volatile T3*) t3, (
volatile T4*) t4, (
volatile T5*) t5, (
volatile T6*) t6, (
volatile T7*) t7, (
volatile T8*) t8, (
volatile T9*) t9);
InputArrayOfArrays InputArrayOfArrays InputOutputArray InputOutputArray InputOutputArray InputOutputArray Size InputOutputArray InputOutputArray T
Definition: calib3d.hpp:1867
InputArrayOfArrays InputArrayOfArrays InputOutputArray InputOutputArray InputOutputArray InputOutputArray Size InputOutputArray R
Definition: calib3d.hpp:1867
CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype=-1)
Reduces a matrix to a vector.
const CvArr const CvArr * V
Definition: core_c.h:1341
"black box" representation of the file storage associated with a file on disk.
Definition: calib3d.hpp:441