File: cosh_s_la.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 (337 lines) | stat: -rw-r--r-- 8,654 bytes parent folder | download | duplicates (3)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/*========================== begin_copyright_notice ============================

Copyright (C) 2020-2021 Intel Corporation

SPDX-License-Identifier: MIT

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

#include "../imf.h"
#pragma OPENCL FP_CONTRACT OFF
typedef struct
{

    unsigned int _sExp_tbl_PH[32];
    unsigned int _sExp_tbl_PL[32];
    unsigned int _sExp_tbl_NH[32];
    unsigned int _sShifter_UISA;
    unsigned int _iIndexMask_UISA;
    unsigned int _iDomainRange_UISA;
    unsigned int _sPC1_UISA;
    unsigned int _sPC2_UISA;
    unsigned int _sPC3_UISA;

    unsigned int _sInvLn2;
    unsigned int _sInvLn2lo;
    unsigned int _sLn2hi;
    unsigned int _sLn2lo;
    unsigned int _sSign;
    unsigned int _sOne;
    unsigned int _sNOne;
    unsigned int _iExpMask;

    unsigned int _sShifter;
    unsigned int _iIndexMask;
    unsigned int _iDomainRange;

    unsigned int _sPC1;
    unsigned int _sPC2;
    unsigned int _sPC3;
    unsigned int _sPC4;

    unsigned int _sPC5;
    unsigned int _sPC6;

    unsigned int _iHalf;

} __internal_scosh_la_data_t;

static __constant __internal_scosh_la_data_t __internal_scosh_la_data = {
    {
     0x3f000000u, 0x3f02cd87u, 0x3f05aac3u, 0x3f08980fu,
     0x3f0b95c2u, 0x3f0ea43au, 0x3f11c3d3u, 0x3f14f4f0u,
     0x3f1837f0u, 0x3f1b8d3au, 0x3f1ef532u, 0x3f227043u,
     0x3f25fed7u, 0x3f29a15bu, 0x3f2d583fu, 0x3f3123f6u,
     0x3f3504f3u, 0x3f38fbafu, 0x3f3d08a4u, 0x3f412c4du,
     0x3f45672au, 0x3f49b9beu, 0x3f4e248cu, 0x3f52a81eu,
     0x3f5744fdu, 0x3f5bfbb8u, 0x3f60ccdfu, 0x3f65b907u,
     0x3f6ac0c7u, 0x3f6fe4bau, 0x3f75257du, 0x3f7a83b3u},
    {
     0x00000000u, 0xb2cea7a9u, 0x32cf9891u, 0xb2feda4bu,
     0xb1e0aba1u, 0xb2e97465u, 0x32e75624u, 0xb2ae0212u,
     0x32a31b71u, 0xb28c5563u, 0x32c12342u, 0x3043125au,
     0xb2ac9d5eu, 0xb2962b08u, 0xb1adeaf6u, 0xb2fc5aa8u,
     0x324fe77au, 0x328ec5f7u, 0xb2c14fe8u, 0xb256663eu,
     0x318aa837u, 0xb2f323a2u, 0x31a8fc24u, 0xb2dc1daau,
     0xb254a58au, 0xb2d04a1cu, 0xb19eab59u, 0xb1c41be6u,
     0xb1c116deu, 0xb2c8464au, 0x31a92436u, 0xb2123758u},
    {
     0x3f000000u, 0x3efa83b3u, 0x3ef5257du, 0x3eefe4bau,
     0x3eeac0c7u, 0x3ee5b907u, 0x3ee0ccdfu, 0x3edbfbb8u,
     0x3ed744fdu, 0x3ed2a81eu, 0x3ece248cu, 0x3ec9b9beu,
     0x3ec5672au, 0x3ec12c4du, 0x3ebd08a4u, 0x3eb8fbafu,
     0x3eb504f3u, 0x3eb123f6u, 0x3ead583fu, 0x3ea9a15bu,
     0x3ea5fed7u, 0x3ea27043u, 0x3e9ef532u, 0x3e9b8d3au,
     0x3e9837f0u, 0x3e94f4f0u, 0x3e91c3d3u, 0x3e8ea43au,
     0x3e8b95c2u, 0x3e88980fu, 0x3e85aac3u, 0x3e82cd87u},
    0x48c00000u,
    0x0000001fu,
    0x42AEAC4Eu,
    0x3F800000u,
    0x3f00010fu,
    0x3e2aaacdu,

    0x3FB8AA3Bu,
    0x32A57060u,
    0x3F317000u,
    0x3805fdf4u,
    0x80000000u,
    0x3f800000u,
    0xbf800000u,
    0x7f800000u,
    0x4b400000u,
    0x0000001fu,
    0x42AEAC4Eu,

    0x3F800000u,
    0x3f000000u,
    0x3e2aaa57u,
    0x3d2aaa72u,
    0x3c091461u,
    0x3ab6a8a3u,

    0x3f000000u
};

static __constant union
{
    unsigned int w;
    float f;
} __scosh_la_Shifter = { 0x4ac000feu };

static __constant union
{
    unsigned int w;
    float f;
} __scosh_la_L2E = { 0x3FB8AA3Bu };

static __constant union
{
    unsigned int w;
    float f;
} __scosh_la_L2H = { 0x3f317218u };

static __constant union
{
    unsigned int w;
    float f;
} __scosh_la_L2L = { 0xb102E308u };

static __constant union
{
    unsigned int w;
    float f;
} __scosh_la_c5 = { 0x3c08ba8bu };

static __constant union
{
    unsigned int w;
    float f;
} __scosh_la_c4 = { 0x3d2aec4eu };

static __constant union
{
    unsigned int w;
    float f;
} __scosh_la_c3 = { 0x3e2aaa9cu };

static __constant union
{
    unsigned int w;
    float f;
} __scosh_la_c2 = { 0x3effffe8u };

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

__attribute__((always_inline))
inline int __internal_scosh_la_cout (float *a, float *r)
{
    int nRet = 0;
    float x = SPIRV_OCL_BUILTIN(fabs, _f32, ) (*a);
    union
    {
        unsigned int w;
        float f;
    } S, Th, Tlr, Th2, xin, xa, res;
    float N, R, poly;
    int index_mask;

    S.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (x, __scosh_la_L2E.f, __scosh_la_Shifter.f);
    N = S.f - __scosh_la_Shifter.f;

    R = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (-N, __scosh_la_L2H.f, x);
    R = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (-N, __scosh_la_L2L.f, R);

    Th.w = S.w << 22;

    index_mask = 0 - (S.w & 1);

    Th.w ^= (index_mask & 0x7504F3u);

    Tlr.w = index_mask & 0x329302AEu;

    poly = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (R, __scosh_la_c5.f, __scosh_la_c4.f);
    poly = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (R, poly, __scosh_la_c3.f);
    poly = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (R, poly, __scosh_la_c2.f);
    poly = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (R, poly, __scosh_la_c1.f);
    poly = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (R, poly, Tlr.f);

    xin.f = x;
    xa.w = xin.w & 0x7fffffffu;

    if (xa.w > 0x42AEAC4Fu)
        goto COSHF_SPECIAL;

    res.f = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (poly, Th.f, Th.f);

    *r = 0.5f * res.f;
    return nRet;

  COSHF_SPECIAL:
    if (xa.w > 0x42b2d4fcu)
    {
        if (xa.w > 0x7f800000u)
        {
            *r = x + x;
            return nRet;
        }

        res.w = 0x7f800000;
        *r = res.f;
        nRet = 3;
        return nRet;
    }

    S.w += 0xfe;
    Th2.w = (S.w >> 2) & 0xff;
    S.w -= (Th2.w << 1);

    Th2.w <<= 23;

    Th.w = S.w << 22;

    Th.w ^= (index_mask & 0x7504F3u);

    res.f = 0.5f * SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (poly, Th.f, Th.f);
    res.f *= Th2.f;

    *r = res.f;
    return nRet;
}

float __ocl_svml_coshf (float a)
{

    float va1;
    float vr1;
    unsigned int vm;

    float r;

    va1 = a;;

    {

        float sN;
        float sM;
        float sR;
        float sR2;
        float sSinh_r;
        float sOut;
        float sG1;
        float sG2;
        float sXSign;
        float sAbsX;

        unsigned int iM;
        unsigned int iAbsX;
        unsigned int iRangeMask;

        float sInvLn2;
        float sShifter;
        float sPC[6];
        unsigned int iHalf;
        unsigned int iDomainRange;

        sInvLn2 = as_float (__internal_scosh_la_data._sInvLn2);
        sShifter = as_float (__internal_scosh_la_data._sShifter);
        sPC[0] = as_float (__internal_scosh_la_data._sPC1);
        sPC[1] = as_float (__internal_scosh_la_data._sPC2);
        sPC[2] = as_float (__internal_scosh_la_data._sPC3);
        sPC[3] = as_float (__internal_scosh_la_data._sPC4);

        sPC[4] = as_float (__internal_scosh_la_data._sPC5);
        sPC[5] = as_float (__internal_scosh_la_data._sPC6);

        sXSign = as_float (__internal_scosh_la_data._sSign);
        iHalf = (__internal_scosh_la_data._iHalf);
        iDomainRange = (__internal_scosh_la_data._iDomainRange);

        sAbsX = as_float ((~(as_uint (sXSign)) & as_uint (va1)));

        sM = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (sAbsX, sInvLn2, sShifter);

        iAbsX = as_uint (sAbsX);

        iRangeMask = ((unsigned int) (-(signed int) ((signed int) iAbsX >= (signed int) iDomainRange)));
        vm = 0;
        vm = iRangeMask;

        sN = (sM - sShifter);
        sOut = as_float (__internal_scosh_la_data._sLn2hi);
        sR = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (-(sOut), sN, sAbsX);
        sOut = as_float (__internal_scosh_la_data._sLn2lo);
        sR = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (-(sOut), sN, sR);

        iM = as_uint (sM);
        iM = ((unsigned int) (iM) << (23));
        sR2 = (sR * sR);

        iAbsX = (iHalf + iM);
        sG1 = as_float (iAbsX);
        iAbsX = (iHalf - iM);
        sG2 = as_float (iAbsX);
        sM = sG1;
        sG1 = (sG1 - sG2);
        sG2 = (sM + sG2);

        sSinh_r = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (sPC[4], sR2, sPC[2]);
        sSinh_r = (sSinh_r * sR2);
        sSinh_r = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (sSinh_r, sR, sR);

        sOut = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (sPC[5], sR2, sPC[3]);
        sOut = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (sOut, sR2, sPC[1]);
        sOut = (sOut * sR2);
        sOut = (sOut * sG2);
        sOut = SPIRV_OCL_BUILTIN(fma, _f32_f32_f32, ) (sG1, sSinh_r, sOut);
        vr1 = (sOut + sG2);
    }

    if ((vm) != 0)
    {
        float _vapi_arg1[1];
        float _vapi_res1[1];
        ((float *) _vapi_arg1)[0] = va1;
        ((float *) _vapi_res1)[0] = vr1;
        __internal_scosh_la_cout (_vapi_arg1, _vapi_res1);
        vr1 = ((float *) _vapi_res1)[0];
    };
    r = vr1;;

    return r;

}