MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / unwrap

Function unwrap

src/backend/opencl/kernel/unwrap.hpp:29–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28template<typename T>
29void unwrap(Param out, const Param in, const dim_t wx, const dim_t wy,
30 const dim_t sx, const dim_t sy, const dim_t px, const dim_t py,
31 const dim_t dx, const dim_t dy, const dim_t nx,
32 const bool is_column) {
33 using cl::EnqueueArgs;
34 using cl::NDRange;
35 using std::string;
36 using std::vector;
37
38 ToNumStr<T> toNumStr;
39 vector<TemplateArg> tmpltArgs = {
40 TemplateTypename<T>(),
41 TemplateArg(is_column),
42 };
43 vector<string> compileOpts = {
44 DefineKeyValue(T, dtype_traits<T>::getName()),
45 DefineKeyValue(IS_COLUMN, is_column),
46 DefineKeyValue(ZERO, toNumStr(scalar<T>(0))),
47 };
48 compileOpts.emplace_back(getTypeBuildDefinition<T>());
49
50 auto unwrap =
51 common::getKernel("unwrap", {{unwrap_cl_src}}, tmpltArgs, compileOpts);
52
53 dim_t TX = 1, TY = 1;
54 dim_t BX = 1;
55 const dim_t BY = out.info.dims[2] * out.info.dims[3];
56 int reps = 1;
57
58 if (is_column) {
59 TX = std::min(THREADS_PER_GROUP, nextpow2(out.info.dims[0]));
60 TY = THREADS_PER_GROUP / TX;
61 BX = divup(out.info.dims[1], TY);
62 reps = divup((wx * wy), TX);
63 } else {
64 TX = THREADS_X;
65 TY = THREADS_Y;
66 BX = divup(out.info.dims[0], TX);
67 reps = divup((wx * wy), TY);
68 }
69
70 NDRange local(TX, TY);
71 NDRange global(local[0] * BX, local[1] * BY);
72
73 unwrap(EnqueueArgs(getQueue(), global, local), *out.data, out.info,
74 *in.data, in.info, static_cast<int>(wx), static_cast<int>(wy),
75 static_cast<int>(sx), static_cast<int>(sy), static_cast<int>(px),
76 static_cast<int>(py), static_cast<int>(dx), static_cast<int>(dy),
77 static_cast<int>(nx), reps);
78 CL_DEBUG_FINISH(getQueue());
79}
80
81} // namespace kernel
82} // namespace opencl

Callers

nothing calls this directly

Calls 7

TemplateArgClass · 0.85
getNameFunction · 0.85
nextpow2Function · 0.85
EnqueueArgsClass · 0.85
getKernelFunction · 0.50
minFunction · 0.50
getQueueFunction · 0.50

Tested by

no test coverage detected