kokkos / kokkos

Kokkos C++ Performance Portability Programming Ecosystem: The Programming Model - Parallel Execution and Memory Abstraction
https://kokkos.org
Other
1.85k stars 421 forks source link

Kokkos::Array fixes and improvements #6355

Open nliber opened 1 year ago

nliber commented 1 year ago

While looking to add a deduction guide to Kokkos::Array, I had to add unit tests, which uncovered some issues.

Q: Should these four things be conflated into the same public type? The only place that contiguous and strided Kokkos::Array is used is in core/src/impl/Kokkos_ViewArray.hpp for defining ViewMapping<Traits, Kokkos::Array<>>::reference_type.

My vote would be for Kokkos::Array to only support owning semantics, and to deprecate/remove the third (Proxy) template parameter. The other semantics can be moved to their own non-templated (private?) types.

Q: I can fix the bugs in the funky strided assignment operators. Should I, or should I just remove this unused functionality?

My vote is to remove the assignment operators from contiguous and strided Kokkos:Array.

Another issue:

The subscripting operators are templated on integral and enum types. I assume (but don't know) this was done to avoid compiler warnings, such as signed/unsigned mismatches. However, while it deliberately supports enums, it doesn't support scoped enums. Also, unlike C array subscripting operators, it doesn't work on things convertible to size_t.

Q: Should scoped enums be supported for subscripting? The reason to do so is that it encourages people to use them over unscoped enums. (If we intend not to support them, I'll give it a better error message.).

My vote is to support scoped enums.

Q: Should type convertible to size_t be supported for subscripting? I don't see why not, and it meets user expectations (especially for new users).

My vote is to support types convertible to size_t.

The plan (breaking up my current PR into these):

ajpowelsnl commented 1 year ago

@nliber - Would you like to discuss this issue on Wed.?

nliber commented 1 year ago

@ajpowelsnl Sure!

nliber commented 2 months ago

Update: all that is left is documenting the public API. The plan is to not document the deprecated parts.