On 30/09/2019 18:30, GT wrote:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Monday, September 30, 2019 9:52 AM, Szabolcs Nagy <[email protected]>
> wrote:
>
>> On 27/09/2019 20:23, GT wrote:
>>
>>> I am attempting to create a vector version of sincos for PPC64.
>>> The relevant discussion thread is on the GLIBC libc-alpha mailing list.
>>> Navigate it beginning at
>>> https://sourceware.org/ml/libc-alpha/2019-09/msg00334.html
>>> The intention is to reuse as much as possible from the existing GCC
>>> implementation of other libmvec functions.
>>> My questions are: Which function(s) in GCC;
>>>
>>> 1. Gather scalar function input arguments, from multiple loop iterations,
>>> into a single vector input argument for the vector function version?
>>> 2. Distribute scalar function outputs, to appropriate loop iteration
>>> result, from the single vector function output result?
>>>
>>> I am referring especially to vectorization of sin and cos.
>>
>> i wonder if gcc can auto-vectorize scalar sincos
>> calls, the vectorizer seems to want the calls to
>> have no side-effect, but attribute pure or const
>> is not appropriate for sincos (which has no return
>> value but takes writable pointer args)
>
> 1. Do you mean whether x86_64 already does auto-vectorize sincos?
any current target with simd attribute or omp delcare simd support.
> 2. Where in the code do you see the vectorizer require no side-effect?
i don't know where it is in the code, but
__attribute__((simd)) float foo (float);
void bar (float *restrict a, float *restrict b)
{
for(int i=0; i<4000; i++)
a[i] = foo (b[i]);
}
is not vectorized, however it gets vectorized if
i add __attribute__((const)) to foo
OR
if i add '#pragma omp simd' to the loop and compile with
-fopenmp-simd.
(which makes sense to me: you don't want to vectorize
if you don't know the side-effects, otoh, there is no
attribute to say that i know there will be no side-effects
in functions taking pointer arguments so i don't see
how sincos can get vectorized)
>> "#pragma omp simd" on a loop seems to work but i
>> could not get unannotated sincos loops to vectorize.
>>
>> it seems it would be nice if we could add pure/const
>> somehow (maybe to the simd variant only? afaik openmp
>> requires no sideeffects for simd variants, but that's
>> probably only for explicitly marked loops?)
>
> 1. Example 1 and Example 2 at https://sourceware.org/glibc/wiki/libmvec show
> the 2 different
> ways to activate auto-vectorization. When you refer to "unannotated sincos",
> which of
> the 2 techniques do you mean?
example 1 annotates the loop with #pragma omp simd.
(and requires -fopenmp-simd cflag to work)
example 2 is my goal where -ftree-vectorize is enough
without annotation.
> 2. Which function was auto-vectorized by "pragma omp simd" in the loop?
see example above.