Change the definition of marray::size() to return NumElements
Opened this issue · 3 comments
The spec defines marray::size()
to return the number of bytes in the marray instead of the number of elements. This is at odds with every other definition of a member named size()
in SYCL, where size()
would return the number of elements stored / accessed, and where applicable, a corresponding byte_size()
function is provided to obtain the number of bytes.
I propose to change the definition to return the number of elements instead to avoid confusion and give the user a method of querying the element count without resorting to metaprogramming:
- Change
marray::size()
to read "ReturnsNumElements
." - (optionally) Add
marray::byte_size()
that reads "Returns the size of this SYCLmarray
in bytes.".
(Accidental) prior art:
- DPC++ already implements this in the manner proposed
- The CTS assumes any SYCL type with
size()
andoperator[]
members to behave in the proposed way, and will fail a SYCL implementation that adheres to the spec for this member.
The definition in the spec indeed does seem counterintuitive to me.
For what it's worth, AdaptiveCpp also implements marray
in the manner you propose, with the size()
function returning NumElements
: https://github.com/AdaptiveCpp/AdaptiveCpp/blob/2333dc631b38510f43e1c59f23ffc8e05d13daa6/include/hipSYCL/sycl/libkernel/marray.hpp#L112
This means that all implementations agree to disagree with the spec here. We should change the spec.
Yes, that's a good catch. I also think the spec should be changed.
PR needed. CTS also assumes this returns NumElements
.