C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: a standard way to tell the compiler to choose an implementation version following policies ?
From: Ronan Keryell (rkeryell_at_[hidden])
Date: 2020-06-18 19:12:40


On 6/12/20 2:01 PM, c.ohanessian via Std-Discussion wrote:

> ‌‌Hi,

Hello

> My name is Cesar OHANESSIAN, a C++ enthusiast. I am currently working on
> the implementation of a multidimensional array, the purpose being to
> extend std::array while being adaptable to most of the usual conventions
> (row/col vector, row/col major). I would like to allow people to mix the
> conventions, not only for compatibility reasons but also for local
> optimization purposes, for example:
>
>  - the matrix-vector product in col vector/row major gives 3
> independent std::inner_product with contiguous iterators
>  - the recopy of a specific basis vector is a simple memcpy in col
> vector/col major (or in row vector/row major).
Have you look at the mdspan and mdarray proposal already?
https://wg21.link/P0009
https://wg21.link/P1684

It would be interesting to get some feedback about what is lacking there
at the first place or to improve the proposal or the implementation, as
they are already used in production for HPC and embedded applications.

> With that in mind, iterating over two arrays with different conventions
> is intrinsically sub optimal in memory and is a deciding factor to keep
> or reject a local optimization regarding its compatibility impact (when
> doing std::copy, std::equal).
>
> I would like to tell the compiler to choose between different iterator
> implementations (all the stride order permutations) which are all
> equivalent in their defined behavior, following some policies (memory
> space/execution speed). It's a low level decision, depending on various
> fixed costs including the iterator implementation itself (dealing with
> for loops and counters). It would be pleasant to have a standard way for
> taking benefit of the compiler decisions, allowing more flexibility at
> compile time => each template instantiation has a unique solution so we
> shouldn't have to perform infinite experimental plans ! Does such a
> feature exist ?

It is not clear to me what you are looking at.
A first approach is to use meta-programming and introspection on mdspan
layouts for example.
Otherwise, there are 50 years of research on automatic parallelization
looking at how to optimize these problems, but I am not sure it has a
lot to do with C++ itself.
Perhaps you should look at what ISO C++ SG19 is doing related to
machine-learning?
More generally you could look at what some frameworks like MLIR are
doing in this area.

By looking only at the subject of the message about policies, perhaps it
is also similar to https://github.com/chriskohlhoff/propria implementing
properties from https://wg21.link/P1393.

See you,
--
Ronan KERYELL, Xilinx Research Labs / San José, California.


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups