-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
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
#include <CL/sycl.hpp>
int main()
{
auto queue = cl::sycl::queue{};
const auto in = cl::sycl::buffer<int, 1>{1024};
auto out = cl::sycl::buffer<int, 1>{1024};
queue.submit([&](cl::sycl::handler& cgh)
{
// candidate function not viable: method is not marked const
auto in_acc = in.get_access<cl::sycl::access::mode::read>(cgh);
auto out_acc = out.get_access<cl::sycl::access::mode::write>(cgh);
cgh.copy(in_acc, out_acc);
});
return 0;
}Use case
Any const data structure encapsulating a SYCL buffer.
Possible solutions
- Mark
get_accessconstforaccess::mode::read. I'd be happy to open a pull-request for this if needed. - Add wording to
get_access's specification which explains why it cannot be markedconst.
hdelassus
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request