mdspan revision
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 20/100
Research direction
No source files or tests are named. Start by reviewing the constructor overview and the listed design questions for mdarray, then identify the project’s relevant implementation and test locations. Done means reaching an agreed design for constructors, move behavior, and container extraction, rather than making a narrowly scoped edit.
Written by the indexing model from the issue text.
Description
Super Brief mdarray introduction
Why we want mdarray
Creating a simple 2D array with mdspan requires multiple steps because mdspan is non-owning.
// Create a mapping:
layout_left map(extents(N,M));
// Create an allocation
vector<int> data(map.required_span_size());
// Create mdspan:
mdspan a(data.data(), map);
mdarray is a multidimensional array with value-semantics and makes the above simpler
// default layout
mdarray a(N,M);
// other layout
mdarray b(layout_left(extents(N,M)));
What aspects of mdspan does mdarray have
mdarray has the
element_type,extentsand- layout policy aspects of
mdspan
The accessor policy is replaced by a container type.
template<class ElementType, class Extents, class Layout, class Accessor>
class mdspan {
public:
...
template<class ... Indices>
reference operator [] (Indices ... idx) const { return acc_.access(ptr_, map_(idx...)); }
private:
typename Accessor::data_handle_type ptr_;
Layout::mapping<Extents> map_;
Accessor acc_;
};
template<class ElementType, class Extents, class Layout, class Container>
class mdarray {
public:
...
template<class ... Indices>
reference operator [] (Indices ... idx) { return ctr_[map_(idx...)]); }
private:
Layout::mapping<Extents> map_;
Container ctr_;
};
Design issues left at last time
- Which constructors do we want?
- What is mdarrays move behavior
- Do we want to support moving out (extracting) the container
Constructor
- multiple options for how to design overload set
- complicated
Overview Table
The following table gives an overview of the three approaches.
In this table we use these shorthands:
mda_t: a specialization ofmdarrayc_t: thecontainer_typeofmda_te: anextentsobjectm: a layout mapping objectme: aextentsobject or a layout mapping objectc: an instance ofc_ta: an allocator objectv: a value (something convertible tomda_t::value_typemda: anmdarrayobject, not necessarily the same type asmda_tmds: anmdspanobejct, not necessarily the same as returned bymda_t::to_mdspan
| Arguments | Current | Minimal | Variadic |
|---|---|---|---|
| `default` | `mda_t()` | `mda_t()` | `mda_t()` |
| integrals | `mda_t(10, 10)` | `mda_t(10, 10)` | `mda_t(10, 10)` |
| mapping/extents | `mda_t(me)` | `mda_t(me)` | `mda_t(me)` |
| container + integrals | `mda_t(extents{10, 10}, c)` | `mda_t(extents{10, 10}, c)` | `mda_t(extents{10, 10}, c)` |
| move container + integrals | `mda_t(extents{10, 10}, move(c))` | `mda_t(extents{10, 10}, move(c))` | `mda_t(extents{10, 10}, move(c))` |
| container + mapping/extents | `mda_t(me, c)` | `mda_t(me, c)` | `mda_t(me, c)` |
| move container + mapping | `mda_t(me, move(c))` | `mda_t(me, move(c))` | `mda_t(me, move(c))` |
| container + alloc + mapping/extents | `mda_t(me, c, a)` | `mda_t(me, c_t(c,a))` | `mda_t(me, c, a)` |
| move container + alloc + mapping | `mda_t(me, move(c), a)` | `mda_t(me, c_t(move(c),a))` | `mda_t(me, move(c), a)` |
| extents + value | `mda_t(e, v)` | `mda_t(e, c_t(map_t(e).required_span_size(), v))` | `mda_t(e, v)` |
| mapping + value | `mda_t(m, v)` | `mda_t(m, c_t(m.required_span_size(), v))` | `mda_t(m, v)` |
| mapping + custom container size | `mda_t(m, c_t(s))` | `mda_t(m, c_t(s))` | `mda_t(m, c_t(s))` or `mda_t(m, s)` for integrals not convertible to `value_type` |
| mapping + custom container size + value | `mda_t(m, c_t(s, v))` | `mda_t(m, c_t(s, v))` | `mda_t(m, s, v)` |
| extents + value + alloc | `mda_t(e, v, a)` | `mda_t(e, c_t(map_t(e).required_span_size(), v, a)))` | `mda_t(e, v , a)` |
| mapping + value + alloc | `mda_t(m, v, a)` | `mda_t(m, move(c_t(m.required_span_size(), v, a)))` | `mda_t(m, v, a)` |
| mapping + custom container size + alloc | `mda_t(m, c_t(s, a))` | `mda_t(m, c_t(s, a))` | `mda_t(m, c_t(s, a))` or `mda_t(m, s, a)` for integrals not convertible to `value_type` |
| mapping + custom container size + value + alloc | `mda_t(m, c_t(s, v, a))` | `mda_t(m, c_t(s, v, a))` | `mda_t(m, s, v, a)` |
| iterators | `mda_t(m, c_t(begin, end))` | `mda_t(m, c_t(begin, end))` | `mda_t(m, begin, end)` |
| range | `mda_t(m, c_t(r))` | `mda_t(m, c_t(r))` | `mda_t(m, r)` |
| converting mdarray | `mda_t(mda)` | `mda_t(mda)` | `mda_t(mda)` |
| compatible mdspan | `mda_t(mds)` | `mda_t(mds)` | `mda_t(mds)` |
| compatible mdspan + allocator | `mda_t(mds, a)` | `mda_t(mds, a)` | `mda_t(mds, a)` |
- Dominant language
- HTML
- Stars
- 29
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ORNL/cpp-proposals-pub
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
ORNL/cpp-proposals-pub#394 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
ORNL/cpp-proposals-pub#393 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ORNL/cpp-proposals-pub#297 ·
-
P3242: LWG ReviewOpen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ORNL/cpp-proposals-pub#484 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ORNL/cpp-proposals-pub#483 · 2 comments ·
All issues in ORNL/cpp-proposals-pub
Similar issues
-
compiler-rt:asan
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
llvm/llvm-project#242921 ·
Maintainers usually reply within 1 day
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the modulePossibly taken @MalithaPrabhashana claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
jaseci-labs/jac#10756 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
area:interp bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
yidika-lab/yidika#80 ·
Maintainers usually reply within 1 day