Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022

CppNorth · 5K views · 2022 · 1:07:19

Open on YouTube

C, C++, Rust, Go & systems languagesSoftware performance & optimizationtalk

Why Stack Overflow recommends it

Stack Overflow users link it whenever a question involves multidimensional arrays, views or std::mdspan, since it covers extents, layouts, slicing and the performance trade-offs of iterating over multidimensional data.

Recommended by 3 people across 8 different months, 2022 to 2025.

What it is

A CppNorth 2022 conference talk by Bryce Adelstein Lelbach (NVIDIA) on C++23's std::mdspan, a non-owning multidimensional view with configurable layout and access, plus the open problem that it has no iterators. He explores several approaches to performant multidimensional iteration and how well compilers optimize them.

What people said

Recommends Pepijn Kramer · 2022-10 · Stack Overflow · on “How to return multi- dimensional-vector of given dimension and type?”

Fun fact : Multidimensional arrays are not build in yet, but it is being worked on Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video]

Recommends Pepijn Kramer · 2022-10 · Stack Overflow · on “Shared memory between std::vector and Eigen::VectorXd”

Maybe you can take some inspiration from this upcoming C++23 feature (mdspan): Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video] .

Recommends Pepijn Kramer · 2023-01 · Stack Overflow · on “Slice and assign a matrix from a matrix class using a proxy class in C++”

Not an answer but this might be interesting to you : Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video] . It is about std::mdspan [LINK] C++23. Which is there to make views on multidimensional data.

Recommends tylo · 2023-02 · Stack Overflow · on “Why is iterating over std::ranges::views::join so slow”

I think you may find the answer to this in the talk " Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video] " from around 30 - 45 minutes in. Peter: Fair enough, I'll give a full answer: In summary, most optimizers are not able to vectorize the flattened/joined iterator. He shows several approaches where the iterator either contains the current MD indices, one where it only contains the linear index (must then reconstruct the MD indices which is even worse), and one approach with coroutines, which works better on some compilers - so it requires a good coroutine implementation + compiler support. The supposedly bad performance led to the conclusion that C++23 std::mdspan is n

Recommends Pepijn Kramer · 2023-12 · Stack Overflow · on “vector Initialize reference from return value”

Maybe you mean something like a view on data inside the matrix? Something like mdspan [LINK] perhaps? Better explained here : Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video]

Recommends Pepijn Kramer · 2023-12 · Stack Overflow · on “How to find an element in mdspan”

I don't know the answer (not enough experience with mdspan yet), from what I gathered so far you can only reduce dimensionality not go back up. But I know this is a good presentation Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video] that covers the use of mdspan

Recommends Pepijn Kramer · 2024-08 · Stack Overflow · on “Is it possible to reference template template arguments?”

Side note you might be interested in std::mdspan [LINK] (C++23) or a (C++14/17 library implementation of that). Watch Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video]

Recommends Ahmed AEK · 2024-10 · Stack Overflow · on “How to store std::mdspan?”

@DamirTenishev you can watch this video, it explains the basic and advanced use cases as well as the downsides Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video]

Recommends Pepijn Kramer · 2024-10 · Stack Overflow · on “Dynamically allocated multidimensional arrays in C++”

Maybe after watching this Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video] you will change your mind :)

Recommends Pepijn Kramer · 2025-01 · Stack Overflow · on “Why is `index_type` in `std::extents` allowed to be signed and how can I know the lower and upper bound for such signed integer types?”

Maybe this video will help you : Multidimensional C++ - Bryce Adelstein Lelbach - CppNorth 2022 [this video] . Extents are covered fairly early on. However when you say "highest index value" do you mean the "extent with the highest value" (or in other words the largest dimension?)