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

Function floodFill

src/backend/opencl/kernel/flood_fill.hpp:71–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69
70template<typename T>
71void floodFill(Param out, const Param image, const Param seedsx,
72 const Param seedsy, const T newValue, const T lowValue,
73 const T highValue, const af::connectivity nlookup) {
74 constexpr int RADIUS = 1;
75
76 UNUSED(nlookup);
77 std::array<std::string, 11> options = {
78 DefineKeyValue(T, dtype_traits<T>::getName()),
79 DefineValue(RADIUS),
80 DefineValue(VALID),
81 DefineValue(INVALID),
82 DefineValue(ZERO),
83 DefineKey(FLOOD_FILL_STEP),
84 DefineKeyValue(LMEM_WIDTH, (THREADS_X + 2 * RADIUS)),
85 DefineKeyValue(LMEM_HEIGHT, (THREADS_Y + 2 * RADIUS)),
86 DefineKeyValue(GROUP_SIZE, (THREADS_Y * THREADS_X)),
87 getTypeBuildDefinition<T>()};
88
89 auto floodStep =
90 common::getKernel("flood_step", {{flood_fill_cl_src}},
91 TemplateArgs(TemplateTypename<T>()), options);
92 cl::NDRange local(kernel::THREADS_X, kernel::THREADS_Y, 1);
93 cl::NDRange global(divup(out.info.dims[0], local[0]) * local[0],
94 divup(out.info.dims[1], local[1]) * local[1], 1);
95
96 initSeeds<T>(out, seedsx, seedsy);
97
98 int notFinished = 1;
99 cl::Buffer* dContinue = bufferAlloc(sizeof(int));
100
101 while (notFinished) {
102 notFinished = 0;
103 floodStep.setFlag(dContinue, &notFinished);
104 floodStep(cl::EnqueueArgs(getQueue(), global, local), *out.data,
105 out.info, *image.data, image.info, lowValue, highValue,
106 *dContinue);
107 CL_DEBUG_FINISH(getQueue());
108 notFinished = floodStep.getFlag(dContinue);
109 }
110 bufferFree(dContinue);
111 finalizeOutput<T>(out, newValue);
112}
113
114} // namespace kernel
115} // namespace opencl

Callers

nothing calls this directly

Calls 9

getNameFunction · 0.85
TemplateArgsFunction · 0.85
bufferAllocFunction · 0.85
EnqueueArgsClass · 0.85
bufferFreeFunction · 0.85
getKernelFunction · 0.50
getQueueFunction · 0.50
setFlagMethod · 0.45
getFlagMethod · 0.45

Tested by

no test coverage detected