C++ Logo

std-proposals

Advanced search

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

From: connor horman <chorman64_at_[hidden]>
Date: Wed, 12 Apr 2023 10:45:28 -0400
The issue would be an operation like -. a-b is already well-formed (albeit
with undefined behaviour) and has type std::ptrdiff_t. This is because a
and b decay to float* each, then pointer subtraction occurs.

On Wed, Apr 12, 2023 at 10:30 samuel ammonius via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> I know there's already an std::experimental solution in place for SIMD,
> but I think there's a better way to go about this.
>
> When you add 2 variables together in C, the generated assembly basically
> says:
>
> 1. Put the first number into register A
> 2. Put the second number into register B
> 3. Calculate the result into register C
> 4. Copy register C to the desired memory location
>
> 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".
>
> 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.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-04-12 14:45:41