C++ Logo

std-proposals

Advanced search

Re: [std-proposals] SIMD by just operating on 2 arrays

From: bmon Dor <dorbmons_at_[hidden]>
Date: Wed, 12 Apr 2023 23:09:34 +0800
I think it is a bad idea to do so.
We need a clear syntax to know if the SIMD would be applied.

Giuseppe D'Angelo via Std-Proposals <std-proposals_at_[hidden]>
于2023年4月12日周三 22:50写道:

> On 12/04/2023 16:30, samuel ammonius via Std-Proposals wrote:
> > Using SIMD for addition performs the exact same process but with lists
> > of numbers instead of single ones, so why not just do this:
> >
> > float a[4] = {1.0f, 5.0f, 0.0f, 0.005f};
> >
> > float b[4] = {0.0f, 1000.0f, 0.0f, 9.0f};
> >
> > float c[4] = a + b; // SIMD
> >
> > Common SIMD-operable types - like lists of 2, 4, or 8 floats or ints -
> > could be operated together like this, and other types could just produce
> > a syntax error like "This array type cannot be operated on".
>
> What if my platform doesn't have SIMD?
>
> In general, is writing std::fixed_simd<float, 4> instead of float[4] in
> the above so bad that it warrants such a language change?
>
>
> > Does anyone think this might be a good idea? The only issue I can see is
> > that people may be misled into thinking this concatenates the arrays.
>
> It's also a "language API break" (?) -- at the moment, `a - b` actually
> compiles and yields ptrdiff_t, not float[4]. (But if you actually
> evaluate it, it's UB https://eel.is/c++draft/expr#add-5.3 .)
>
> --
> Giuseppe D'Angelo
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-04-12 15:09:47