Blender V5.0
kernel/device/oneapi/kernel.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021-2022 Intel Corporation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#ifdef WITH_ONEAPI
8
9# include <stddef.h>
10
11/* NOTE(@nsirgien): Should match underlying type in the declaration inside "kernel/types.h"
12 * TODO: use kernel/types.h directly. */
13enum DeviceKernel : int;
14
15# ifndef CYCLES_KERNEL_ONEAPI_EXPORT
16# ifdef _WIN32
17# if defined(ONEAPI_EXPORT)
18# define CYCLES_KERNEL_ONEAPI_EXPORT extern __declspec(dllexport)
19# else
20# define CYCLES_KERNEL_ONEAPI_EXPORT extern __declspec(dllimport)
21# endif
22# else
23# define CYCLES_KERNEL_ONEAPI_EXPORT extern __attribute__((visibility("default")))
24# endif
25# endif
26
27class SyclQueue;
28class SyclDevice;
29
30typedef void (*OneAPIErrorCallback)(const char *error, void *user_ptr);
31
32struct KernelContext {
33 /* Queue, associated with selected device */
34 SyclQueue *queue = nullptr;
35 /* Pointer to USM device memory with all global/constant allocation on this device */
36 void *kernel_globals = nullptr;
37 /* We needs this additional data for some kernels. */
38 int scene_max_shaders = 0;
39};
40
41/* Use extern C linking so that the symbols can be easily load from the dynamic library at runtime.
42 */
43# ifdef __cplusplus
44extern "C" {
45# endif
46
47CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_run_test_kernel(SyclQueue *queue_);
48CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_zero_memory_on_device(SyclQueue *queue_,
49 void *device_pointer,
50 size_t num_bytes);
51CYCLES_KERNEL_ONEAPI_EXPORT void oneapi_set_error_cb(OneAPIErrorCallback cb, void *user_ptr);
52CYCLES_KERNEL_ONEAPI_EXPORT size_t oneapi_suggested_gpu_kernel_size(const DeviceKernel kernel);
53CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_enqueue_kernel(KernelContext *context,
54 const int kernel,
55 const size_t global_size,
56 const size_t local_size,
57 const unsigned int kernel_features,
58 bool use_hardware_raytracing,
59 void **args);
60CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_load_kernels(SyclQueue *queue,
61 const unsigned int kernel_features,
62 bool use_hardware_raytracing);
63# ifdef __cplusplus
64}
65
66# endif
67#endif /* WITH_ONEAPI */
DeviceKernel
static void error(const char *str)