| 22 | |
| 23 | template<typename inType, typename outType> |
| 24 | void bilateral(Param<outType> out, CParam<inType> in, float s_sigma, |
| 25 | float c_sigma) { |
| 26 | auto bilateral = common::getKernel( |
| 27 | "arrayfire::cuda::bilateral", {{bilateral_cuh_src}}, |
| 28 | TemplateArgs(TemplateTypename<inType>(), TemplateTypename<outType>()), |
| 29 | {{DefineValue(THREADS_X), DefineValue(THREADS_Y)}}); |
| 30 | |
| 31 | dim3 threads(kernel::THREADS_X, kernel::THREADS_Y); |
| 32 | |
| 33 | int blk_x = divup(in.dims[0], THREADS_X); |
| 34 | int blk_y = divup(in.dims[1], THREADS_Y); |
| 35 | |
| 36 | dim3 blocks(blk_x * in.dims[2], blk_y * in.dims[3]); |
| 37 | |
| 38 | // calculate shared memory size |
| 39 | int radius = (int)std::max(s_sigma * 1.5f, 1.f); |
| 40 | int num_shrd_elems = (THREADS_X + 2 * radius) * (THREADS_Y + 2 * radius); |
| 41 | int num_gauss_elems = (2 * radius + 1) * (2 * radius + 1); |
| 42 | size_t total_shrd_size = |
| 43 | sizeof(outType) * (num_shrd_elems + num_gauss_elems); |
| 44 | |
| 45 | size_t MAX_SHRD_SIZE = getDeviceProp(getActiveDeviceId()).sharedMemPerBlock; |
| 46 | if (total_shrd_size > MAX_SHRD_SIZE) { |
| 47 | char errMessage[256]; |
| 48 | snprintf(errMessage, sizeof(errMessage), |
| 49 | "\nCUDA Bilateral filter doesn't support %f spatial sigma\n", |
| 50 | s_sigma); |
| 51 | CUDA_NOT_SUPPORTED(errMessage); |
| 52 | } |
| 53 | |
| 54 | EnqueueArgs qArgs(blocks, threads, getActiveStream(), total_shrd_size); |
| 55 | |
| 56 | bilateral(qArgs, out, in, s_sigma, c_sigma, num_shrd_elems, blk_x, blk_y); |
| 57 | |
| 58 | POST_LAUNCH_CHECK(); |
| 59 | } |
| 60 | |
| 61 | } // namespace kernel |
| 62 | } // namespace cuda |
nothing calls this directly
no test coverage detected