Blender V5.3
device/cuda/kernel.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#ifdef WITH_CUDA
6
7# include "device/cuda/kernel.h"
9
11
12void CUDADeviceKernels::load(CUDADevice *device)
13{
14 CUmodule cuModule = device->cuModule;
15
16 for (int i = 0; i < (int)DEVICE_KERNEL_NUM; i++) {
17 CUDADeviceKernel &kernel = kernels_[i];
18
20 continue;
21 }
22
23 const std::string function_name = std::string("kernel_gpu_") +
25 cuda_device_assert(device,
26 cuModuleGetFunction(&kernel.function, cuModule, function_name.c_str()));
27
28 if (kernel.function) {
29 cuda_device_assert(device, cuFuncSetCacheConfig(kernel.function, CU_FUNC_CACHE_PREFER_L1));
30
31 cuda_device_assert(
32 device,
33 cuOccupancyMaxPotentialBlockSize(
34 &kernel.min_blocks, &kernel.num_threads_per_block, kernel.function, nullptr, 0, 0));
35 }
36 else {
37 LOG_ERROR << "Unable to load kernel " << function_name;
38 }
39 }
40
41 loaded = true;
42}
43
44const CUDADeviceKernel &CUDADeviceKernels::get(DeviceKernel kernel) const
45{
46 return kernels_[(int)kernel];
47}
48
49bool CUDADeviceKernels::available(DeviceKernel kernel) const
50{
51 return kernels_[(int)kernel].function != nullptr;
52}
53
55
56#endif /* WITH_CUDA */
#define CCL_NAMESPACE_END
const char * device_kernel_as_string(DeviceKernel kernel)
bool device_kernel_has_gpu_function(DeviceKernel kernel)
DeviceKernel
@ DEVICE_KERNEL_NUM
#define LOG_ERROR
Definition log.h:101