23namespace shamalgs::atomic {
60 template<
class int_t, u32 group_size>
61 class DynamicIdGenerator;
83 template<
class int_t, u32 group_size>
86 sycl::accessor<int_t, 1, sycl::access::mode::read_write, sycl::access::target::device>
89 sycl::local_accessor<int_t, 1> local_group_id;
93 : group_id{gen.
group_id, cgh, sycl::read_write}, local_group_id(1, cgh) {}
104 ret.is_main_thread = it.get_local_id(0) == 0 ? 1 : 0;
106 if (ret.is_main_thread) {
110 sycl::memory_order_relaxed,
111 sycl::memory_scope_device,
112 sycl::access::address_space::global_space>
113 atomic_group_id(group_id[0]);
115 ret.dyn_group_id = atomic_group_id.fetch_add(1);
116 local_group_id[0] = ret.dyn_group_id;
118 it.barrier(sycl::access::fence_space::local_space);
119 ret.dyn_group_id = local_group_id[0];
121 ret.dyn_global_id = ret.dyn_group_id * group_size + it.get_local_id(0);
127 template<
class int_t, u32 group_size>
Accesses version of DynamicIdGenerator see doc for example (DynamicIdGenerator)
DynamicId< int_t > compute_id(sycl::nd_item< 1 > it) const
compute the local ids and return the result DynamicId
Sycl utility to dynamically generate group ids.
DynamicIdGenerator(sycl::queue &q)
Construct DynamicIdGenerator
sycl::buffer< int_t > group_id
the buffer used for group_id synchronization
AccessedDynamicIdGenerator< int_t, group_size > get_access(sycl::handler &cgh)
Get the access to DynamicIdGenerator returning the accessed variants AccessedDynamicIdGenerator
Object returned by DynamicIdGenerator containing information about the worker affected id.
void buf_fill_discard(sycl::queue &q, sycl::buffer< T > &buf, T value)
Fill a buffer with a given value (sycl::no_init mode)
main include file for memory algorithms