kokkos / array_ref

Polymorphic multidimensional array view
36 stars 9 forks source link

Add paragraph explaining why extents are tricky here? #14

Closed jlperla closed 9 years ago

jlperla commented 9 years ago

I think that a paragraph explaining why extents are tricky is useful. Maybe something like:

The complexity in implementing extents is that the type depends on whether the extent was given statically or dynamically. As discussed before, this is essential to ensure a zero-overhead penalty for the abstraction. For example, consider view< int[ ][3][3] > array_1 vs. view< int[ ][ ][ ] > array_2. Calling array_1.extent(1) returns a constexpr const std::size_t, while array_2.extent(1) returns a const std::size_t. This static information is essential for the compiler to generate an efficient operator() or for interfacing libraries such as Eigen to query an underlying static extent to enable SIMD optimizations based on the known extent length, etc.

hcedwar commented 9 years ago

The extent function should always be constexpr. If a view is constructed with constant expression dimensions then the result of the extent function should be observable as constexpr. This is what helps force optimization. Added note to extent function about return value for implicit dimensions of default constructed view and explicit dimensions queried with literal input value.