33 sycl::queue &q, sycl::buffer<T> &buf, sycl::buffer<u32> &index_map,
u32 len) {
35 sycl::buffer<T> ret(len);
37 q.submit([&](sycl::handler &cgh) {
38 sycl::accessor in{buf, cgh, sycl::read_only};
39 sycl::accessor out{ret, cgh, sycl::write_only, sycl::no_init};
40 sycl::accessor permut{index_map, cgh, sycl::read_only};
42 cgh.parallel_for(sycl::range<1>(len), [=](sycl::item<1> item) {
43 out[item] = in[permut[item]];
47 return std::move(ret);
52 const sham::DeviceScheduler_ptr &sched_ptr,
66 auto e = q.
submit(el, [&](sycl::handler &cgh) {
67 cgh.parallel_for(sycl::range<1>(len), [=](sycl::item<1> item) {
68 out[item] = in[permut[item]];
78 void index_remap_nvar(
79 const sham::DeviceScheduler_ptr &sched_ptr,
80 sham::DeviceBuffer<T> &source,
81 sham::DeviceBuffer<T> &dest,
82 sham::DeviceBuffer<u32> &index_map,
94 auto e = q.
submit(el, [&](sycl::handler &cgh) {
97 cgh.parallel_for(sycl::range<1>(len), [=](sycl::item<1> item) {
98 u32 in_id = permut[item] * nvar_loc;
99 u32 out_id = item.get_linear_id() * nvar_loc;
101 for (
u32 a = 0; a < nvar_loc; a++) {
102 out[out_id + a] = in[in_id + a];
133 template sycl::buffer<_arg_> index_remap( \
134 sycl::queue &q, sycl::buffer<_arg_> &buf, sycl::buffer<u32> &index_map, u32 len); \
136 template void index_remap( \
137 const sham::DeviceScheduler_ptr &sched, \
138 sham::DeviceBuffer<_arg_> &source, \
139 sham::DeviceBuffer<_arg_> &dest, \
140 sham::DeviceBuffer<u32> &index_map, \
143 template void index_remap_nvar( \
144 const sham::DeviceScheduler_ptr &sched, \
145 sham::DeviceBuffer<_arg_> &source, \
146 sham::DeviceBuffer<_arg_> &dest, \
147 sham::DeviceBuffer<u32> &index_map, \
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory).
void complete_event_state(sycl::event e) const
Complete the event state of the buffer.
T * get_write_access(sham::EventList &depends_list, SourceLocation src_loc=SourceLocation{})
Get a read-write pointer to the buffer's data.
const T * get_read_access(sham::EventList &depends_list, SourceLocation src_loc=SourceLocation{}) const
Get a read-only pointer to the buffer's data.
A SYCL queue associated with a device and a context.
sycl::event submit(Fct &&fct)
Submits a kernel to the SYCL queue.
Class to manage a list of SYCL events.
main include file for the shamalgs algorithms
namespace to store algorithms implemented by shamalgs
sycl::buffer< T > index_remap(sycl::queue &q, sycl::buffer< T > &source_buf, sycl::buffer< u32 > &index_map, u32 len)
remap a buffer according to a given index map result[i] = result[index_map[i]]
sycl::buffer< u32 > gen_buffer_index(sycl::queue &q, u32 len)
generate a buffer such that for i in [0,len[, buf[i] = i
sycl::buffer< typename std::invoke_result_t< Fct, u32 > > gen_buffer_device(sycl::queue &q, u32 len, Fct &&func)
generate a buffer from a lambda expression based on the indexes
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...