KhronosGroup / SYCL-Docs

SYCL Open Source Specification
Other
117 stars 68 forks source link

Should accessor::operator[](id<Dim>) only be available for Dim > 1? #294

Open illuhad opened 2 years ago

illuhad commented 2 years ago

Currently, we have accessor::operator[](id<Dim>) available for device accessors if Dim > 0: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_interface_for_buffer_command_accessors

I believe this can cause ambiguities if accessor::operator[] is used with item<1> as argument instead of id<1>:

Do we want to support passing item to accessor::operator[]? If so, I think one solution could be to make the accessor::operator[](id<Dim>) only available for Dim > 1. This is how I have solved this at the moment.

Passing id<1> still works, because then id<1> would be implicitly converted to size_t, and then accessor::operator[](size_t) can be used.

I'm curious how other implementers have solved this, because going strictly by the synopsis as defined in the spec will not work I think.

gmlueck commented 2 years ago

item<1> can be implicitly converted to id<1>

Is this true? I don't see this in the spec.

illuhad commented 2 years ago

id has non-explicit constructor accepting item: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#id-class

tomdeakin commented 2 years ago

22/11/24: more investigation required by implementors.