From 66042a281bc84be026bf0beca53a46a25d77af61 Mon Sep 17 00:00:00 2001 From: Attila Krasznahorkay Date: Wed, 6 Nov 2024 21:03:17 +0100 Subject: [PATCH] Fixing SYCL memset in the absence of sycl::queue::memset. --- sycl/src/utils/sycl/async_copy.sycl | 5 ++++- sycl/src/utils/sycl/copy.sycl | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sycl/src/utils/sycl/async_copy.sycl b/sycl/src/utils/sycl/async_copy.sycl index df6aa5ac..afee2e51 100644 --- a/sycl/src/utils/sycl/async_copy.sycl +++ b/sycl/src/utils/sycl/async_copy.sycl @@ -15,6 +15,7 @@ #include "vecmem/utils/sycl/async_copy.hpp" // System include(s). +#include #include #include @@ -111,7 +112,9 @@ void async_copy::do_memset(std::size_t size, void* ptr, int value) const { // We can not perform this operation asynchronously, since the data used // in the copy only exists as long as this function is executing. So we // don't record this event, but rather wait it out right here. - const std::vector dummy(size / sizeof(int) + 1, value); + std::vector dummy(size / sizeof(int) + 1); + std::fill_n(reinterpret_cast(dummy.data()), size, + static_cast(value)); details::get_queue(m_data->m_queue) .memcpy(ptr, dummy.data(), size) .wait_and_throw(); diff --git a/sycl/src/utils/sycl/copy.sycl b/sycl/src/utils/sycl/copy.sycl index c98c5774..5fba2821 100644 --- a/sycl/src/utils/sycl/copy.sycl +++ b/sycl/src/utils/sycl/copy.sycl @@ -15,6 +15,7 @@ #include "vecmem/utils/sycl/copy.hpp" // System include(s). +#include #include namespace vecmem::sycl { @@ -71,7 +72,9 @@ void copy::do_memset(std::size_t size, void* ptr, int value) const { .memset(ptr, value, size) .wait_and_throw(); #else - const std::vector dummy(size / sizeof(int) + 1, value); + std::vector dummy(size / sizeof(int) + 1); + std::fill_n(reinterpret_cast(dummy.data()), size, + static_cast(value)); details::get_queue(m_data->m_queue) .memcpy(ptr, dummy.data(), size) .wait_and_throw();