PandA-2024.02
dfmul.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 20
61 const float64 a_input[N] = {
62  0x7FF0000000000000ULL, /* inf */
63  0x7FFF000000000000ULL, /* nan */
64  0x7FF0000000000000ULL, /* inf */
65  0x7FF0000000000000ULL, /* inf */
66  0x3FF0000000000000ULL, /* 1.0 */
67  0x0000000000000000ULL, /* 0.0 */
68  0x3FF0000000000000ULL, /* 1.0 */
69  0x0000000000000000ULL, /* 0.0 */
70  0x8000000000000000ULL, /* -0.0 */
71  0x3FF0000000000000ULL, /* 1.0 */
72  0x3FF0000000000000ULL, /* 1.0 */
73  0x4000000000000000ULL, /* 2.0 */
74  0x3FD0000000000000ULL, /* 0.25 */
75  0xC000000000000000ULL, /* -2.0 */
76  0xBFD0000000000000ULL, /* -0.25 */
77  0x4000000000000000ULL, /* 2.0 */
78  0xBFD0000000000000ULL, /* -0.25 */
79  0xC000000000000000ULL, /* -2.0 */
80  0x3FD0000000000000ULL, /* 0.25 */
81  0x0000000000000000ULL /* 0.0 */
82 };
83 
84 const float64 b_input[N] = {
85  0xFFFFFFFFFFFFFFFFULL, /* nan */
86  0xFFF0000000000000ULL, /* -inf */
87  0x0000000000000000ULL, /* nan */
88  0x3FF0000000000000ULL, /* -inf */
89  0xFFFF000000000000ULL, /* nan */
90  0x7FF0000000000000ULL, /* inf */
91  0x7FF0000000000000ULL, /* inf */
92  0x3FF0000000000000ULL, /* 1.0 */
93  0x3FF0000000000000ULL, /* 1.0 */
94  0x0000000000000000ULL, /* 0.0 */
95  0x8000000000000000ULL, /* -0.0 */
96  0x3FD0000000000000ULL, /* 0.25 */
97  0x4000000000000000ULL, /* 2.0 */
98  0xBFD0000000000000ULL, /* -0.25 */
99  0xC000000000000000ULL, /* -2.0 */
100  0xBFD0000000000000ULL, /* -0.25 */
101  0x4000000000000000ULL, /* -2.0 */
102  0x3FD0000000000000ULL, /* 0.25 */
103  0xC000000000000000ULL, /* -2.0 */
104  0x0000000000000000ULL /* 0.0 */
105 };
106 
107 const float64 z_output[N] = {
108  0xFFFFFFFFFFFFFFFFULL, /* nan */
109  0x7FFF000000000000ULL, /* nan */
110  0x7FFFFFFFFFFFFFFFULL, /* nan */
111  0x7FF0000000000000ULL, /* inf */
112  0xFFFF000000000000ULL, /* nan */
113  0x7FFFFFFFFFFFFFFFULL, /* nan */
114  0x7FF0000000000000ULL, /* inf */
115  0x0000000000000000ULL, /* 0.0 */
116  0x8000000000000000ULL, /* -0.0 */
117  0x0000000000000000ULL, /* 0.0 */
118  0x8000000000000000ULL, /* -0.0 */
119  0x3FE0000000000000ULL, /* 0.5 */
120  0x3FE0000000000000ULL, /* 0.5 */
121  0x3FE0000000000000ULL, /* 0.5 */
122  0x3FE0000000000000ULL, /* 0.5 */
123  0xBFE0000000000000ULL, /* -0.5 */
124  0xBFE0000000000000ULL, /* -0.5 */
125  0xBFE0000000000000ULL, /* -0.5 */
126  0xBFE0000000000000ULL, /* -0.5 */
127  0x0000000000000000ULL /* 0.0 */
128 };
129 
130 int
132 {
133  int main_result;
134  int i;
135  float64 x1, x2;
136  main_result = 0;
137  for (i = 0; i < N; i++)
138  {
139  float64 result;
140  x1 = a_input[i];
141  x2 = b_input[i];
142  result = float64_mul (x1, x2);
143  main_result += (result != z_output[i]);
144 
145  printf
146  ("a_input=%016llx b_input=%016llx expected=%016llx output=%016llx (%lf)\n",
147  a_input[i], b_input[i], z_output[i], result,
148  ullong_to_double (result));
149  }
150  printf ("%d\n", main_result);
151  return main_result;
152  }
int main_result
Definition: mips.c:38
const float64 b_input[N]
Definition: dfmul.c:84
#define N
Definition: dfmul.c:60
float64 float64_mul(float64 a, float64 b)
Definition: softfloat.c:241
int result[SIZE]
Definition: adpcm.c:800
const float64 z_output[N]
Definition: dfmul.c:107
unsigned long long float64
Definition: softfloat.h:54
int main()
Definition: dfmul.c:131
double ullong_to_double(unsigned long long x)
Definition: dfmul.c:41
const float64 a_input[N]
Definition: dfmul.c:61
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