ORNL / ORNL/cpp-proposals-pub

Issaquah (Feb 2023) P2642 presentation

Open
#325 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
29
Forks
26
PR merge metrics
No merged PRs in 30d

Description

P2642 (padded mdspan layouts)

Use cases

  1. Overaligned access to the beginning of each contiguous segment of elements

  2. Representing column-major or row-major matrices whose stride is greater than the number of rows

    • "Pitched allocations*

    • Critical use case for matrix algorithms; the layout of BLAS and LAPACK

Use case for padding_stride=0 (at compile time)

Leftmost (for layout_left_padded; rightmost for layout_right_padded)
extent is zero at compile time: extents<Integral, 0, ...>.

template<int Value>
using Int = integral_constant<int, Value>;

layout_left::mapping<extents<int, 0, 10>> mapping{};
mdspan m{nullptr, mapping};
auto m_sub = submdspan(m, tuple{Int<0>{}, Int<0>{}}, full_extent);

Before P2642, m_sub would have mapping type
layout_stride::mapping<extents<int, 0, 10>>.

After P2642, m_sub would have mapping type
layout_left_padded<0>::mapping<extents<int, 0, 10>>.

Errata

  • .extents() returns by value, not by const reference

    • [mdspan.layout.reqmts] specifies that .extents() returns const extents_type&, but layout_{left,right}_padded::mapping::extents in P2642 returns extents_type.

    • layout_{left,right}_padded::mapping does not store the user's extents object

      • It stores the "padded extents"

      • Effectively a "layout_{left,right} of a bigger array"

    • Fix: Change to return const extents_type&; rely on lifetime extension

  • Specification of layout_left_padded<ps>::mapping(const layout_left_padded<ps>::mapping<OtherExtents>&) converting constructors and operator== may need adjustments, so that the spec as written can deduce the input padding_stride template argument. (See comments below.)

    • Consider adding a public member to layout_{left,right}_padded::mapping so users can get the padding_stride template argument without needing to write a traits class

Implementation

PR 237 in https://github.com/kokkos/mdspan

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the P2642 use cases and errata in this issue, then review implementation PR 237 in the kokkos/mdspan repository. The issue discusses presentation material and specification corrections, but does not identify files, tests, or a clear completion condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.