Accessors - jimmytwei/oneAPI-samples GitHub Wiki

Accessors

  • Prefer the use of the simplified accessor style​

  • Verbose SYCL style:​

auto x_a = x_buf.template get_access<access::mode::read_write>(h);​
auto y_a = y_buf.template get_access<access::mode::read>(h);​
auto z_a = z_buf.template get_access<access::mode::write>(h);​
  • Simplified DPC++ style (SYCL 2020):
accessor x_a(x_buf, h); // access::mode::read_write​
accessor y_a(y_buf, h, read_only);	// acesss::mode::read​
accessor z_a(z_buf, h, write_only);	// access::mode::write​

host_accessor q_a(q_buf);	// access::mode::read_write​
host_accessor q_a(q_buf, read_only);	// acesss::mode::read​
host_accessor q_a(q_buf, write_only);	// acesss::mode::write

Implicit conversion to size_t

  • Prefer using implicit subscripts for id<1> and item<1> parallel for index​

  • Verbose SYCL style:​

h.parallel_for(..., [=](cl::sycl::id<1> idx) {​
  size_t i = idx[0];​
  a[idx] = i;​

h.parallel_for(..., [=](cl::sycl::item<1> idx) {​
  size_t i = idx[0];​
  a[idx] = i;​

​* Simplified DPC++ style:​

h.parallel_for(..., [=](id<1> i) {​
  a[i] = i;​

h.parallel_for(..., [=](item<1> i) {​
  a[i] = i;