mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
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
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#pragma once
|
|
|
|
#ifdef WITH_HIP
|
|
|
|
# include "device/memory.h"
|
|
# include "device/queue.h"
|
|
|
|
# include "device/hip/util.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
class HIPDevice;
|
|
class device_memory;
|
|
|
|
/* Base class for HIP queues. */
|
|
class HIPDeviceQueue : public DeviceQueue {
|
|
public:
|
|
HIPDeviceQueue(HIPDevice *device);
|
|
~HIPDeviceQueue() override;
|
|
|
|
void init_execution() override;
|
|
void load_image_info() override;
|
|
|
|
bool enqueue(DeviceKernel kernel,
|
|
const int 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;
|
|
|
|
virtual hipStream_t stream()
|
|
{
|
|
return hip_stream_;
|
|
}
|
|
|
|
unique_ptr<DeviceGraphicsInterop> graphics_interop_create() override;
|
|
|
|
protected:
|
|
HIPDevice *hip_device_;
|
|
hipStream_t hip_stream_;
|
|
|
|
ConcurrentStatesParams concurrent_states_params() const override;
|
|
void get_memory_info(size_t &total, size_t &free) const override;
|
|
|
|
void assert_success(hipError_t result, const char *operation);
|
|
};
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
#endif /* WITH_HIP */
|