2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2021-2022 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2022-06-29 12:58:04 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_ONEAPI
|
|
|
|
|
|
|
|
|
|
# include <stddef.h>
|
|
|
|
|
|
|
|
|
|
/* NOTE(@nsirgien): Should match underlying type in the declaration inside "kernel/types.h"
|
|
|
|
|
* TODO: use kernel/types.h directly. */
|
|
|
|
|
enum DeviceKernel : int;
|
|
|
|
|
|
|
|
|
|
# ifndef CYCLES_KERNEL_ONEAPI_EXPORT
|
|
|
|
|
# ifdef _WIN32
|
|
|
|
|
# if defined(ONEAPI_EXPORT)
|
|
|
|
|
# define CYCLES_KERNEL_ONEAPI_EXPORT extern __declspec(dllexport)
|
|
|
|
|
# else
|
|
|
|
|
# define CYCLES_KERNEL_ONEAPI_EXPORT extern __declspec(dllimport)
|
|
|
|
|
# endif
|
|
|
|
|
# else
|
2023-09-08 15:40:36 +02:00
|
|
|
# define CYCLES_KERNEL_ONEAPI_EXPORT extern __attribute__((visibility("default")))
|
2022-06-29 12:58:04 +02:00
|
|
|
# endif
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
class SyclQueue;
|
|
|
|
|
|
|
|
|
|
typedef void (*OneAPIErrorCallback)(const char *error, void *user_ptr);
|
|
|
|
|
|
|
|
|
|
struct KernelContext {
|
|
|
|
|
/* Queue, associated with selected device */
|
2024-12-29 23:13:45 +01:00
|
|
|
SyclQueue *queue = nullptr;
|
2022-06-29 12:58:04 +02:00
|
|
|
/* Pointer to USM device memory with all global/constant allocation on this device */
|
2024-12-29 23:13:45 +01:00
|
|
|
void *kernel_globals = nullptr;
|
2023-05-17 00:20:46 +02:00
|
|
|
/* We needs this additional data for some kernels. */
|
2024-12-29 23:13:45 +01:00
|
|
|
int scene_max_shaders = 0;
|
2022-06-29 12:58:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Use extern C linking so that the symbols can be easily load from the dynamic library at runtime.
|
|
|
|
|
*/
|
|
|
|
|
# ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
# endif
|
|
|
|
|
|
2022-10-06 18:35:51 +02:00
|
|
|
CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_run_test_kernel(SyclQueue *queue_);
|
2024-05-28 19:04:19 +02:00
|
|
|
CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_zero_memory_on_device(SyclQueue *queue_,
|
|
|
|
|
void *device_pointer,
|
|
|
|
|
size_t num_bytes);
|
2022-10-06 18:35:51 +02:00
|
|
|
CYCLES_KERNEL_ONEAPI_EXPORT void oneapi_set_error_cb(OneAPIErrorCallback cb, void *user_ptr);
|
2023-08-22 19:04:16 +02:00
|
|
|
CYCLES_KERNEL_ONEAPI_EXPORT size_t oneapi_suggested_gpu_kernel_size(const DeviceKernel kernel);
|
2022-10-06 18:35:51 +02:00
|
|
|
CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_enqueue_kernel(KernelContext *context,
|
2025-01-01 18:15:54 +01:00
|
|
|
const int kernel,
|
|
|
|
|
const size_t global_size,
|
|
|
|
|
const size_t local_size,
|
2023-03-16 11:56:55 +01:00
|
|
|
const unsigned int kernel_features,
|
|
|
|
|
bool use_hardware_raytracing,
|
2022-10-06 18:35:51 +02:00
|
|
|
void **args);
|
2022-10-10 16:37:40 +02:00
|
|
|
CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_load_kernels(SyclQueue *queue,
|
2023-03-16 11:56:55 +01:00
|
|
|
const unsigned int kernel_features,
|
|
|
|
|
bool use_hardware_raytracing);
|
2022-06-29 12:58:04 +02:00
|
|
|
# ifdef __cplusplus
|
|
|
|
|
}
|
2023-03-16 11:56:55 +01:00
|
|
|
|
2022-06-29 12:58:04 +02:00
|
|
|
# endif
|
|
|
|
|
#endif /* WITH_ONEAPI */
|