blender/intern/cycles/device/oneapi/queue.h
Brecht Van Lommel 5c328388f3 Cycles: Add concurrent states growth and shrinking for all GPU backends
This helps avoid out of memory errors for complex scenes, and improves
performance for smaller scenes with more memory available for states.

Metal already had logic like this, now the logic is centralized and can
be used for all GPU backends.

The parameters have been somewhat tuned per device, based on earlier
work for oneAPI in #163437 and CUDA in #163532. For Metal the behavior
should remain basically the same.

For oneAPI, this enables free_memory queries on iGPUs, as driver have
been exposing this for some time.

Co-authored-by: Patrick Mours <pmours@nvidia.com>
Co-authored-by; Xavier Hallade <xavier.hallade@intel.com>

Pull Request: https://projects.blender.org/blender/blender/pulls/163930
2026-09-23 15:22:57 +02:00

61 lines
1.5 KiB
C++

/* SPDX-FileCopyrightText: 2021-2025 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0 */
#pragma once
#ifdef WITH_ONEAPI
# include "device/memory.h"
# include "device/queue.h"
# include "kernel/device/oneapi/kernel.h"
# include "util/unique_ptr.h"
CCL_NAMESPACE_BEGIN
class OneapiDevice;
class device_memory;
/* Base class for OneAPI queues. */
class OneapiDeviceQueue : public DeviceQueue {
public:
explicit OneapiDeviceQueue(OneapiDevice *device);
int num_sort_partitions(int max_num_paths, uint max_scene_shaders) const override;
void init_execution() override;
void load_image_info() override;
bool enqueue(DeviceKernel kernel,
const int kernel_work_size,
const DeviceKernelArguments &args) override;
bool synchronize() override;
void zero_to_device(device_memory &mem) override;
void copy_to_device(device_memory &mem) override;
void copy_from_device(device_memory &mem) override;
void *copy_from_device_synchronized(device_memory &mem, vector<uint8_t> &storage) override;
bool supports_local_atomic_sort() const override
{
return true;
}
# ifdef SYCL_LINEAR_MEMORY_INTEROP_AVAILABLE
unique_ptr<DeviceGraphicsInterop> graphics_interop_create() override;
# endif
protected:
OneapiDevice *oneapi_device_;
unique_ptr<KernelContext> kernel_context_;
ConcurrentStatesParams concurrent_states_params() const override;
void get_memory_info(size_t &total, size_t &free) const override;
};
CCL_NAMESPACE_END
#endif /* WITH_ONEAPI */