PandA-2024.02
dfadd.c
Go to the documentation of this file.
1 /*
2 +--------------------------------------------------------------------------+
3 | CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
4 | ======================================================================== |
5 | |
6 | * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda, |
7 | H. Takada and K. Ishii |
8 | Nagoya University, Japan |
9 | |
10 | * Remark : |
11 | 1. This source code is modified to unify the formats of the benchmark |
12 | programs in CHStone. |
13 | 2. Test vectors are added for CHStone. |
14 | 3. If "main_result" is 0 at the end of the program, the program is |
15 | correctly executed. |
16 | 4. Please follow the copyright of each benchmark program. |
17 +--------------------------------------------------------------------------+
18 */
19 /*
20  * Copyright (C) 2008
21  * Y. Hara, H. Tomiyama, S. Honda, H. Takada and K. Ishii
22  * Nagoya University, Japan
23  * All rights reserved.
24  *
25  * Disclaimer of Warranty
26  *
27  * These software programs are available to the user without any license fee or
28  * royalty on an "as is" basis. The authors disclaims any and all warranties,
29  * whether express, implied, or statuary, including any implied warranties or
30  * merchantability or of fitness for a particular purpose. In no event shall the
31  * copyright-holder be liable for any incidental, punitive, or consequential damages
32  * of any kind whatsoever arising from the use of these programs. This disclaimer
33  * of warranty extends to the user of these programs and user's customers, employees,
34  * agents, transferees, successors, and assigns.
35  *
36  */
37 #include <stdio.h>
38 #include "softfloat.c"
39 
40 double
41 ullong_to_double (unsigned long long x)
42 {
43  union
44  {
45  double d;
46  unsigned long long ll;
47  } t;
48 
49  t.ll = x;
50  return t.d;
51 }
52 
53 /*
54 +--------------------------------------------------------------------------+
55 | * Test Vectors (added for CHStone) |
56 | a_input, b_input : input data |
57 | z_output : expected output data |
58 +--------------------------------------------------------------------------+
59 */
60 #define N 46
61 const float64 a_input[N] = {
62  0x7FF8000000000000ULL, /* nan */
63  0x7FF0000000000000ULL, /* inf */
64  0x4000000000000000ULL, /* 2.0 */
65  0x4000000000000000ULL, /* 2.0 */
66  0x3FF0000000000000ULL, /* 1.0 */
67  0x3FF0000000000000ULL, /* 1.0 */
68  0x0000000000000000ULL, /* 0.0 */
69  0x3FF8000000000000ULL, /* 1.5 */
70  0x7FF8000000000000ULL, /* nan */
71  0x7FF0000000000000ULL, /* inf */
72  0x0000000000000000ULL, /* 0.0 */
73  0x3FF8000000000000ULL, /* 1.5 */
74  0xFFF8000000000000ULL, /* nan */
75  0xFFF0000000000000ULL, /* -inf */
76  0xC000000000000000ULL, /* -2.0 */
77  0xC000000000000000ULL, /* -2.0 */
78  0xBFF0000000000000ULL, /* -1.0 */
79  0xBFF0000000000000ULL, /* -1.0 */
80  0x8000000000000000ULL, /* -0.0 */
81  0xBFF8000000000000ULL, /* -1.5 */
82  0xFFF8000000000000ULL, /* nan */
83  0xFFF0000000000000ULL, /* -inf */
84  0x8000000000000000ULL, /* -0.0 */
85  0xBFF8000000000000ULL, /* -1.5 */
86  0x7FF8000000000000ULL, /* nan */
87  0x7FF0000000000000ULL, /* inf */
88  0x3FF0000000000000ULL, /* 1.0 */
89  0x3FF0000000000000ULL, /* 1.0 */
90  0x3FF0000000000000ULL, /* 1.0 */
91  0x0000000000000000ULL, /* 0.0 */
92  0x3FF8000000000000ULL, /* 1.5 */
93  0x7FF8000000000000ULL, /* nan */
94  0x7FF0000000000000ULL, /* inf */
95  0x3FF0000000000000ULL, /* 1.0 */
96  0x4000000000000000ULL, /* 2.0 */
97  0xFFF0000000000000ULL, /* -inf */
98  0xFFF0000000000000ULL, /* -inf */
99  0xBFF0000000000000ULL, /* -1.0 */
100  0xBFF0000000000000ULL, /* -1.0 */
101  0xBFF0000000000000ULL, /* -1.0 */
102  0x8000000000000000ULL, /* -0.0 */
103  0xBFF8000000000000ULL, /* -1.5 */
104  0xFFF8000000000000ULL, /* nan */
105  0xFFF0000000000000ULL, /* -inf */
106  0xBFF0000000000000ULL, /* -1.0 */
107  0xC000000000000000ULL /* -2.0 */
108 };
109 
110 const float64 b_input[N] = {
111  0x3FF0000000000000ULL, /* 1.0 */
112  0x3FF0000000000000ULL, /* 1.0 */
113  0x0000000000000000ULL, /* 0.0 */
114  0x3FF8000000000000ULL, /* 1.5 */
115  0x7FF8000000000000ULL, /* nan */
116  0x7FF0000000000000ULL, /* inf */
117  0x4000000000000000ULL, /* 2.0 */
118  0x4000000000000000ULL, /* 2.0 */
119  0x7FF0000000000000ULL, /* inf */
120  0x7FF0000000000000ULL, /* inf */
121  0x0000000000000000ULL, /* 0.0 */
122  0x3FF0000000000000ULL, /* 1.0 */
123  0xBFF0000000000000ULL, /* -1.0 */
124  0xBFF0000000000000ULL, /* -1.0 */
125  0x8000000000000000ULL, /* -0.0 */
126  0xBFF8000000000000ULL, /* -1.5 */
127  0xFFF8000000000000ULL, /* nan */
128  0xFFF0000000000000ULL, /* -inf */
129  0xC000000000000000ULL, /* -2.0 */
130  0xC000000000000000ULL, /* -2.0 */
131  0xFFF0000000000000ULL, /* -inf */
132  0xFFF0000000000000ULL, /* -inf */
133  0x8000000000000000ULL, /* -inf */
134  0xBFF0000000000000ULL, /* -1.0 */
135  0xFFF0000000000000ULL, /* -inf */
136  0xFFF0000000000000ULL, /* -inf */
137  0xBFF0000000000000ULL, /* -1.0 */
138  0xFFF8000000000000ULL, /* nan */
139  0xFFF0000000000000ULL, /* -inf */
140  0xBFF0000000000000ULL, /* -1.0 */
141  0xC000000000000000ULL, /* -2.0 */
142  0xBFF0000000000000ULL, /* -1.0 */
143  0xBFF0000000000000ULL, /* -1.0 */
144  0x8000000000000000ULL, /* -0.0 */
145  0xBFF8000000000000ULL, /* -1.5 */
146  0x7FF8000000000000ULL, /* nan */
147  0x7FF0000000000000ULL, /* inf */
148  0x3FF0000000000000ULL, /* 1.0 */
149  0x7FF8000000000000ULL, /* nan */
150  0x7FF0000000000000ULL, /* inf */
151  0x3FF0000000000000ULL, /* 1.0 */
152  0x4000000000000000ULL, /* 2.0 */
153  0x3FF0000000000000ULL, /* 1.0 */
154  0x3FF0000000000000ULL, /* 1.0 */
155  0x0000000000000000ULL, /* 0.0 */
156  0x3FF8000000000000ULL /* 1.5 */
157 };
158 
159 const float64 z_output[N] = {
160  0x7FF8000000000000ULL, /* nan */
161  0x7FF0000000000000ULL, /* inf */
162  0x4000000000000000ULL, /* 2.0 */
163  0x400C000000000000ULL, /* 3.5 */
164  0x7FF8000000000000ULL, /* nan */
165  0x7FF0000000000000ULL, /* inf */
166  0x4000000000000000ULL, /* 2.0 */
167  0x400C000000000000ULL, /* 3.5 */
168  0x7FF8000000000000ULL, /* nan */
169  0x7FF0000000000000ULL, /* inf */
170  0x0000000000000000ULL, /* 0.0 */
171  0x4004000000000000ULL, /* 2.5 */
172  0xFFF8000000000000ULL, /* nan */
173  0xFFF0000000000000ULL, /* -inf */
174  0xC000000000000000ULL, /* -2.0 */
175  0xC00C000000000000ULL, /* -3.5 */
176  0xFFF8000000000000ULL, /* nan */
177  0xFFF0000000000000ULL, /* -inf */
178  0xC000000000000000ULL, /* -2.0 */
179  0xC00C000000000000ULL, /* -3.5 */
180  0xFFF8000000000000ULL, /* nan */
181  0xFFF0000000000000ULL, /* -inf */
182  0x8000000000000000ULL, /* -0.0 */
183  0xC004000000000000ULL, /* -2.5 */
184  0x7FF8000000000000ULL, /* nan */
185  0x7FFFFFFFFFFFFFFFULL, /* nan */
186  0x0000000000000000ULL, /* 0.0 */
187  0xFFF8000000000000ULL, /* nan */
188  0xFFF0000000000000ULL, /* -inf */
189  0xBFF0000000000000ULL, /* -1.0 */
190  0xBFE0000000000000ULL, /* -0.5 */
191  0x7FF8000000000000ULL, /* nan */
192  0x7FF0000000000000ULL, /* inf */
193  0x3FF0000000000000ULL, /* 1.0 */
194  0x3FE0000000000000ULL, /* 0.5 */
195  0x7FF8000000000000ULL, /* nan */
196  0x7FFFFFFFFFFFFFFFULL, /* nan */
197  0x0000000000000000ULL, /* 0.0 */
198  0x7FF8000000000000ULL, /* nan */
199  0x7FF0000000000000ULL, /* inf */
200  0x3FF0000000000000ULL, /* 1.0 */
201  0x3FE0000000000000ULL, /* 0.5 */
202  0xFFF8000000000000ULL, /* nan */
203  0xFFF0000000000000ULL, /* -inf */
204  0xBFF0000000000000ULL, /* -1.0 */
205  0xBFE0000000000000ULL /* -0.5 */
206 };
207 
208 int
210 {
211  int main_result;
212  int i;
213  float64 x1, x2;
214  main_result = 0;
215  for (i = 0; i < N; i++)
216  {
217  float64 result;
218  x1 = a_input[i];
219  x2 = b_input[i];
220  result = float64_add (x1, x2);
221  main_result += (result != z_output[i]);
222 
223  printf
224  ("a_input=%016llx b_input=%016llx expected=%016llx output=%016llx (%lf)\n",
225  a_input[i], b_input[i], z_output[i], result,
226  ullong_to_double (result));
227  }
228  printf ("%d\n", main_result);
229  return main_result;
230  }
double ullong_to_double(unsigned long long x)
Definition: dfadd.c:41
#define N
Definition: dfadd.c:60
int main_result
Definition: mips.c:38
const float64 a_input[N]
Definition: dfadd.c:61
int main()
Definition: dfadd.c:209
const float64 b_input[N]
Definition: dfadd.c:110
float64 float64_add(float64 a, float64 b)
Definition: softfloat.c:406
int result[SIZE]
Definition: adpcm.c:800
const float64 z_output[N]
Definition: dfadd.c:159
unsigned long long float64
Definition: softfloat.h:54
x
Return the smallest n such that 2^n >= _x.

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13