File: erf_s_ep_noLUT.cl

package info (click to toggle)
intel-graphics-compiler 1.0.12504.6-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 83,912 kB
  • sloc: cpp: 910,147; lisp: 202,655; ansic: 15,197; python: 4,025; yacc: 2,241; lex: 1,570; pascal: 244; sh: 104; makefile: 25
file content (154 lines) | stat: -rw-r--r-- 4,392 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*===================== begin_copyright_notice ==================================

Copyright (c) 2022 Intel Corporation

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

======================= end_copyright_notice ==================================*/

#include "../imf.h"
#pragma OPENCL FP_CONTRACT OFF

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___b5 = { 0x3605524cu };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___b4 = { 0x39953450u };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___b3 = { 0x3b7e8d75u };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___b2 = { 0x3d5983e4u };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___b1 = { 0x3e4635acu };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___b0 = { 0x3f906ebau };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___a5 = { 0x381cf31fu };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___a4 = { 0x3a9b6bd9u };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___a3 = { 0x3c792ec0u };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___a2 = { 0x3dec40c3u };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___a1 = { 0x3f013f71u };

static __constant union
{
    unsigned int w;
    float f;
} __serf_ep___a0 = { 0x3f800000u };

__attribute__((always_inline))
inline int __internal_serf_ep_nolut_cout (float *a, float *pres)
{
    int nRet = 0;
    float xin = *a;
    union
    {
        unsigned int w;
        float f;
    } x, xa, res;
    int iexpon;
    unsigned int sgn_x;
    float dR, dR2;
    union
    {
        unsigned int w;
        float f;
    } apoly, bpoly, Y;
    xa.f = xin;
    sgn_x = xa.w & 0x80000000;
    xa.w ^= sgn_x;
    dR = (xa.f > 4.0f) ? 4.0f : xa.f;
    dR2 = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (dR, dR, 0.0f);
    dR = (xa.w > 0x7f800000UL) ? xa.f : dR;
    bpoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (__serf_ep___b5.f, dR2, __serf_ep___b4.f);
    apoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (__serf_ep___a5.f, dR2, __serf_ep___a4.f);
    bpoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (bpoly.f, dR2, __serf_ep___b3.f);
    apoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (apoly.f, dR2, __serf_ep___a3.f);
    bpoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (bpoly.f, dR2, __serf_ep___b2.f);
    apoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (apoly.f, dR2, __serf_ep___a2.f);
    bpoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (bpoly.f, dR2, __serf_ep___b1.f);
    apoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (apoly.f, dR2, __serf_ep___a1.f);
    bpoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (bpoly.f, dR2, __serf_ep___b0.f);
    apoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (apoly.f, dR2, __serf_ep___a0.f);
    Y.f = 1.0f / apoly.f;
    bpoly.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (bpoly.f, dR, 0.0f);
    res.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (bpoly.f, Y.f, 0.0f);
    res.f = (res.f > 1.0f) ? 1.0f : res.f;
    res.f = (xa.w <= 0x7f800000) ? res.f : (xa.f + xa.f);
    res.w ^= sgn_x;
    *pres = res.f;
    return nRet;
}

float __ocl_svml_erff_ep_noLUT (float a)
{
    float va1;
    float vr1;
    float r;
    va1 = a;
    __internal_serf_ep_nolut_cout (&va1, &vr1);
    r = vr1;
    return r;
}