summaryrefslogtreecommitdiffstats
path: root/all_pairs/source/audiobeam/audiobeamlibm.c
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
commit386b7d3366f1359a265da207a9cafa3edf553b64 (patch)
treec76120c2c138faed822e4ae386be6ef22a738a78 /all_pairs/source/audiobeam/audiobeamlibm.c
parent54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff)
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'all_pairs/source/audiobeam/audiobeamlibm.c')
-rw-r--r--all_pairs/source/audiobeam/audiobeamlibm.c423
1 files changed, 423 insertions, 0 deletions
diff --git a/all_pairs/source/audiobeam/audiobeamlibm.c b/all_pairs/source/audiobeam/audiobeamlibm.c
new file mode 100644
index 0000000..259f40b
--- /dev/null
+++ b/all_pairs/source/audiobeam/audiobeamlibm.c
@@ -0,0 +1,423 @@
1/*
2
3 This program is part of the TACLeBench benchmark suite.
4 Version V 2.0
5
6 Name: audiobeamlibm.c
7
8 Author: Ian Lance Taylor and J.T. Conklin
9
10 Function: IEEE754 software library routines.
11
12 Source: Sun Microsystems and Cygnus
13
14 Original name: Unknown
15
16 Changes: No major functional changes.
17
18 License: See the terms below.
19
20*/
21
22/*
23 ====================================================
24 Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
25
26 Developed at SunPro, a Sun Microsystems, Inc. business.
27 Permission to use, copy, modify, and distribute this
28 software is freely granted, provided that this notice
29 is preserved.
30 ====================================================
31*/
32
33
34#include "audiobeamlibm.h"
35#include "audiobeamlibmath.h"
36
37
38static const int audiobeam_npio2_hw[] = {
39 0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00,
40 0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00,
41 0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100,
42 0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00,
43 0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00,
44 0x4242c700, 0x42490f00
45};
46
47static const float
48audiobeam_invpio2 = 6.3661980629e-01f, /* 0x3f22f984 */
49audiobeam_pio2_1 = 1.5707855225e+00f, /* 0x3fc90f80 */
50audiobeam_pio2_1t = 1.0804334124e-05f, /* 0x37354443 */
51audiobeam_pio2_2 = 1.0804273188e-05f, /* 0x37354400 */
52audiobeam_pio2_2t = 6.0770999344e-11f, /* 0x2e85a308 */
53audiobeam_pio2_3 = 6.0770943833e-11f, /* 0x2e85a300 */
54audiobeam_pio2_3t = 6.1232342629e-17f; /* 0x248d3132 */
55
56static const float
57audiobeam_C1 = 4.1666667908e-02f, /* 0x3d2aaaab */
58audiobeam_C2 = -1.3888889225e-03f, /* 0xbab60b61 */
59audiobeam_C3 = 2.4801587642e-05f, /* 0x37d00d01 */
60audiobeam_C4 = -2.7557314297e-07f, /* 0xb493f27c */
61audiobeam_C5 = 2.0875723372e-09f, /* 0x310f74f6 */
62audiobeam_C6 = -1.1359647598e-11f; /* 0xad47d74e */
63
64static const float
65audiobeam_S1 = -1.6666667163e-01f, /* 0xbe2aaaab */
66audiobeam_S2 = 8.3333337680e-03f, /* 0x3c088889 */
67audiobeam_S3 = -1.9841270114e-04f, /* 0xb9500d01 */
68audiobeam_S4 = 2.7557314297e-06f, /* 0x3638ef1b */
69audiobeam_S5 = -2.5050759689e-08f, /* 0xb2d72f34 */
70audiobeam_S6 = 1.5896910177e-10f; /* 0x2f2ec9d3 */
71
72static const float
73audiobeam_two25 = 3.355443200e+07f, /* 0x4c000000 */
74audiobeam_twom25 = 2.9802322388e-08f; /* 0x33000000 */
75
76
77int audiobeam___ieee754_rem_pio2f( float x, float *y )
78{
79 float z, w, t, r, fn;
80 int i, j, n = 0, ix, hx;
81
82 AUDIOBEAM_GET_FLOAT_WORD( hx, x );
83 ix = hx & 0x7fffffff;
84 if ( ix <= 0x3f490fd8 ) {
85 y[0] = x;
86 y[1] = 0;
87 return 0;
88 }
89 if ( ix < 0x4016cbe4 ) {
90 if ( hx > 0 ) {
91 z = x - audiobeam_pio2_1;
92 if ( ( ix & 0xfffffff0 ) != 0x3fc90fd0 ) {
93 y[0] = z - audiobeam_pio2_1t;
94 y[1] = ( z - y[0] ) - audiobeam_pio2_1t;
95 } else {
96 z -= audiobeam_pio2_2;
97 y[0] = z - audiobeam_pio2_2t;
98 y[1] = ( z - y[0] ) - audiobeam_pio2_2t;
99 }
100 return 1;
101 } else {
102 z = x + audiobeam_pio2_1;
103 if ( ( ix & 0xfffffff0 ) != 0x3fc90fd0 ) {
104 y[0] = z + audiobeam_pio2_1t;
105 y[1] = ( z - y[0] ) + audiobeam_pio2_1t;
106 } else {
107 z += audiobeam_pio2_2;
108 y[0] = z + audiobeam_pio2_2t;
109 y[1] = ( z - y[0] ) + audiobeam_pio2_2t;
110 }
111 return -1;
112 }
113 }
114 if ( ix <= 0x43490f80 ) {
115 t = audiobeam_fabsf( x );
116 n = ( int ) ( t * audiobeam_invpio2 + audiobeam_half );
117 fn = ( float )n;
118 r = t - fn * audiobeam_pio2_1;
119 w = fn * audiobeam_pio2_1t;
120 if ( n < 32 && ( int )( ix & 0xffffff00 ) != audiobeam_npio2_hw[n - 1] )
121 y[0] = r - w;
122 else {
123 unsigned int high;
124 j = ix >> 23;
125 y[0] = r - w;
126 AUDIOBEAM_GET_FLOAT_WORD( high, y[0] );
127 i = j - ( ( high >> 23 ) & 0xff );
128 if ( i > 8 ) {
129 t = r;
130 w = fn * audiobeam_pio2_2;
131 r = t - w;
132 w = fn * audiobeam_pio2_2t - ( ( t - r ) - w );
133 y[0] = r - w;
134 AUDIOBEAM_GET_FLOAT_WORD( high, y[0] );
135 i = j - ( ( high >> 23 ) & 0xff );
136 if ( i > 25 ) {
137 t = r;
138 w = fn * audiobeam_pio2_3;
139 r = t - w;
140 w = fn * audiobeam_pio2_3t - ( ( t - r ) - w );
141 y[0] = r - w;
142 }
143 }
144 }
145 y[1] = ( r - y[0] ) - w;
146 if ( hx < 0 ) {
147 y[0] = -y[0];
148 y[1] = -y[1];
149 return -n;
150 } else return n;
151 }
152 if ( ix >= 0x7f800000 ) {
153 y[0] = y[1] = x - x;
154 return 0;
155 }
156
157 return n;
158}
159
160
161float audiobeam___kernel_cosf( float x, float y )
162{
163 float a, hz, z, r, qx;
164 int ix;
165 AUDIOBEAM_GET_FLOAT_WORD( ix, x );
166 ix &= 0x7fffffff;
167 if ( ix < 0x32000000 ) {
168 if ( ( ( int )x ) == 0 ) return audiobeam_one;
169 }
170 z = x * x;
171 r = z * ( audiobeam_C1 + z * ( audiobeam_C2 + z * ( audiobeam_C3 + z *
172 ( audiobeam_C4 + z *
173 ( audiobeam_C5 + z * audiobeam_C6 ) ) ) ) );
174 if ( ix < 0x3e99999a )
175 return audiobeam_one - ( ( float )0.5f * z - ( z * r - x * y ) );
176 else {
177 if ( ix > 0x3f480000 )
178 qx = ( float )0.28125f;
179 else
180 AUDIOBEAM_SET_FLOAT_WORD( qx, ix - 0x01000000 );
181 hz = ( float )0.5f * z - qx;
182 a = audiobeam_one - qx;
183 return a - ( hz - ( z * r - x * y ) );
184 }
185}
186
187
188float audiobeam___kernel_sinf( float x, float y, int iy )
189{
190 float z, r, v;
191 int ix;
192 AUDIOBEAM_GET_FLOAT_WORD( ix, x );
193 ix &= 0x7fffffff;