Revision 76bb84ddcbb6051ec13cc5f9729043063a3b2faa authored by Steven Johnson on 16 May 2023, 18:25:08 UTC, committed by GitHub on 16 May 2023, 18:25:08 UTC
* Allow autoconversion from `Buffer<T>` -> `Buffer<const T>&` When you are intermixing CPU and GPU calls in a single piece of code, it's preferable to pass `Buffer<>` by nonconst reference, so that lazy host<->device copies are done efficiently. However, many callers prefer to define input Buffers as `Buffer<const T>` (as they should), but the fact that this form didn't easily allow autoconversion from caller (whihc may well have constructed the buffer as non-const) to callee (due to incompatible type references) led some users to just pass by a copy, since these autoconverted. This had a couple of undesirable effects: - Making a copy cost a small but nonzero amount of code (managing refcounts, etc) - More importantly, lazy copies in the callee got 'lost' to the caller, since the `halide_buffer_t` in the callee was a copy, thus any added `device` value or change in dirty bits was never seen. This could previously be worked around by adding explicit calls to `.as_const()`, but that is ugly and awkward. This change adds an ugly-but-safe implicit-conversion overload, to allow converting `Buffer<T>&` to `Buffer<const T>&`, iff T isn't already const. This will allow cleaning up downstream code to pass by references more consistently, without needing to add `.as_const()` warts. * Also add convenience conversions for Buffer<void>&
1 parent f121abf
File | Mode | Size |
---|---|---|
BundleStatic.cmake | -rw-r--r-- | 7.8 KB |
CheckFilesExist.cmake | -rw-r--r-- | 455 bytes |
FindHalide.cmake | -rw-r--r-- | 292 bytes |
FindHalide_WebGPU.cmake | -rw-r--r-- | 744 bytes |
HalideGeneratorHelpers.cmake | -rw-r--r-- | 32.0 KB |
HalideTargetHelpers.cmake | -rw-r--r-- | 2.3 KB |
HalideTestHelpers.cmake | -rw-r--r-- | 4.3 KB |
TargetExportScript.cmake | -rw-r--r-- | 2.3 KB |
WipeStandardFlags.cmake | -rw-r--r-- | 702 bytes |
toolchain.linux-aarch64.cmake | -rw-r--r-- | 689 bytes |
toolchain.linux-arm32.cmake | -rw-r--r-- | 1.3 KB |
toolchain.linux-i386.cmake | -rw-r--r-- | 612 bytes |
toolchain.linux-x64-asan.cmake | -rw-r--r-- | 1.3 KB |
Computing file changes ...