libocca / occa

Portable and vendor neutral framework for parallel programming on heterogeneous platforms.
https://libocca.org
MIT License
396 stars 86 forks source link

`memory::size()` should return number of `dtype` entries #687

Closed stgeke closed 11 months ago

stgeke commented 1 year ago

To make it consistent with STL functions like std::vector.

noelchalmers commented 1 year ago

length does: https://github.com/libocca/occa/blob/main/src/core/memory.cpp#L145. It's distinguished from size in this way.

stgeke commented 1 year ago

I know but I would prefer a std::vector conform behaviour. IMHO, it's less error-prone.

mkbosmans commented 1 year ago

Why would memory need to behave like std::vector? A vector does not have a way to get it's memory footprint, it is just an implementation of a container, where the user can only do operations on elements, not bytes.

The array class in OCCA is more like std::vector. That does have an [] indexing operator for example. To me the least error prone approach is to keep each class concerned with its own use case and don't muddle things by overlapping functionality between memory and array too much.

stgeke commented 1 year ago

Having in mind that occa::memory is dtype aware all methods should reflect that. May be memory::size() is an exception and returns always the number of bytes.