[PATCH v5 00/10] Implement extents and layouts from the mdspan header.
Luc Grosheintz
luc.grosheintz@gmail.com
Tue Apr 29 12:46:06 GMT 2025
This patch series follows up on:
https://gcc.gnu.org/pipermail/libstdc++/2025-April/061078.html
As agreed, I'm appending commits that add the layouts to this patch
series. Each layout is added in a separate commit and tests are added in
the immediately following commit.
Changes since v4 to std::extents related code:
* Use else-branch with constexpr if.
* Introduce `_S_is_compatible_extents` and use it to improve the quality
of the generated code for `operator==`.
* Make `_S_is_dynamic` consteval.
* Silence warning in two cases of `(_Counts, 0)...` about unused
expression (left of the comma operator).
* Use `cmp_equal` to compare values of with different integer types.
* Fix missing include <utility>.
* The following bugs in test code were fixed:
- assumed that `size_t` was 64 bits wide (arm).
- assumed that `cstdint` is imported implicitly (aarch64).
- tested that a function pointer was not null, instead of calling
the function.
- used and incorrect integer type.
New since v4:
* `layout_left`, `layout_right` and `layout_stride`.
In the implementation of `layout_stride::is_exhaustive`, I encounter an
issue that the standard requires that there exists a permutation of the
ranks, such that the permutated layout is a `layout_left` [0]. If the size
of the extent is zero, then this condition implies that the method
`is_exhaustive` returns false for some choices of strides, even though
the layout mapping requirements for `is_exhaustive` are always satisfied
trivially, i.e. because for every element in the empty set anything is
true. One example is `extents = {0, 0, 1}` and `strides = {1, 1, 1}`.
Currently, I haven't been able to come up with a way of checking the
condition (other than brute force checking all permutations), which is
why I've implemented a slightly different check, that satisfies the
layout mapping requirements, but also return true for the example
provided above.
[0]: https://eel.is/c++draft/mdspan.layout#stride.obs-5.2
Thank you Tomasz for the excellent review of v4.
Luc Grosheintz (10):
libstdc++: Setup internal FTM for mdspan.
libstdc++: Add header mdspan to the build-system.
libstdc++: Implement std::extents [PR107761].
libstdc++: Add tests for std::extents.
libstdc++: Implement layout_left from mdspan.
libstdc++: Add tests for layout_left.
libstdc++: Implement layout_right from mdspan.
libstdc++: Add tests for layout_right.
libstdc++: Implement layout_stride from mdspan.
libstdc++: Add tests for layout_stride.
libstdc++-v3/doc/doxygen/user.cfg.in | 1 +
libstdc++-v3/include/Makefile.am | 1 +
libstdc++-v3/include/Makefile.in | 1 +
libstdc++-v3/include/bits/version.def | 9 +
libstdc++-v3/include/bits/version.h | 9 +
libstdc++-v3/include/precompiled/stdc++.h | 1 +
libstdc++-v3/include/std/mdspan | 863 ++++++++++++++++++
libstdc++-v3/src/c++23/std.cc.in | 6 +-
.../mdspan/extents/class_mandates_neg.cc | 8 +
.../23_containers/mdspan/extents/ctor_copy.cc | 82 ++
.../23_containers/mdspan/extents/ctor_ints.cc | 62 ++
.../mdspan/extents/ctor_shape.cc | 160 ++++
.../mdspan/extents/custom_integer.cc | 87 ++
.../23_containers/mdspan/extents/misc.cc | 224 +++++
.../mdspan/layouts/class_mandate_neg.cc | 23 +
.../23_containers/mdspan/layouts/ctors.cc | 301 ++++++
.../23_containers/mdspan/layouts/mapping.cc | 431 +++++++++
.../23_containers/mdspan/layouts/stride.cc | 359 ++++++++
18 files changed, 2627 insertions(+), 1 deletion(-)
create mode 100644 libstdc++-v3/include/std/mdspan
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/class_mandates_neg.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_copy.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_shape.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/custom_integer.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/extents/misc.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/layouts/ctors.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/layouts/mapping.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/layouts/stride.cc
--
2.49.0
More information about the Libstdc++
mailing list