From 795a76029a1d9afe652e2f9481b15e61cfc33b72 Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Mon, 31 Mar 2025 16:14:36 +0200 Subject: [PATCH] Cycles: oneAPI: Restrict use of experimental copy optimization to L0 This API is not properly implemented in other SYCL backends at the moment and we don't want it to fail at runtime, so we conservatively enable it only for Level-Zero. --- intern/cycles/device/oneapi/device_impl.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/intern/cycles/device/oneapi/device_impl.cpp b/intern/cycles/device/oneapi/device_impl.cpp index e250a53f377..2dcbe3da1ae 100644 --- a/intern/cycles/device/oneapi/device_impl.cpp +++ b/intern/cycles/device/oneapi/device_impl.cpp @@ -388,7 +388,11 @@ void *OneapiDevice::host_alloc(const MemoryType type, const size_t size) /* Import host_pointer into USM memory for faster host<->device data transfers. */ if (type == MEM_READ_WRITE || type == MEM_READ_ONLY) { sycl::queue *queue = reinterpret_cast(device_queue_); - sycl::ext::oneapi::experimental::prepare_for_device_copy(host_pointer, size, *queue); + /* This API is properly implemented only in Level-Zero backend at the moment and we don't + * want it to fail at runtime, so we conservatively use it only for L0. */ + if (queue->get_backend() == sycl::backend::ext_oneapi_level_zero) { + sycl::ext::oneapi::experimental::prepare_for_device_copy(host_pointer, size, *queue); + } } } # endif @@ -401,7 +405,11 @@ void OneapiDevice::host_free(const MemoryType type, void *host_pointer, const si # ifdef SYCL_EXT_ONEAPI_COPY_OPTIMIZE if (type == MEM_READ_WRITE || type == MEM_READ_ONLY) { sycl::queue *queue = reinterpret_cast(device_queue_); - sycl::ext::oneapi::experimental::release_from_device_copy(host_pointer, *queue); + /* This API is properly implemented only in Level-Zero backend at the moment and we don't + * want it to fail at runtime, so we conservatively use it only for L0. */ + if (queue->get_backend() == sycl::backend::ext_oneapi_level_zero) { + sycl::ext::oneapi::experimental::release_from_device_copy(host_pointer, *queue); + } } # endif