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

Function floodFill

src/backend/cuda/kernel/flood_fill.hpp:36–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35template<typename T>
36void floodFill(Param<T> out, CParam<T> image, CParam<uint> seedsx,
37 CParam<uint> seedsy, const T newValue, const T lowValue,
38 const T highValue, const af::connectivity nlookup) {
39 UNUSED(nlookup);
40 if (sharedMemRequiredByFloodFill<T>() >
41 getDeviceProp(getActiveDeviceId()).sharedMemPerBlock) {
42 char errMessage[256];
43 snprintf(errMessage, sizeof(errMessage),
44 "\nCurrent thread's CUDA device doesn't have sufficient "
45 "shared memory required by FloodFill\n");
46 CUDA_NOT_SUPPORTED(errMessage);
47 }
48
49 auto initSeeds =
50 common::getKernel("arrayfire::cuda::initSeeds", {{flood_fill_cuh_src}},
51 TemplateArgs(TemplateTypename<T>()));
52 auto floodStep =
53 common::getKernel("arrayfire::cuda::floodStep", {{flood_fill_cuh_src}},
54 TemplateArgs(TemplateTypename<T>()),
55 {{DefineValue(THREADS_X), DefineValue(THREADS_Y)}});
56 auto finalizeOutput = common::getKernel(
57 "arrayfire::cuda::finalizeOutput", {{flood_fill_cuh_src}},
58 TemplateArgs(TemplateTypename<T>()));
59
60 EnqueueArgs qArgs(dim3(divup(seedsx.elements(), THREADS)), dim3(THREADS),
61 getActiveStream());
62 initSeeds(qArgs, out, seedsx, seedsy);
63 POST_LAUNCH_CHECK();
64
65 dim3 threads(THREADS_X, THREADS_Y);
66 dim3 blocks(divup(image.dims[0], threads.x),
67 divup(image.dims[1], threads.y));
68 EnqueueArgs fQArgs(blocks, threads, getActiveStream());
69
70 auto continueFlagPtr = floodStep.getDevPtr("doAnotherLaunch");
71
72 for (int doAnotherLaunch = 1; doAnotherLaunch > 0;) {
73 doAnotherLaunch = 0;
74 floodStep.setFlag(continueFlagPtr, &doAnotherLaunch);
75 floodStep(fQArgs, out, image, lowValue, highValue);
76 POST_LAUNCH_CHECK();
77 doAnotherLaunch = floodStep.getFlag(continueFlagPtr);
78 }
79 finalizeOutput(fQArgs, out, newValue);
80 POST_LAUNCH_CHECK();
81}
82
83} // namespace kernel
84} // namespace cuda

Callers

nothing calls this directly

Calls 10

TemplateArgsFunction · 0.85
getActiveStreamFunction · 0.85
initSeedsFunction · 0.85
finalizeOutputFunction · 0.85
getActiveDeviceIdFunction · 0.50
getKernelFunction · 0.50
elementsMethod · 0.45
getDevPtrMethod · 0.45
setFlagMethod · 0.45
getFlagMethod · 0.45

Tested by

no test coverage detected