On Thu, Dec 5, 2019 at 6:45 PM GT <tng...@protonmail.com> wrote:
>
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, December 5, 2019 4:44 AM, Richard Biener 
> <richard.guent...@gmail.com> wrote:
>
> ...
> ...
> ...
>
> > >
> > > I'm trying to identify the source code which needs modification but I 
> > > need help proceeding.
> > > I am comparing two compilations: The first is a simple file with a call 
> > > to sin in a loop.
> > > Vectorization succeeds. The second is an almost identical file but with a 
> > > call to sincos
> > > in the loop. Vectorization fails.
> > > In gdb, the earliest code location where the two compilations differ is 
> > > in function
> > > number_of_iterations_exit_assumptions in file tree-ssa-loop-niter.c. Line
> > > op0 = gimple_cond_lhs (stmt);
> > > returns a tree which when analyzed in function instantiate_scev_r (in 
> > > file tree-scalar-evolution.c)
> > > results in the first branch of the switch being taken for sincos. For 
> > > sin, the 2nd branch of the
> > > switch is taken.
> > > How can I correlate stmt in the source line above to the relevant line in 
> > > any dump among those created
> > > using debugging dump option -fdump-tree-all?
> >
> > grep ;)
> >
> > Can you provide a testcase with a simd attribute annotated cexpi that
> > one can play with?
> >
>
> On an x86_64 system, run Example 2 at this link:
>
> sourceware.org/glibc/wiki/libmvec
>
> After verifying vectorization (by finding a name with prefix _ZGV and suffix 
> _sin in a.out), replace
> the call to sin by one to sincos. The file should be similar to this:
>
> ================
>
> #include <math.h>
>
> int N = 3200;
> double c[3200];
> double b[3200];
> double a[3200];
>
> int main (void)
> {
>   int i;
>
>   for (i = 0; i < N; i += 1)
>   {
>     sincos (a[i], &b[i], &c[i]);
>   }
>
>   return (0);
> }
>
> ================
>
> In addition to the options shown in Example 2, I passed GCC flags 
> -fopt-info-all, -fopt-info-internal and
> -fdump-tree-all to obtain more verbose messages.
>
> That should show vectorization failing for sincos, and diagnostics on the 
> screen indicating reason(s) for
> the failure.
>
> To perform the runs on PPC64 requires building both GCC and GLIBC with 
> modifications not yet accepted
> into the main development branches of the projects.
>
> Please let me know if you are able to run on x86_64; if not, then perhaps I 
> can push the local GCC
> changes to some github repository. GLIBC changes are available at branch 
> tuliom/libmvec of the
> development repository.

So I used

void sincos(double x, double *sin, double *cos);
_Complex double __attribute__((__simd__("notinbranch")))
__builtin_cexpi (double);

int N = 3200;
double c[3200];
double b[3200];
double a[3200];

int main (void)
{
  int i;

  for (i = 0; i < N; i += 1)
  {
    sincos (a[i], &b[i], &c[i]);
  }

  return (0);
}

and get

t.c:2:58: warning: unsupported return type ‘complex double’ for simd

so I suppose that would need fixing / ABI adjustments.  Then vectorization
fails with the expected

t.c:13:3: note:   ==> examining statement: _8 = __builtin_cexpi (_1);
t.c:13:3: note:   get vectype for scalar type: complex double
t.c:15:5: missed:   not vectorized: unsupported data-type complex double
t.c:13:3: missed:  can't determine vectorization factor.

For the ABI thing the alternative is to go with "something" for sincos
and have the vectorizer query that something at cexpi vectorization
time, emitting code for that ABI.

But of course the vectorizer needs to be teached to deal with the cexpi
call in the IL which was very low priority because there wasn't any
SIMD implementation of sincos (with whatever ABI).  I can help with
that to some extent, but I wonder what openmp says to _Complex
types and simd functions for those?  Jakub?

Richard.

> Bert.

Reply via email to