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