1 minute read

https://youtu.be/9fRnSQkpNGg

Summary: cppcon23 talk about performance impact of mdspan

Refresher on mdspan
std::mdspan is a non-owning (!) view of multidimensional data, e.g. think of a block of a matrix. similar to std::string_view or std::span. value-type semantics s.t. object can be easily copied, e.g. pass-by-value is possible.

Talk discusses impact of using mdspan vs supplying raw pointer to function.

mdspan supports strides (think: creating a view of a matrix for only every 2nd element). std::layout_stride has runtime overhead!

The number of parameters and their sizes determine if they are passed via registers or memory (slower!). This is compiler specific. Current implementations:

  • msvc: number of arguments <= 4. each of size <= 8byte.
  • others: number of arguments <= 6. each of size <= 16byte.