Files
opencv-MIRROR/modules/core/include
Abhishek Gola 22db6f41b9 Merge pull request #30398 from abhishek-gola/non-cpu-hal
core: non-CPU HAL (cv::accel) with a CUDA backend

What this PR adds: cv::accel, a non-CPU HAL in core, kept to a minimal first version.

Explicit placement: UMat::createOn(device, shape, type), Mat::upload(device) and UMat::upload(device). Mat::upload() returns once the Mat has been read; UMat::upload() returns the same UMat when it is already on that device.
Functions with an accelerator hook (cv::flip and cv::transpose in this PR) run on the device stored in the input's UMatData. Their output is created there with createOn(), also when the backend declines the call and the CPU runs it. Other functions run on the CPU as before.
One allocator per backend; each buffer keeps its device in UMatData::allocatorContext.
One stream per device and CPU thread (Device::threadStream()). Work of one thread runs in order; work of different threads is synchronized explicitly with cv::accel::synchronize(device).
Operations are reached with device.ops<accel::CoreOps>("core") and called directly. A stream keeps the buffers of queued work alive until it finishes (Stream::retain()), as the OpenCL backend does with a running kernel's UMats.
In-place calls are handled by each operation: the CUDA backend swaps mirrored elements for an in-place flip and transposes square matrices in place.
A CUDA backend with flip and transpose kernels. Discrete GPUs get memory from a stream-ordered pool that keeps freed memory for reuse while the pool holds less than a quarter of the device's memory, and returns the rest to the driver. On a GPU the build has no kernels for, the calls fall back to the CPU.
2026-11-20 17:54:15 +05:30
..