"Fossies" - the Fresh Open Source Software Archive

Member "pocl-1.8/lib/kernel/ocml/src/acospiF.cl" (12 Oct 2021, 1051 Bytes) of package /linux/misc/pocl-1.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lisp source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 /*===--------------------------------------------------------------------------
    2  *                   ROCm Device Libraries
    3  *
    4  * This file is distributed under the University of Illinois Open Source
    5  * License. See LICENSE.TXT for details.
    6  *===------------------------------------------------------------------------*/
    7 
    8 #include "mathF.h"
    9 
   10 CONSTATTR float
   11 MATH_MANGLE(acospi)(float x)
   12 {
   13     const float piinv = 0x1.45f306p-2f;
   14 
   15     float ax = BUILTIN_ABS_F32(x);
   16 
   17     float rt = MATH_MAD(-0.5f, ax, 0.5f);
   18     float x2 = ax * ax;
   19     float r = ax > 0.5f ? rt : x2;
   20 
   21     float u = r * MATH_MAD(r, MATH_MAD(r, MATH_MAD(r, MATH_MAD(r, 
   22                   MATH_MAD(r, 
   23                       -0x1.3f1c6cp-8f, 0x1.2ac560p-6f), 0x1.80aab4p-8f), 0x1.e53378p-7f),
   24                       0x1.86680ap-6f), 0x1.b29c5ap-5f);
   25 
   26     float s = MATH_FAST_SQRT(r);
   27     float ztp = 2.0f * MATH_MAD(s, u, piinv*s);
   28     float ztn = 1.0f - ztp;
   29     float zt =  x < 0.0f ? ztn : ztp;
   30     float z = 0.5f - MATH_MAD(x, u, piinv*x);
   31     z = ax > 0.5f ? zt : z;
   32 
   33     return z;
   34 }
   35