This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PPC64 libmvec sincos/sincosf ABI


On 8/8/19 10:48 AM, GT wrote:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, August 8, 2019 1:33 PM, Bill Schmidt wschmidt@linux.ibm.com wrote:
>
>> I'm trying to work my way into understanding the veclibabi support in
>> GCC, so please bear with me.
>>
>> Why are we interested in sincos at all?  There is no handling of sincos
>> in the i386 SVML or ACML interfaces for libmvec.  They handle only sin
>> and cos separately, as does libmassv for Power.  I am coming late to the
>> discussion, but I don't understand how this fits into the libmvec ABI
>> requirements.
>>
> 1. I understood sincos to be included in implementation of libmvec on PPC64
> because x86_64 provides that capability. There is discussion of an initial
> implementation bug in x86_64 sincos at:
> https://sourceware.org/bugzilla/show_bug.cgi?id=20024
>
> The final comment in the thread declares the bug fixed in GLIBC 2.24.

Interesting.  I believe you -- I'm still learning about this.  It
appears that, although there is an interface provided in libmvec, there
isn't GCC code to generate calls to it.  I'd like to be proven wrong
about that.
>
> 2. I am trying to understand how GCC currently vectorizes loops containing calls
> to sincos. GLIBC wiki page https://sourceware.org/glibc/wiki/libmvec has two
> examples of code that GCC will vectorize if GLIBC is properly implemented. I
> changed Example 2 so that it now reads as below:
>
> tst_sincos.c
> -------------------
> #include <math.h>
>
> int N = 3200;
>
> double a[3200];
> double b[3200];
> double c[3200];
>
> int main (void)
> {
>   int i;
>
>   for (i = 0; i < N; i += 1)
>   {
>     sincos (a[i], &b[i], &c[i]);
>   }
>
>   return (0);
> }
> --------------------
>
> Compiled it with gcc version 8.3.1 using the command in the Example:
> gcc ./tst_sincos.c -O1 -ftree-loop-vectorize -ffast-math -lm -mavx
>
> Does not generate vectorized call. There is the following warning issued
> by gcc:
>
> ----------------------
> ./tst_sincos.c: In function ‘main’:
> ./tst_sincos.c:15:5: warning: implicit declaration of function ‘sincos’ [-Wimplicit-function-declaration]
>      sincos (a[i], &b[i], &c[i]);
>      ^~~~~~
> ./tst_sincos.c:15:5: warning: incompatible implicit declaration of built-in function ‘sincos’
> ./tst_sincos.c:15:5: note: include ‘<math.h>’ or provide a declaration of ‘sincos’
> ./tst_sincos.c:2:1:
> +#include <math.h>
>
> ./tst_sincos.c:15:5:
>      sincos (a[i], &b[i], &c[i]);
>      ^~~~~~
> ----------------------
>
> The same warning is issued even when not requesting vectorization:
> gcc ./tst_sincos.c -lm
>
> All the above was on an x86_64 system. Got the same warning on PPC64 POWER8.
>
> What is the issue with tst_sincos.c above? math.h is clearly included.
I agree that this is odd.  I have no explanation for you.

You aren't going to get the vectorized function calls having removed the
#pragma omp simd, I think.

But even with that addressed, I don't think you'll see the vectorized
function calls, because GCC doesn't specifically handle the sincos
builtin.  In ix86_veclibabi_svml, there's a switch statement that
describes which builtins are handled.  These are the cases that result
in calls to libmvec:

    CASE_CFN_EXP:
    CASE_CFN_LOG:
    CASE_CFN_LOG10:
    CASE_CFN_POW:
    CASE_CFN_TANH:
    CASE_CFN_TAN:
    CASE_CFN_ATAN:
    CASE_CFN_ATAN2:
    CASE_CFN_ATANH:
    CASE_CFN_CBRT:
    CASE_CFN_SINH:
    CASE_CFN_SIN:
    CASE_CFN_ASINH:
    CASE_CFN_ASIN:
    CASE_CFN_COSH:
    CASE_CFN_COS:
    CASE_CFN_ACOSH:
    CASE_CFN_ACOS:

CASE_CFN_SINCOS does not appear among them.  It's possibly because the
interface is different enough that GCC hasn't been taught to handle it. 
Or perhaps it's an oversight.  The sin and cos examples from the link
above should work, since those are covered here.

Anyway, at a minimum we probably want to provide the libmvec sincos[f]
functions for ppc64le (see the other fork of this thread for the return
value discussion), but at the moment existing vector library ABI support
in GCC doesn't seem to target those.

Bill


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]