Blender  V3.3
device/hip/kernel.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifdef WITH_HIP
5 
6 # include "device/hip/kernel.h"
7 # include "device/hip/device_impl.h"
8 
10 
11 void HIPDeviceKernels::load(HIPDevice *device)
12 {
13  hipModule_t hipModule = device->hipModule;
14 
15  for (int i = 0; i < (int)DEVICE_KERNEL_NUM; i++) {
16  HIPDeviceKernel &kernel = kernels_[i];
17 
18  /* No mega-kernel used for GPU. */
20  continue;
21  }
22 
23  const std::string function_name = std::string("kernel_gpu_") +
25  hip_device_assert(device,
26  hipModuleGetFunction(&kernel.function, hipModule, function_name.c_str()));
27 
28  if (kernel.function) {
29  hip_device_assert(device, hipFuncSetCacheConfig(kernel.function, hipFuncCachePreferL1));
30 
31  hip_device_assert(
32  device,
33  hipModuleOccupancyMaxPotentialBlockSize(
34  &kernel.min_blocks, &kernel.num_threads_per_block, kernel.function, 0, 0));
35  }
36  else {
37  LOG(ERROR) << "Unable to load kernel " << function_name;
38  }
39  }
40 
41  loaded = true;
42 }
43 
44 const HIPDeviceKernel &HIPDeviceKernels::get(DeviceKernel kernel) const
45 {
46  return kernels_[(int)kernel];
47 }
48 
49 bool HIPDeviceKernels::available(DeviceKernel kernel) const
50 {
51  return kernels_[(int)kernel].function != nullptr;
52 }
53 
55 
56 #endif /* WITH_HIP*/
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
CCL_NAMESPACE_BEGIN const char * device_kernel_as_string(DeviceKernel kernel)
SyclQueue void void size_t num_bytes SyclQueue void const char void *memory_device_pointer KernelContext int kernel
DeviceKernel
@ DEVICE_KERNEL_INTEGRATOR_MEGAKERNEL
@ DEVICE_KERNEL_NUM
#define LOG(severity)
Definition: log.h:36