KhronosGroup / KhronosGroup/SYCL-Docs
buffer::get_access<access::mode::read> should be marked const.
- Dominant language
- JavaScript
- Stars
- 158
- Forks
- 80
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 5
Description
### The Problem
Calling `get_access` in read-only mode requires the `buffer` to be non-`const` since `get_access` itself is never marked as `const`. This is a problem for `const` data structures which encapsulate a SYCL `buffer`. It also contradicts `const`-correctness which is strongly advocated for by the C++ community. Finally it is counterintuitive for the programmer.
### Example
```c++
#include
int main()
{
auto queue = cl::sycl::queue{};
const auto in = cl::sycl::buffer{1024};
auto out = cl::sycl::buffer{1024};
queue.submit([&](cl::sycl::handler& cgh)
{
// candidate function not viable: method is not marked const
auto in_acc = in.get_access(cgh);
auto out_acc = out.get_access(cgh);
cgh.copy(in_acc, out_acc);
});
return 0;
}
```
### Use case
Any `const` data structure encapsulating a SYCL `buffer`.
### Possible solutions
1. Mark `get_access` `const` for `access::mode::read`. I'd be happy to open a pull-request for this if needed.
2. Add wording to `get_access`'s specification which explains why it cannot be marked `const`.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue concerns the SYCL buffer get_access specification and includes a const-correctness example. Start by reading the get_access specification and the seven-comment discussion, then determine which proposed resolution is accepted. Done means the specification clearly settles the behavior of read-only access for const buffers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100