Is C++23 std::mdspan a Zero-overhead Abstraction? - Oleksandr Bacherikov - CppCon 2023

Explore the zero-overhead abstraction of C++23's std::mdspan, discussing its template parameters, matrix addition, and performance optimization, while delving into its complex implementation and limitations.

Key takeaways
  • MDSpan has a significant amount of template parameters
  • MDSpan can be used to formulate matrix addition with zero overhead
  • The assembly code for MDSpan has an extra block of instructions compared to the non-MDSpan version
  • The extra instructions are not related to vectorization, but rather due to the way parameters are passed
  • Some functions in MDSpan can be optimized by reusing storage and avoiding stack access
  • The standard MDSpan requires extents to be one of the specializations of the standard type
  • The presentation of MDSpan is important for performance-critical code
  • Parameters should not be passed unnecessarily to functions where performance is critical
  • The complexity of implementing MDSpan is due to the ABI limitations
  • It is difficult to make MDSpan work with non-standard register sizes
  • The presentation of MDSpan can be used for image processing and other applications.