Skip to content

Commit

Permalink
Fixing SYCL memset in the absence of sycl::queue::memset.
Browse files Browse the repository at this point in the history
  • Loading branch information
krasznaa committed Nov 6, 2024
1 parent 8f648e5 commit 66042a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sycl/src/utils/sycl/async_copy.sycl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "vecmem/utils/sycl/async_copy.hpp"

// System include(s).
#include <algorithm>
#include <exception>
#include <vector>

Expand Down Expand Up @@ -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<int> dummy(size / sizeof(int) + 1, value);
std::vector<int> dummy(size / sizeof(int) + 1);
std::fill_n(reinterpret_cast<unsigned char*>(dummy.data()), size,
static_cast<unsigned char>(value));
details::get_queue(m_data->m_queue)
.memcpy(ptr, dummy.data(), size)
.wait_and_throw();
Expand Down
5 changes: 4 additions & 1 deletion sycl/src/utils/sycl/copy.sycl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "vecmem/utils/sycl/copy.hpp"

// System include(s).
#include <algorithm>
#include <vector>

namespace vecmem::sycl {
Expand Down Expand Up @@ -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<int> dummy(size / sizeof(int) + 1, value);
std::vector<int> dummy(size / sizeof(int) + 1);
std::fill_n(reinterpret_cast<unsigned char*>(dummy.data()), size,
static_cast<unsigned char>(value));
details::get_queue(m_data->m_queue)
.memcpy(ptr, dummy.data(), size)
.wait_and_throw();
Expand Down

0 comments on commit 66042a2

Please sign in to comment.