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

Function index

src/backend/opencl/kernel/index.hpp:34–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33template<typename T>
34void index(Param out, const Param in, const IndexKernelParam_t& p,
35 cl::Buffer* bPtr[4]) {
36 std::array<std::string, 2> options = {
37 DefineKeyValue(T, dtype_traits<T>::getName()),
38 getTypeBuildDefinition<T>()};
39
40 auto index =
41 common::getKernel("indexKernel", {{index_cl_src}},
42 TemplateArgs(TemplateTypename<T>()), options);
43 int threads_x = 256;
44 int threads_y = 1;
45 cl::NDRange local(threads_x, threads_y);
46 switch (out.info.dims[1]) {
47 case 1: threads_y = 1; break;
48 case 2: threads_y = 2; break;
49 case 3:
50 case 4: threads_y = 4; break;
51 default: threads_y = 8; break;
52 }
53 threads_x = static_cast<unsigned>(256.f / threads_y);
54
55 int blk_x = divup(out.info.dims[0], local[0]);
56 int blk_y = divup(out.info.dims[1], local[1]);
57
58 cl::NDRange global(blk_x * out.info.dims[2] * local[0],
59 blk_y * out.info.dims[3] * local[1]);
60
61 index(cl::EnqueueArgs(getQueue(), global, local), *out.data, out.info,
62 *in.data, in.info, p, *bPtr[0], *bPtr[1], *bPtr[2], *bPtr[3], blk_x,
63 blk_y);
64 CL_DEBUG_FINISH(getQueue());
65}
66} // namespace kernel
67} // namespace opencl
68} // namespace arrayfire

Callers

nothing calls this directly

Calls 5

getNameFunction · 0.85
TemplateArgsFunction · 0.85
EnqueueArgsClass · 0.85
getKernelFunction · 0.50
getQueueFunction · 0.50

Tested by

no test coverage detected