-
Notifications
You must be signed in to change notification settings - Fork 6
/
scan.cpp
40 lines (31 loc) · 1.25 KB
/
scan.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "scan.h"
#include "general_scan.h"
bool TRTC_Inclusive_Scan(const DVVectorLike& vec_in, DVVectorLike& vec_out, const Functor& binary_op)
{
Functor src({ {"vec_in", &vec_in} }, { "idx" },
" return vec_in[idx];\n");
return general_scan(vec_in.size(), src, vec_out, binary_op);
}
bool TRTC_Inclusive_Scan(const DVVectorLike& vec_in, DVVectorLike& vec_out)
{
Functor plus("Plus");
return TRTC_Inclusive_Scan(vec_in, vec_out, plus);
}
bool TRTC_Exclusive_Scan(const DVVectorLike& vec_in, DVVectorLike& vec_out)
{
Functor src({ {"vec_in", &vec_in} }, { "idx" },
" return idx>0? vec_in[idx - 1] : (decltype(vec_in)::value_t) 0;\n");
Functor plus("Plus");
return general_scan(vec_in.size(), src, vec_out, plus);
}
bool TRTC_Exclusive_Scan(const DVVectorLike& vec_in, DVVectorLike& vec_out, const DeviceViewable& init, const Functor& binary_op)
{
Functor src({ {"vec_in", &vec_in}, {"init", &init} }, { "idx" },
" return idx>0? vec_in[idx - 1] : (decltype(vec_in)::value_t)init;\n");
return general_scan(vec_in.size(), src, vec_out, binary_op);
}
bool TRTC_Exclusive_Scan(const DVVectorLike& vec_in, DVVectorLike& vec_out, const DeviceViewable& init)
{
Functor plus("Plus");
return TRTC_Exclusive_Scan(vec_in, vec_out, init, plus);
}