Skip to content

Commit

Permalink
Merge pull request #302 from krasznaa/SYCLMemsetFix-main-20241106
Browse files Browse the repository at this point in the history
SYCL Memset Fix, main branch (2024.11.06.)
  • Loading branch information
krasznaa authored Nov 7, 2024
2 parents 9a5309f + 014ea8d commit 837a468
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 837a468

Please sign in to comment.