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


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, August 8, 2019 11:25 AM, Bill Schmidt wschmidt@linux.ibm.com wrote:

>
> Let me jump in here to answer a general question that I think Bert has
> had for a while.
> For the PPC64LE ABI, we should be returning everything through registers
> wherever possible.  The ABI supports multiple return values of the same
> type (up to 8 vector return values, for example), using the same
> registers used for passing parameters.  For simplicity in this example,
> I'll use the AltiVec-style types (vector double), but this works
> identically if you use more generically defined vector types.
> #include <altivec.h>
> struct sincosret
> {
>     vector double sinvals;
>     vector double cosvals;
> };
> struct sincosret
> mysincos (vector double a)
> {
>     struct sincosret scr;
>     scr.sinvals = a+a;  // May be slightly incorrect
>     scr.cosvals = a*a;  // Ditto
>     return scr;
> }
> This will result in the values being returned in VR2 and VR3:
> xvmuldp 35,34,34
> xvadddp 34,34,34
> blr
> This is preferable to returning values indirectly through memory, which
> on older POWER processors can result in stalls from the store and load
> being too close together and possibly executed out of order.  The cost
> is pretty much negligible compared to the cost of computing sin/cos, but
> we might as well do it the best way that the ABI provides.

I believe we can now answer the issues that Joseph raised earlier in this thread.
Those questions are here: https://sourceware.org/ml/libc-alpha/2019-08/msg00022.html

The PowerPC64 double-precision vector sincos will have this as its prototype:
struct sincosret _ZGVbN2v_sincos (vector double);

The corresponding single-precision vector sincosf will have a prototype:
struct sincosretf _ZGVbN4v_sincosf (vector float);
-----------------------

We also need a new attribute that will indicate when scalar sincos[f] in a loop can be vectorized using the newly redefined PowerPC64 vector sincos[f] functions. None of the existing attributes can be used since the technique used to return multiple values in registers is new AFAIU. So, Bill, are you the designer who can attest that what is agreed to here for the sincos API and ABI will be faithfully reflected in the ABI document?


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