Question about global memory in SYCL guide


I have tried to type in and run the program in the SYCL guide, section about memory:

However, it will not compile because of two things related to the global memory:

auto global_mem = buf.get_access<sycl::access::mode::read>();

First, given that we assign to it later, shouldn’t it be access mode read_write? This is easy to change.

Secondly, the compiler believes it’s a host buffer and therefore it will not accept references to it in the SYCL kernel. I have tried to find other accessor constructors and get methods, without success and would need some help here.




Hi Mats, Thanks for spotting these. We’ll check the code and update it where needed.


There was a change made at some point to the spec that makes accessors constructed without a handler host-only. If you add the handler to the arguments to the get_access function call, it should work as expected.