1 |
5 |
sergeykhbr |
diff --git a/arch/riscv64/soc/riscv_gnss/Kbuild b/arch/riscv64/soc/riscv_gnss/Kbuild
|
2 |
|
|
index d035736..2f092f2 100644
|
3 |
|
|
--- a/arch/riscv64/soc/riscv_gnss/Kbuild
|
4 |
|
|
+++ b/arch/riscv64/soc/riscv_gnss/Kbuild
|
5 |
|
|
@@ -5,4 +5,4 @@ ccflags-y +=-I$(srctree)/drivers
|
6 |
|
|
|
7 |
|
|
asflags-y := ${ccflags-y}
|
8 |
|
|
|
9 |
|
|
-obj-y += soc.o
|
10 |
|
|
+obj-y += soc.o dhry/dhry_1.o dhry/dhry_2.o
|
11 |
|
|
diff --git a/arch/riscv64/soc/riscv_gnss/dhry/dhry.h b/arch/riscv64/soc/riscv_gnss/dhry/dhry.h
|
12 |
|
|
new file mode 100644
|
13 |
|
|
index 0000000..5ff61aa
|
14 |
|
|
--- /dev/null
|
15 |
|
|
+++ b/arch/riscv64/soc/riscv_gnss/dhry/dhry.h
|
16 |
|
|
@@ -0,0 +1,432 @@
|
17 |
|
|
+/*
|
18 |
|
|
+ ****************************************************************************
|
19 |
|
|
+ *
|
20 |
|
|
+ * "DHRYSTONE" Benchmark Program
|
21 |
|
|
+ * -----------------------------
|
22 |
|
|
+ *
|
23 |
|
|
+ * Version: C, Version 2.1
|
24 |
|
|
+ *
|
25 |
|
|
+ * File: dhry.h (part 1 of 3)
|
26 |
|
|
+ *
|
27 |
|
|
+ * Date: May 25, 1988
|
28 |
|
|
+ *
|
29 |
|
|
+ * Author: Reinhold P. Weicker
|
30 |
|
|
+ * Siemens AG, E STE 35
|
31 |
|
|
+ * Postfach 3240
|
32 |
|
|
+ * 8520 Erlangen
|
33 |
|
|
+ * Germany (West)
|
34 |
|
|
+ * Phone: [xxx-49]-9131-7-20330
|
35 |
|
|
+ * (8-17 Central European Time)
|
36 |
|
|
+ * Usenet: ..!mcvax!unido!estevax!weicker
|
37 |
|
|
+ *
|
38 |
|
|
+ * Original Version (in Ada) published in
|
39 |
|
|
+ * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
|
40 |
|
|
+ * pp. 1013 - 1030, together with the statistics
|
41 |
|
|
+ * on which the distribution of statements etc. is based.
|
42 |
|
|
+ *
|
43 |
|
|
+ * In this C version, the following C library functions are used:
|
44 |
|
|
+ * - strcpy, strcmp (inside the measurement loop)
|
45 |
|
|
+ * - printf, scanf (outside the measurement loop)
|
46 |
|
|
+ * In addition, Berkeley UNIX system calls "times ()" or "time ()"
|
47 |
|
|
+ * are used for execution time measurement. For measurements
|
48 |
|
|
+ * on other systems, these calls have to be changed.
|
49 |
|
|
+ *
|
50 |
|
|
+ * Collection of Results:
|
51 |
|
|
+ * Reinhold Weicker (address see above) and
|
52 |
|
|
+ *
|
53 |
|
|
+ * Rick Richardson
|
54 |
|
|
+ * PC Research. Inc.
|
55 |
|
|
+ * 94 Apple Orchard Drive
|
56 |
|
|
+ * Tinton Falls, NJ 07724
|
57 |
|
|
+ * Phone: (201) 389-8963 (9-17 EST)
|
58 |
|
|
+ * Usenet: ...!uunet!pcrat!rick
|
59 |
|
|
+ *
|
60 |
|
|
+ * Please send results to Rick Richardson and/or Reinhold Weicker.
|
61 |
|
|
+ * Complete information should be given on hardware and software used.
|
62 |
|
|
+ * Hardware information includes: Machine type, CPU, type and size
|
63 |
|
|
+ * of caches; for microprocessors: clock frequency, memory speed
|
64 |
|
|
+ * (number of wait states).
|
65 |
|
|
+ * Software information includes: Compiler (and runtime library)
|
66 |
|
|
+ * manufacturer and version, compilation switches, OS version.
|
67 |
|
|
+ * The Operating System version may give an indication about the
|
68 |
|
|
+ * compiler; Dhrystone itself performs no OS calls in the measurement loop.
|
69 |
|
|
+ *
|
70 |
|
|
+ * The complete output generated by the program should be mailed
|
71 |
|
|
+ * such that at least some checks for correctness can be made.
|
72 |
|
|
+ *
|
73 |
|
|
+ ***************************************************************************
|
74 |
|
|
+ *
|
75 |
|
|
+ * History: This version C/2.1 has been made for two reasons:
|
76 |
|
|
+ *
|
77 |
|
|
+ * 1) There is an obvious need for a common C version of
|
78 |
|
|
+ * Dhrystone, since C is at present the most popular system
|
79 |
|
|
+ * programming language for the class of processors
|
80 |
|
|
+ * (microcomputers, minicomputers) where Dhrystone is used most.
|
81 |
|
|
+ * There should be, as far as possible, only one C version of
|
82 |
|
|
+ * Dhrystone such that results can be compared without
|
83 |
|
|
+ * restrictions. In the past, the C versions distributed
|
84 |
|
|
+ * by Rick Richardson (Version 1.1) and by Reinhold Weicker
|
85 |
|
|
+ * had small (though not significant) differences.
|
86 |
|
|
+ *
|
87 |
|
|
+ * 2) As far as it is possible without changes to the Dhrystone
|
88 |
|
|
+ * statistics, optimizing compilers should be prevented from
|
89 |
|
|
+ * removing significant statements.
|
90 |
|
|
+ *
|
91 |
|
|
+ * This C version has been developed in cooperation with
|
92 |
|
|
+ * Rick Richardson (Tinton Falls, NJ), it incorporates many
|
93 |
|
|
+ * ideas from the "Version 1.1" distributed previously by
|
94 |
|
|
+ * him over the UNIX network Usenet.
|
95 |
|
|
+ * I also thank Chaim Benedelac (National Semiconductor),
|
96 |
|
|
+ * David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
|
97 |
|
|
+ * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
|
98 |
|
|
+ * for their help with comments on earlier versions of the
|
99 |
|
|
+ * benchmark.
|
100 |
|
|
+ *
|
101 |
|
|
+ * Changes: In the initialization part, this version follows mostly
|
102 |
|
|
+ * Rick Richardson's version distributed via Usenet, not the
|
103 |
|
|
+ * version distributed earlier via floppy disk by Reinhold Weicker.
|
104 |
|
|
+ * As a concession to older compilers, names have been made
|
105 |
|
|
+ * unique within the first 8 characters.
|
106 |
|
|
+ * Inside the measurement loop, this version follows the
|
107 |
|
|
+ * version previously distributed by Reinhold Weicker.
|
108 |
|
|
+ *
|
109 |
|
|
+ * At several places in the benchmark, code has been added,
|
110 |
|
|
+ * but within the measurement loop only in branches that
|
111 |
|
|
+ * are not executed. The intention is that optimizing compilers
|
112 |
|
|
+ * should be prevented from moving code out of the measurement
|
113 |
|
|
+ * loop, or from removing code altogether. Since the statements
|
114 |
|
|
+ * that are executed within the measurement loop have NOT been
|
115 |
|
|
+ * changed, the numbers defining the "Dhrystone distribution"
|
116 |
|
|
+ * (distribution of statements, operand types and locality)
|
117 |
|
|
+ * still hold. Except for sophisticated optimizing compilers,
|
118 |
|
|
+ * execution times for this version should be the same as
|
119 |
|
|
+ * for previous versions.
|
120 |
|
|
+ *
|
121 |
|
|
+ * Since it has proven difficult to subtract the time for the
|
122 |
|
|
+ * measurement loop overhead in a correct way, the loop check
|
123 |
|
|
+ * has been made a part of the benchmark. This does have
|
124 |
|
|
+ * an impact - though a very minor one - on the distribution
|
125 |
|
|
+ * statistics which have been updated for this version.
|
126 |
|
|
+ *
|
127 |
|
|
+ * All changes within the measurement loop are described
|
128 |
|
|
+ * and discussed in the companion paper "Rationale for
|
129 |
|
|
+ * Dhrystone version 2".
|
130 |
|
|
+ *
|
131 |
|
|
+ * Because of the self-imposed limitation that the order and
|
132 |
|
|
+ * distribution of the executed statements should not be
|
133 |
|
|
+ * changed, there are still cases where optimizing compilers
|
134 |
|
|
+ * may not generate code for some statements. To a certain
|
135 |
|
|
+ * degree, this is unavoidable for small synthetic benchmarks.
|
136 |
|
|
+ * Users of the benchmark are advised to check code listings
|
137 |
|
|
+ * whether code is generated for all statements of Dhrystone.
|
138 |
|
|
+ *
|
139 |
|
|
+ * Version 2.1 is identical to version 2.0 distributed via
|
140 |
|
|
+ * the UNIX network Usenet in March 1988 except that it corrects
|
141 |
|
|
+ * some minor deficiencies that were found by users of version 2.0.
|
142 |
|
|
+ * The only change within the measurement loop is that a
|
143 |
|
|
+ * non-executed "else" part was added to the "if" statement in
|
144 |
|
|
+ * Func_3, and a non-executed "else" part removed from Proc_3.
|
145 |
|
|
+ *
|
146 |
|
|
+ ***************************************************************************
|
147 |
|
|
+ *
|
148 |
|
|
+ * Defines: The following "Defines" are possible:
|
149 |
|
|
+ * -DREG=register (default: Not defined)
|
150 |
|
|
+ * As an approximation to what an average C programmer
|
151 |
|
|
+ * might do, the "register" storage class is applied
|
152 |
|
|
+ * (if enabled by -DREG=register)
|
153 |
|
|
+ * - for local variables, if they are used (dynamically)
|
154 |
|
|
+ * five or more times
|
155 |
|
|
+ * - for parameters if they are used (dynamically)
|
156 |
|
|
+ * six or more times
|
157 |
|
|
+ * Note that an optimal "register" strategy is
|
158 |
|
|
+ * compiler-dependent, and that "register" declarations
|
159 |
|
|
+ * do not necessarily lead to faster execution.
|
160 |
|
|
+ * -DNOSTRUCTASSIGN (default: Not defined)
|
161 |
|
|
+ * Define if the C compiler does not support
|
162 |
|
|
+ * assignment of structures.
|
163 |
|
|
+ * -DNOENUMS (default: Not defined)
|
164 |
|
|
+ * Define if the C compiler does not support
|
165 |
|
|
+ * enumeration types.
|
166 |
|
|
+ * -DTIMES (default)
|
167 |
|
|
+ * -DTIME
|
168 |
|
|
+ * The "times" function of UNIX (returning process times)
|
169 |
|
|
+ * or the "time" function (returning wallclock time)
|
170 |
|
|
+ * is used for measurement.
|
171 |
|
|
+ * For single user machines, "time ()" is adequate. For
|
172 |
|
|
+ * multi-user machines where you cannot get single-user
|
173 |
|
|
+ * access, use the "times ()" function. If you have
|
174 |
|
|
+ * neither, use a stopwatch in the dead of night.
|
175 |
|
|
+ * "printf"s are provided marking the points "Start Timer"
|
176 |
|
|
+ * and "Stop Timer". DO NOT use the UNIX "time(1)"
|
177 |
|
|
+ * command, as this will measure the total time to
|
178 |
|
|
+ * run this program, which will (erroneously) include
|
179 |
|
|
+ * the time to allocate storage (malloc) and to perform
|
180 |
|
|
+ * the initialization.
|
181 |
|
|
+ * -DHZ=nnn
|
182 |
|
|
+ * In Berkeley UNIX, the function "times" returns process
|
183 |
|
|
+ * time in 1/HZ seconds, with HZ = 60 for most systems.
|
184 |
|
|
+ * CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
|
185 |
|
|
+ * A VALUE.
|
186 |
|
|
+ *
|
187 |
|
|
+ ***************************************************************************
|
188 |
|
|
+ *
|
189 |
|
|
+ * Compilation model and measurement (IMPORTANT):
|
190 |
|
|
+ *
|
191 |
|
|
+ * This C version of Dhrystone consists of three files:
|
192 |
|
|
+ * - dhry.h (this file, containing global definitions and comments)
|
193 |
|
|
+ * - dhry_1.c (containing the code corresponding to Ada package Pack_1)
|
194 |
|
|
+ * - dhry_2.c (containing the code corresponding to Ada package Pack_2)
|
195 |
|
|
+ *
|
196 |
|
|
+ * The following "ground rules" apply for measurements:
|
197 |
|
|
+ * - Separate compilation
|
198 |
|
|
+ * - No procedure merging
|
199 |
|
|
+ * - Otherwise, compiler optimizations are allowed but should be indicated
|
200 |
|
|
+ * - Default results are those without register declarations
|
201 |
|
|
+ * See the companion paper "Rationale for Dhrystone Version 2" for a more
|
202 |
|
|
+ * detailed discussion of these ground rules.
|
203 |
|
|
+ *
|
204 |
|
|
+ * For 16-Bit processors (e.g. 80186, 80286), times for all compilation
|
205 |
|
|
+ * models ("small", "medium", "large" etc.) should be given if possible,
|
206 |
|
|
+ * together with a definition of these models for the compiler system used.
|
207 |
|
|
+ *
|
208 |
|
|
+ **************************************************************************
|
209 |
|
|
+ *
|
210 |
|
|
+ * Dhrystone (C version) statistics:
|
211 |
|
|
+ *
|
212 |
|
|
+ * [Comment from the first distribution, updated for version 2.
|
213 |
|
|
+ * Note that because of language differences, the numbers are slightly
|
214 |
|
|
+ * different from the Ada version.]
|
215 |
|
|
+ *
|
216 |
|
|
+ * The following program contains statements of a high level programming
|
217 |
|
|
+ * language (here: C) in a distribution considered representative:
|
218 |
|
|
+ *
|
219 |
|
|
+ * assignments 52 (51.0 %)
|
220 |
|
|
+ * control statements 33 (32.4 %)
|
221 |
|
|
+ * procedure, function calls 17 (16.7 %)
|
222 |
|
|
+ *
|
223 |
|
|
+ * 103 statements are dynamically executed. The program is balanced with
|
224 |
|
|
+ * respect to the three aspects:
|
225 |
|
|
+ *
|
226 |
|
|
+ * - statement type
|
227 |
|
|
+ * - operand type
|
228 |
|
|
+ * - operand locality
|
229 |
|
|
+ * operand global, local, parameter, or constant.
|
230 |
|
|
+ *
|
231 |
|
|
+ * The combination of these three aspects is balanced only approximately.
|
232 |
|
|
+ *
|
233 |
|
|
+ * 1. Statement Type:
|
234 |
|
|
+ * ----------------- number
|
235 |
|
|
+ *
|
236 |
|
|
+ * V1 = V2 9
|
237 |
|
|
+ * (incl. V1 = F(..)
|
238 |
|
|
+ * V = Constant 12
|
239 |
|
|
+ * Assignment, 7
|
240 |
|
|
+ * with array element
|
241 |
|
|
+ * Assignment, 6
|
242 |
|
|
+ * with record component
|
243 |
|
|
+ * --
|
244 |
|
|
+ * 34 34
|
245 |
|
|
+ *
|
246 |
|
|
+ * X = Y +|-|"&&"|"|" Z 5
|
247 |
|
|
+ * X = Y +|-|"==" Constant 6
|
248 |
|
|
+ * X = X +|- 1 3
|
249 |
|
|
+ * X = Y *|/ Z 2
|
250 |
|
|
+ * X = Expression, 1
|
251 |
|
|
+ * two operators
|
252 |
|
|
+ * X = Expression, 1
|
253 |
|
|
+ * three operators
|
254 |
|
|
+ * --
|
255 |
|
|
+ * 18 18
|
256 |
|
|
+ *
|
257 |
|
|
+ * if .... 14
|
258 |
|
|
+ * with "else" 7
|
259 |
|
|
+ * without "else" 7
|
260 |
|
|
+ * executed 3
|
261 |
|
|
+ * not executed 4
|
262 |
|
|
+ * for ... 7 | counted every time
|
263 |
|
|
+ * while ... 4 | the loop condition
|
264 |
|
|
+ * do ... while 1 | is evaluated
|
265 |
|
|
+ * switch ... 1
|
266 |
|
|
+ * break 1
|
267 |
|
|
+ * declaration with 1
|
268 |
|
|
+ * initialization
|
269 |
|
|
+ * --
|
270 |
|
|
+ * 34 34
|
271 |
|
|
+ *
|
272 |
|
|
+ * P (...) procedure call 11
|
273 |
|
|
+ * user procedure 10
|
274 |
|
|
+ * library procedure 1
|
275 |
|
|
+ * X = F (...)
|
276 |
|
|
+ * function call 6
|
277 |
|
|
+ * user function 5
|
278 |
|
|
+ * library function 1
|
279 |
|
|
+ * --
|
280 |
|
|
+ * 17 17
|
281 |
|
|
+ * ---
|
282 |
|
|
+ * 103
|
283 |
|
|
+ *
|
284 |
|
|
+ * The average number of parameters in procedure or function calls
|
285 |
|
|
+ * is 1.82 (not counting the function values aX *
|
286 |
|
|
+ *
|
287 |
|
|
+ * 2. Operators
|
288 |
|
|
+ * ------------
|
289 |
|
|
+ * number approximate
|
290 |
|
|
+ * percentage
|
291 |
|
|
+ *
|
292 |
|
|
+ * Arithmetic 32 50.8
|
293 |
|
|
+ *
|
294 |
|
|
+ * + 21 33.3
|
295 |
|
|
+ * - 7 11.1
|
296 |
|
|
+ * * 3 4.8
|
297 |
|
|
+ * / (int div) 1 1.6
|
298 |
|
|
+ *
|
299 |
|
|
+ * Comparison 27 42.8
|
300 |
|
|
+ *
|
301 |
|
|
+ * == 9 14.3
|
302 |
|
|
+ * /= 4 6.3
|
303 |
|
|
+ * > 1 1.6
|
304 |
|
|
+ * < 3 4.8
|
305 |
|
|
+ * >= 1 1.6
|
306 |
|
|
+ * <= 9 14.3
|
307 |
|
|
+ *
|
308 |
|
|
+ * Logic 4 6.3
|
309 |
|
|
+ *
|
310 |
|
|
+ * && (AND-THEN) 1 1.6
|
311 |
|
|
+ * | (OR) 1 1.6
|
312 |
|
|
+ * ! (NOT) 2 3.2
|
313 |
|
|
+ *
|
314 |
|
|
+ * -- -----
|
315 |
|
|
+ * 63 100.1
|
316 |
|
|
+ *
|
317 |
|
|
+ *
|
318 |
|
|
+ * 3. Operand Type (counted once per operand reference):
|
319 |
|
|
+ * ---------------
|
320 |
|
|
+ * number approximate
|
321 |
|
|
+ * percentage
|
322 |
|
|
+ *
|
323 |
|
|
+ * Integer 175 72.3 %
|
324 |
|
|
+ * Character 45 18.6 %
|
325 |
|
|
+ * Pointer 12 5.0 %
|
326 |
|
|
+ * String30 6 2.5 %
|
327 |
|
|
+ * Array 2 0.8 %
|
328 |
|
|
+ * Record 2 0.8 %
|
329 |
|
|
+ * --- -------
|
330 |
|
|
+ * 242 100.0 %
|
331 |
|
|
+ *
|
332 |
|
|
+ * When there is an access path leading to the final operand (e.g. a record
|
333 |
|
|
+ * component), only the final data type on the access path is counted.
|
334 |
|
|
+ *
|
335 |
|
|
+ *
|
336 |
|
|
+ * 4. Operand Locality:
|
337 |
|
|
+ * -------------------
|
338 |
|
|
+ * number approximate
|
339 |
|
|
+ * percentage
|
340 |
|
|
+ *
|
341 |
|
|
+ * local variable 114 47.1 %
|
342 |
|
|
+ * global variable 22 9.1 %
|
343 |
|
|
+ * parameter 45 18.6 %
|
344 |
|
|
+ * value 23 9.5 %
|
345 |
|
|
+ * reference 22 9.1 %
|
346 |
|
|
+ * function result 6 2.5 %
|
347 |
|
|
+ * constant 55 22.7 %
|
348 |
|
|
+ * --- -------
|
349 |
|
|
+ * 242 100.0 %
|
350 |
|
|
+ *
|
351 |
|
|
+ *
|
352 |
|
|
+ * The program does not compute anything meaningful, but it is syntactically
|
353 |
|
|
+ * and semantically correct. All variables have a value assigned to them
|
354 |
|
|
+ * before they are used as a source operand.
|
355 |
|
|
+ *
|
356 |
|
|
+ * There has been no explicit effort to account for the effects of a
|
357 |
|
|
+ * cache, or to balance the use of long or short displacements for code or
|
358 |
|
|
+ * data.
|
359 |
|
|
+ *
|
360 |
|
|
+ ***************************************************************************
|
361 |
|
|
+ */
|
362 |
|
|
+
|
363 |
|
|
+/* Compiler and system dependent definitions: */
|
364 |
|
|
+
|
365 |
|
|
+#ifndef TIME
|
366 |
|
|
+#undef TIMES
|
367 |
|
|
+#define TIMES
|
368 |
|
|
+#endif
|
369 |
|
|
+ /* Use times(2) time function unless */
|
370 |
|
|
+ /* explicitly defined otherwise */
|
371 |
|
|
+
|
372 |
|
|
+#ifdef MSC_CLOCK
|
373 |
|
|
+#undef HZ
|
374 |
|
|
+#undef TIMES
|
375 |
|
|
+#include <time.h>
|
376 |
|
|
+#define HZ CLK_TCK
|
377 |
|
|
+#endif
|
378 |
|
|
+ /* Use Microsoft C hi-res clock */
|
379 |
|
|
+
|
380 |
|
|
+#ifdef TIMES
|
381 |
|
|
+#include <sys/types.h>
|
382 |
|
|
+#if!defined(CONFIG_RISCV64)
|
383 |
|
|
+#include <sys/times.h>
|
384 |
|
|
+#endif
|
385 |
|
|
+#endif
|
386 |
|
|
+
|
387 |
|
|
+#define Mic_secs_Per_Second 1000000ll
|
388 |
|
|
+ /* Berkeley UNIX C returns process times in seconds/HZ */
|
389 |
|
|
+
|
390 |
|
|
+#ifdef NOSTRUCTASSIGN
|
391 |
|
|
+#define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
|
392 |
|
|
+#else
|
393 |
|
|
+#define structassign(d, s) d = s
|
394 |
|
|
+#endif
|
395 |
|
|
+
|
396 |
|
|
+#ifdef NOENUM
|
397 |
|
|
+#define Ident_1 0
|
398 |
|
|
+#define Ident_2 1
|
399 |
|
|
+#define Ident_3 2
|
400 |
|
|
+#define Ident_4 3
|
401 |
|
|
+#define Ident_5 4
|
402 |
|
|
+ typedef int Enumeration;
|
403 |
|
|
+#else
|
404 |
|
|
+ typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
|
405 |
|
|
+ Enumeration;
|
406 |
|
|
+#endif
|
407 |
|
|
+ /* for boolean and enumeration types in Ada, Pascal */
|
408 |
|
|
+
|
409 |
|
|
+/* General definitions: */
|
410 |
|
|
+
|
411 |
|
|
+#include <stdio.h>
|
412 |
|
|
+ /* for strcpy, strcmp */
|
413 |
|
|
+
|
414 |
|
|
+#define Null 0
|
415 |
|
|
+ /* Value of a Null pointer */
|
416 |
|
|
+#define true 1
|
417 |
|
|
+#define false 0
|
418 |
|
|
+
|
419 |
|
|
+typedef int One_Thirty;
|
420 |
|
|
+typedef int One_Fifty;
|
421 |
|
|
+typedef char Capital_Letter;
|
422 |
|
|
+typedef int Boolean;
|
423 |
|
|
+typedef char Str_30 [31];
|
424 |
|
|
+typedef int Arr_1_Dim [50];
|
425 |
|
|
+typedef int Arr_2_Dim [50] [50];
|
426 |
|
|
+
|
427 |
|
|
+typedef struct record
|
428 |
|
|
+ {
|
429 |
|
|
+ struct record *Ptr_Comp;
|
430 |
|
|
+ Enumeration Discr;
|
431 |
|
|
+ union {
|
432 |
|
|
+ struct {
|
433 |
|
|
+ Enumeration Enum_Comp;
|
434 |
|
|
+ int Int_Comp;
|
435 |
|
|
+ char Str_Comp [31];
|
436 |
|
|
+ } var_1;
|
437 |
|
|
+ struct {
|
438 |
|
|
+ Enumeration E_Comp_2;
|
439 |
|
|
+ char Str_2_Comp [31];
|
440 |
|
|
+ } var_2;
|
441 |
|
|
+ struct {
|
442 |
|
|
+ char Ch_1_Comp;
|
443 |
|
|
+ char Ch_2_Comp;
|
444 |
|
|
+ } var_3;
|
445 |
|
|
+ } variant;
|
446 |
|
|
+ } Rec_Type, *Rec_Pointer;
|
447 |
|
|
+
|
448 |
|
|
+
|
449 |
|
|
diff --git a/arch/riscv64/soc/riscv_gnss/dhry/dhry_1.c b/arch/riscv64/soc/riscv_gnss/dhry/dhry_1.c
|
450 |
|
|
new file mode 100644
|
451 |
|
|
index 0000000..f210e16
|
452 |
|
|
--- /dev/null
|
453 |
|
|
+++ b/arch/riscv64/soc/riscv_gnss/dhry/dhry_1.c
|
454 |
|
|
@@ -0,0 +1,459 @@
|
455 |
|
|
+/*
|
456 |
|
|
+ ****************************************************************************
|
457 |
|
|
+ *
|
458 |
|
|
+ * "DHRYSTONE" Benchmark Program
|
459 |
|
|
+ * -----------------------------
|
460 |
|
|
+ *
|
461 |
|
|
+ * Version: C, Version 2.1
|
462 |
|
|
+ *
|
463 |
|
|
+ * File: dhry_1.c (part 2 of 3)
|
464 |
|
|
+ *
|
465 |
|
|
+ * Date: May 25, 1988
|
466 |
|
|
+ *
|
467 |
|
|
+ * Author: Reinhold P. Weicker
|
468 |
|
|
+ *
|
469 |
|
|
+ ****************************************************************************
|
470 |
|
|
+ */
|
471 |
|
|
+
|
472 |
|
|
+#include "dhry.h"
|
473 |
|
|
+#ifdef CONFIG_RISCV64
|
474 |
|
|
+#include <kernel.h>
|
475 |
|
|
+#include <string.h>
|
476 |
|
|
+char _Next_Glob [sizeof (Rec_Type)];
|
477 |
|
|
+char _Glob[sizeof (Rec_Type)];
|
478 |
|
|
+
|
479 |
|
|
+#pragma GCC diagnostic push
|
480 |
|
|
+#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
|
481 |
|
|
+#pragma GCC diagnostic ignored "-Wimplicit-int"
|
482 |
|
|
+#pragma GCC diagnostic ignored "-Wreturn-type"
|
483 |
|
|
+#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
|
484 |
|
|
+#endif
|
485 |
|
|
+
|
486 |
|
|
+/* Global Variables: */
|
487 |
|
|
+
|
488 |
|
|
+Rec_Pointer Ptr_Glob,
|
489 |
|
|
+ Next_Ptr_Glob;
|
490 |
|
|
+int Int_Glob;
|
491 |
|
|
+Boolean Bool_Glob;
|
492 |
|
|
+char Ch_1_Glob,
|
493 |
|
|
+ Ch_2_Glob;
|
494 |
|
|
+int Arr_1_Glob [50];
|
495 |
|
|
+int Arr_2_Glob [50] [50];
|
496 |
|
|
+
|
497 |
|
|
+//extern char *malloc ();
|
498 |
|
|
+Enumeration Func_1 ();
|
499 |
|
|
+ /* forward declaration necessary since Enumeration may not simply be int */
|
500 |
|
|
+
|
501 |
|
|
+#ifndef REG
|
502 |
|
|
+ Boolean Reg = false;
|
503 |
|
|
+#define REG
|
504 |
|
|
+ /* REG becomes defined as empty */
|
505 |
|
|
+ /* i.e. no register variables */
|
506 |
|
|
+#else
|
507 |
|
|
+ Boolean Reg = true;
|
508 |
|
|
+#endif
|
509 |
|
|
+
|
510 |
|
|
+/* variables for time measurement: */
|
511 |
|
|
+
|
512 |
|
|
+#ifdef TIMES
|
513 |
|
|
+#ifdef CONFIG_RISCV64
|
514 |
|
|
+#define HZ 60000000 // 60 MHz
|
515 |
|
|
+int clock() {
|
516 |
|
|
+ return (int)k_cycle_get_64();
|
517 |
|
|
+}
|
518 |
|
|
+#define Too_Small_Time (2)
|
519 |
|
|
+
|
520 |
|
|
+#else
|
521 |
|
|
+struct tms time_info;
|
522 |
|
|
+extern clock_t times_ (struct tms *t);
|
523 |
|
|
+/* see library function "times" */
|
524 |
|
|
+#define Too_Small_Time (2*HZ)
|
525 |
|
|
+#endif
|
526 |
|
|
+ /* Measurements should last at least about 2 seconds */
|
527 |
|
|
+#endif
|
528 |
|
|
+#ifdef TIME
|
529 |
|
|
+extern long time();
|
530 |
|
|
+ /* see library function "time" */
|
531 |
|
|
+#define Too_Small_Time 2
|
532 |
|
|
+ /* Measurements should last at least 2 seconds */
|
533 |
|
|
+#endif
|
534 |
|
|
+#ifdef MSC_CLOCK
|
535 |
|
|
+extern clock_t clock();
|
536 |
|
|
+#define Too_Small_Time (2*HZ)
|
537 |
|
|
+#endif
|
538 |
|
|
+
|
539 |
|
|
+long Begin_Time,
|
540 |
|
|
+ End_Time,
|
541 |
|
|
+ User_Time;
|
542 |
|
|
+#ifdef CONFIG_RISCV64
|
543 |
|
|
+uint64_t Microseconds,
|
544 |
|
|
+ Dhrystones_Per_Second;
|
545 |
|
|
+#else
|
546 |
|
|
+float Microseconds,
|
547 |
|
|
+ Dhrystones_Per_Second;
|
548 |
|
|
+#endif
|
549 |
|
|
+
|
550 |
|
|
+/* end of variables for time measurement */
|
551 |
|
|
+
|
552 |
|
|
+#ifdef CONFIG_RISCV64
|
553 |
|
|
+int shell_cmd_soc_dhry(int argc, char *argv[])
|
554 |
|
|
+#else
|
555 |
|
|
+main ()
|
556 |
|
|
+#endif
|
557 |
|
|
+/*****/
|
558 |
|
|
+
|
559 |
|
|
+ /* main program, corresponds to procedures */
|
560 |
|
|
+ /* Main and Proc_0 in the Ada version */
|
561 |
|
|
+{
|
562 |
|
|
+ One_Fifty Int_1_Loc;
|
563 |
|
|
+ REG One_Fifty Int_2_Loc;
|
564 |
|
|
+ One_Fifty Int_3_Loc;
|
565 |
|
|
+ REG char Ch_Index;
|
566 |
|
|
+ Enumeration Enum_Loc;
|
567 |
|
|
+ Str_30 Str_1_Loc;
|
568 |
|
|
+ Str_30 Str_2_Loc;
|
569 |
|
|
+ REG int Run_Index;
|
570 |
|
|
+ REG int Number_Of_Runs;
|
571 |
|
|
+
|
572 |
|
|
+ /* Initializations */
|
573 |
|
|
+
|
574 |
|
|
+#ifdef CONFIG_RISCV64
|
575 |
|
|
+ Next_Ptr_Glob = (Rec_Pointer) &_Next_Glob;
|
576 |
|
|
+ Ptr_Glob = (Rec_Pointer) &_Glob ;
|
577 |
|
|
+#else
|
578 |
|
|
+ Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
|
579 |
|
|
+ Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
|
580 |
|
|
+#endif
|
581 |
|
|
+
|
582 |
|
|
+ Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
|
583 |
|
|
+ Ptr_Glob->Discr = Ident_1;
|
584 |
|
|
+ Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
|
585 |
|
|
+ Ptr_Glob->variant.var_1.Int_Comp = 40;
|
586 |
|
|
+ strcpy (Ptr_Glob->variant.var_1.Str_Comp,
|
587 |
|
|
+ "DHRYSTONE PROGRAM, SOME STRING");
|
588 |
|
|
+ strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
|
589 |
|
|
+
|
590 |
|
|
+ Arr_2_Glob [8][7] = 10;
|
591 |
|
|
+ /* Was missing in published program. Without this statement, */
|
592 |
|
|
+ /* Arr_2_Glob [8][7] would have an undefined value. */
|
593 |
|
|
+ /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
|
594 |
|
|
+ /* overflow may occur for this array element. */
|
595 |
|
|
+
|
596 |
|
|
+ printf ("\n");
|
597 |
|
|
+ printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
|
598 |
|
|
+ printf ("\n");
|
599 |
|
|
+ if (Reg)
|
600 |
|
|
+ {
|
601 |
|
|
+ printf ("Program compiled with 'register' attribute\n");
|
602 |
|
|
+ printf ("\n");
|
603 |
|
|
+ }
|
604 |
|
|
+ else
|
605 |
|
|
+ {
|
606 |
|
|
+ printf ("Program compiled without 'register' attribute\n");
|
607 |
|
|
+ printf ("\n");
|
608 |
|
|
+ }
|
609 |
|
|
+#ifdef CONFIG_RISCV64
|
610 |
|
|
+ Number_Of_Runs = 16*1024;
|
611 |
|
|
+#else
|
612 |
|
|
+ printf ("Please give the number of runs through the benchmark: ");
|
613 |
|
|
+ {
|
614 |
|
|
+ int n;
|
615 |
|
|
+ scanf ("%d", &n);
|
616 |
|
|
+ Number_Of_Runs = n;
|
617 |
|
|
+ }
|
618 |
|
|
+ printf ("\n");
|
619 |
|
|
+#endif
|
620 |
|
|
+
|
621 |
|
|
+ printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
|
622 |
|
|
+
|
623 |
|
|
+ /***************/
|
624 |
|
|
+ /* Start timer */
|
625 |
|
|
+ /***************/
|
626 |
|
|
+
|
627 |
|
|
+#ifdef TIMES
|
628 |
|
|
+#ifdef CONFIG_RISCV64
|
629 |
|
|
+ Begin_Time = (long) clock();
|
630 |
|
|
+#else
|
631 |
|
|
+ times (&time_info);
|
632 |
|
|
+ Begin_Time = (long) time_info.tms_utime;
|
633 |
|
|
+#endif
|
634 |
|
|
+#endif
|
635 |
|
|
+#ifdef TIME
|
636 |
|
|
+ Begin_Time = time ( (long *) 0);
|
637 |
|
|
+#endif
|
638 |
|
|
+#ifdef MSC_CLOCK
|
639 |
|
|
+ Begin_Time = clock();
|
640 |
|
|
+#endif
|
641 |
|
|
+
|
642 |
|
|
+ for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
|
643 |
|
|
+ {
|
644 |
|
|
+
|
645 |
|
|
+ Proc_5();
|
646 |
|
|
+ Proc_4();
|
647 |
|
|
+ /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
|
648 |
|
|
+ Int_1_Loc = 2;
|
649 |
|
|
+ Int_2_Loc = 3;
|
650 |
|
|
+ strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
|
651 |
|
|
+ Enum_Loc = Ident_2;
|
652 |
|
|
+ Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
|
653 |
|
|
+ /* Bool_Glob == 1 */
|
654 |
|
|
+ while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
|
655 |
|
|
+ {
|
656 |
|
|
+ Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
|
657 |
|
|
+ /* Int_3_Loc == 7 */
|
658 |
|
|
+ Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
|
659 |
|
|
+ /* Int_3_Loc == 7 */
|
660 |
|
|
+ Int_1_Loc += 1;
|
661 |
|
|
+ } /* while */
|
662 |
|
|
+ /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
|
663 |
|
|
+ Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
|
664 |
|
|
+ /* Int_Glob == 5 */
|
665 |
|
|
+ Proc_1 (Ptr_Glob);
|
666 |
|
|
+ for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
|
667 |
|
|
+ /* loop body executed twice */
|
668 |
|
|
+ {
|
669 |
|
|
+ if (Enum_Loc == Func_1 (Ch_Index, 'C'))
|
670 |
|
|
+ /* then, not executed */
|
671 |
|
|
+ {
|
672 |
|
|
+ Proc_6 (Ident_1, &Enum_Loc);
|
673 |
|
|
+ strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
|
674 |
|
|
+ Int_2_Loc = Run_Index;
|
675 |
|
|
+ Int_Glob = Run_Index;
|
676 |
|
|
+ }
|
677 |
|
|
+ }
|
678 |
|
|
+ /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
|
679 |
|
|
+ Int_2_Loc = Int_2_Loc * Int_1_Loc;
|
680 |
|
|
+ Int_1_Loc = Int_2_Loc / Int_3_Loc;
|
681 |
|
|
+ Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
|
682 |
|
|
+ /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
|
683 |
|
|
+ Proc_2 (&Int_1_Loc);
|
684 |
|
|
+ /* Int_1_Loc == 5 */
|
685 |
|
|
+
|
686 |
|
|
+ } /* loop "for Run_Index" */
|
687 |
|
|
+
|
688 |
|
|
+ /**************/
|
689 |
|
|
+ /* Stop timer */
|
690 |
|
|
+ /**************/
|
691 |
|
|
+
|
692 |
|
|
+#ifdef TIMES
|
693 |
|
|
+#ifdef CONFIG_RISCV64
|
694 |
|
|
+ End_Time = (long) clock();
|
695 |
|
|
+#else
|
696 |
|
|
+ times_ (&time_info);
|
697 |
|
|
+ End_Time = (long) time_info.tms_utime;
|
698 |
|
|
+#endif
|
699 |
|
|
+#endif
|
700 |
|
|
+#ifdef TIME
|
701 |
|
|
+ End_Time = time ( (long *) 0);
|
702 |
|
|
+#endif
|
703 |
|
|
+#ifdef MSC_CLOCK
|
704 |
|
|
+ End_Time = clock();
|
705 |
|
|
+#endif
|
706 |
|
|
+
|
707 |
|
|
+ printf ("Execution ends\n");
|
708 |
|
|
+ printf ("\n");
|
709 |
|
|
+ printf ("Final values of the variables used in the benchmark:\n");
|
710 |
|
|
+ printf ("\n");
|
711 |
|
|
+ printf ("Int_Glob: %d\n", Int_Glob);
|
712 |
|
|
+ printf (" should be: %d\n", 5);
|
713 |
|
|
+ printf ("Bool_Glob: %d\n", Bool_Glob);
|
714 |
|
|
+ printf (" should be: %d\n", 1);
|
715 |
|
|
+ printf ("Ch_1_Glob: %c\n", Ch_1_Glob);
|
716 |
|
|
+ printf (" should be: %c\n", 'A');
|
717 |
|
|
+ printf ("Ch_2_Glob: %c\n", Ch_2_Glob);
|
718 |
|
|
+ printf (" should be: %c\n", 'B');
|
719 |
|
|
+ printf ("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
|
720 |
|
|
+ printf (" should be: %d\n", 7);
|
721 |
|
|
+ printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
|
722 |
|
|
+ printf (" should be: Number_Of_Runs + 10\n");
|
723 |
|
|
+ printf ("Ptr_Glob->\n");
|
724 |
|
|
+ printf (" Ptr_Comp: %d\n", (int) Ptr_Glob->Ptr_Comp);
|
725 |
|
|
+ printf (" should be: (implementation-dependent)\n");
|
726 |
|
|
+ printf (" Discr: %d\n", Ptr_Glob->Discr);
|
727 |
|
|
+ printf (" should be: %d\n", 0);
|
728 |
|
|
+ printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
|
729 |
|
|
+ printf (" should be: %d\n", 2);
|
730 |
|
|
+ printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
|
731 |
|
|
+ printf (" should be: %d\n", 17);
|
732 |
|
|
+ printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
|
733 |
|
|
+ printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
|
734 |
|
|
+ printf ("Next_Ptr_Glob->\n");
|
735 |
|
|
+ printf (" Ptr_Comp: %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
|
736 |
|
|
+ printf (" should be: (implementation-dependent), same as above\n");
|
737 |
|
|
+ printf (" Discr: %d\n", Next_Ptr_Glob->Discr);
|
738 |
|
|
+ printf (" should be: %d\n", 0);
|
739 |
|
|
+ printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
|
740 |
|
|
+ printf (" should be: %d\n", 1);
|
741 |
|
|
+ printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
|
742 |
|
|
+ printf (" should be: %d\n", 18);
|
743 |
|
|
+ printf (" Str_Comp: %s\n",
|
744 |
|
|
+ Next_Ptr_Glob->variant.var_1.Str_Comp);
|
745 |
|
|
+ printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
|
746 |
|
|
+ printf ("Int_1_Loc: %d\n", Int_1_Loc);
|
747 |
|
|
+ printf (" should be: %d\n", 5);
|
748 |
|
|
+ printf ("Int_2_Loc: %d\n", Int_2_Loc);
|
749 |
|
|
+ printf (" should be: %d\n", 13);
|
750 |
|
|
+ printf ("Int_3_Loc: %d\n", Int_3_Loc);
|
751 |
|
|
+ printf (" should be: %d\n", 7);
|
752 |
|
|
+ printf ("Enum_Loc: %d\n", Enum_Loc);
|
753 |
|
|
+ printf (" should be: %d\n", 1);
|
754 |
|
|
+ printf ("Str_1_Loc: %s\n", Str_1_Loc);
|
755 |
|
|
+ printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
|
756 |
|
|
+ printf ("Str_2_Loc: %s\n", Str_2_Loc);
|
757 |
|
|
+ printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
|
758 |
|
|
+ printf ("\n");
|
759 |
|
|
+
|
760 |
|
|
+ User_Time = End_Time - Begin_Time;
|
761 |
|
|
+
|
762 |
|
|
+ if (User_Time < Too_Small_Time)
|
763 |
|
|
+ {
|
764 |
|
|
+ printf ("Measured time too small to obtain meaningful results\n");
|
765 |
|
|
+ printf ("Please increase number of runs\n");
|
766 |
|
|
+ printf ("\n");
|
767 |
|
|
+ }
|
768 |
|
|
+ else
|
769 |
|
|
+ {
|
770 |
|
|
+
|
771 |
|
|
+#ifdef TIME
|
772 |
|
|
+ Microseconds = (float) User_Time * Mic_secs_Per_Second
|
773 |
|
|
+ / (float) Number_Of_Runs;
|
774 |
|
|
+ Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time;
|
775 |
|
|
+#elif defined(CONFIG_RISCV64)
|
776 |
|
|
+#else
|
777 |
|
|
+ Microseconds = (float) User_Time * Mic_secs_Per_Second
|
778 |
|
|
+ / ((float) HZ * ((float) Number_Of_Runs));
|
779 |
|
|
+ Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
|
780 |
|
|
+ / (float) User_Time;
|
781 |
|
|
+#endif
|
782 |
|
|
+ printf ("Microseconds for one run through Dhrystone: ");
|
783 |
|
|
+#ifdef CONFIG_RISCV64
|
784 |
|
|
+ int64_t div1 = (int64_t)HZ*(int64_t)Number_Of_Runs;
|
785 |
|
|
+ Microseconds = 10ll * (int64_t)User_Time * Mic_secs_Per_Second;
|
786 |
|
|
+ printf ("%6d.%01d \n", (int)(Microseconds/(10*div1)), (int)(Microseconds%10));
|
787 |
|
|
+#else
|
788 |
|
|
+ printf ("%6.1f \n", Microseconds);
|
789 |
|
|
+#endif
|
790 |
|
|
+ printf ("Dhrystones per Second: ");
|
791 |
|
|
+#ifdef CONFIG_RISCV64
|
792 |
|
|
+ Dhrystones_Per_Second = 10ll * ((int64_t)HZ * (int64_t) Number_Of_Runs);
|
793 |
|
|
+ div1 = (int64_t)User_Time;
|
794 |
|
|
+ printf ("%6d.%01d \n", (int)(Dhrystones_Per_Second/(10*div1)), (int)(Dhrystones_Per_Second%10));
|
795 |
|
|
+#else
|
796 |
|
|
+ printf ("%6.1f \n", Dhrystones_Per_Second);
|
797 |
|
|
+#endif
|
798 |
|
|
+ printf ("\n");
|
799 |
|
|
+
|
800 |
|
|
+ }
|
801 |
|
|
+
|
802 |
|
|
+ return 0;
|
803 |
|
|
+}
|
804 |
|
|
+
|
805 |
|
|
+
|
806 |
|
|
+Proc_1 (Ptr_Val_Par)
|
807 |
|
|
+/******************/
|
808 |
|
|
+
|
809 |
|
|
+REG Rec_Pointer Ptr_Val_Par;
|
810 |
|
|
+ /* executed once */
|
811 |
|
|
+{
|
812 |
|
|
+ REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
|
813 |
|
|
+ /* == Ptr_Glob_Next */
|
814 |
|
|
+ /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
|
815 |
|
|
+ /* corresponds to "rename" in Ada, "with" in Pascal */
|
816 |
|
|
+
|
817 |
|
|
+ structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
|
818 |
|
|
+ Ptr_Val_Par->variant.var_1.Int_Comp = 5;
|
819 |
|
|
+ Next_Record->variant.var_1.Int_Comp
|
820 |
|
|
+ = Ptr_Val_Par->variant.var_1.Int_Comp;
|
821 |
|
|
+ Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
|
822 |
|
|
+ Proc_3 (&Next_Record->Ptr_Comp);
|
823 |
|
|
+ /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
|
824 |
|
|
+ == Ptr_Glob->Ptr_Comp */
|
825 |
|
|
+ if (Next_Record->Discr == Ident_1)
|
826 |
|
|
+ /* then, executed */
|
827 |
|
|
+ {
|
828 |
|
|
+ Next_Record->variant.var_1.Int_Comp = 6;
|
829 |
|
|
+ Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
|
830 |
|
|
+ &Next_Record->variant.var_1.Enum_Comp);
|
831 |
|
|
+ Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
|
832 |
|
|
+ Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
|
833 |
|
|
+ &Next_Record->variant.var_1.Int_Comp);
|
834 |
|
|
+ }
|
835 |
|
|
+ else /* not executed */
|
836 |
|
|
+ structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
|
837 |
|
|
+} /* Proc_1 */
|
838 |
|
|
+
|
839 |
|
|
+
|
840 |
|
|
+Proc_2 (Int_Par_Ref)
|
841 |
|
|
+/******************/
|
842 |
|
|
+ /* executed once */
|
843 |
|
|
+ /* *Int_Par_Ref == 1, becomes 4 */
|
844 |
|
|
+
|
845 |
|
|
+One_Fifty *Int_Par_Ref;
|
846 |
|
|
+{
|
847 |
|
|
+ One_Fifty Int_Loc;
|
848 |
|
|
+ Enumeration Enum_Loc;
|
849 |
|
|
+
|
850 |
|
|
+ Int_Loc = *Int_Par_Ref + 10;
|
851 |
|
|
+ do /* executed once */
|
852 |
|
|
+ if (Ch_1_Glob == 'A')
|
853 |
|
|
+ /* then, executed */
|
854 |
|
|
+ {
|
855 |
|
|
+ Int_Loc -= 1;
|
856 |
|
|
+ *Int_Par_Ref = Int_Loc - Int_Glob;
|
857 |
|
|
+ Enum_Loc = Ident_1;
|
858 |
|
|
+ } /* if */
|
859 |
|
|
+ while (Enum_Loc != Ident_1); /* true */
|
860 |
|
|
+} /* Proc_2 */
|
861 |
|
|
+
|
862 |
|
|
+
|
863 |
|
|
+Proc_3 (Ptr_Ref_Par)
|
864 |
|
|
+/******************/
|
865 |
|
|
+ /* executed once */
|
866 |
|
|
+ /* Ptr_Ref_Par becomes Ptr_Glob */
|
867 |
|
|
+
|
868 |
|
|
+Rec_Pointer *Ptr_Ref_Par;
|
869 |
|
|
+
|
870 |
|
|
+{
|
871 |
|
|
+ if (Ptr_Glob != Null)
|
872 |
|
|
+ /* then, executed */
|
873 |
|
|
+ *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
|
874 |
|
|
+ Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
|
875 |
|
|
+} /* Proc_3 */
|
876 |
|
|
+
|
877 |
|
|
+
|
878 |
|
|
+Proc_4 () /* without parameters */
|
879 |
|
|
+/*******/
|
880 |
|
|
+ /* executed once */
|
881 |
|
|
+{
|
882 |
|
|
+ Boolean Bool_Loc;
|
883 |
|
|
+
|
884 |
|
|
+ Bool_Loc = Ch_1_Glob == 'A';
|
885 |
|
|
+ Bool_Glob = Bool_Loc | Bool_Glob;
|
886 |
|
|
+ Ch_2_Glob = 'B';
|
887 |
|
|
+} /* Proc_4 */
|
888 |
|
|
+
|
889 |
|
|
+
|
890 |
|
|
+Proc_5 () /* without parameters */
|
891 |
|
|
+/*******/
|
892 |
|
|
+ /* executed once */
|
893 |
|
|
+{
|
894 |
|
|
+ Ch_1_Glob = 'A';
|
895 |
|
|
+ Bool_Glob = false;
|
896 |
|
|
+} /* Proc_5 */
|
897 |
|
|
+
|
898 |
|
|
+
|
899 |
|
|
+ /* Procedure for the assignment of structures, */
|
900 |
|
|
+ /* if the C compiler doesn't support this feature */
|
901 |
|
|
+#ifdef NOSTRUCTASSIGN
|
902 |
|
|
+memcpy (d, s, l)
|
903 |
|
|
+register char *d;
|
904 |
|
|
+register char *s;
|
905 |
|
|
+register int l;
|
906 |
|
|
+{
|
907 |
|
|
+ while (l--) *d++ = *s++;
|
908 |
|
|
+}
|
909 |
|
|
+#endif
|
910 |
|
|
+
|
911 |
|
|
+#ifdef CONFIG_RISCV64
|
912 |
|
|
+#pragma GCC diagnostic pop
|
913 |
|
|
+#endif
|
914 |
|
|
diff --git a/arch/riscv64/soc/riscv_gnss/dhry/dhry_2.c b/arch/riscv64/soc/riscv_gnss/dhry/dhry_2.c
|
915 |
|
|
new file mode 100644
|
916 |
|
|
index 0000000..8ab9fd0
|
917 |
|
|
--- /dev/null
|
918 |
|
|
+++ b/arch/riscv64/soc/riscv_gnss/dhry/dhry_2.c
|
919 |
|
|
@@ -0,0 +1,202 @@
|
920 |
|
|
+/*
|
921 |
|
|
+ ****************************************************************************
|
922 |
|
|
+ *
|
923 |
|
|
+ * "DHRYSTONE" Benchmark Program
|
924 |
|
|
+ * -----------------------------
|
925 |
|
|
+ *
|
926 |
|
|
+ * Version: C, Version 2.1
|
927 |
|
|
+ *
|
928 |
|
|
+ * File: dhry_2.c (part 3 of 3)
|
929 |
|
|
+ *
|
930 |
|
|
+ * Date: May 25, 1988
|
931 |
|
|
+ *
|
932 |
|
|
+ * Author: Reinhold P. Weicker
|
933 |
|
|
+ *
|
934 |
|
|
+ ****************************************************************************
|
935 |
|
|
+ */
|
936 |
|
|
+
|
937 |
|
|
+#include "dhry.h"
|
938 |
|
|
+
|
939 |
|
|
+#ifndef REG
|
940 |
|
|
+#define REG
|
941 |
|
|
+ /* REG becomes defined as empty */
|
942 |
|
|
+ /* i.e. no register variables */
|
943 |
|
|
+#endif
|
944 |
|
|
+
|
945 |
|
|
+#ifdef CONFIG_RISCV64
|
946 |
|
|
+#pragma GCC diagnostic push
|
947 |
|
|
+#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
|
948 |
|
|
+#pragma GCC diagnostic ignored "-Wimplicit-int"
|
949 |
|
|
+#pragma GCC diagnostic ignored "-Wreturn-type"
|
950 |
|
|
+#endif
|
951 |
|
|
+
|
952 |
|
|
+extern int Int_Glob;
|
953 |
|
|
+extern char Ch_1_Glob;
|
954 |
|
|
+
|
955 |
|
|
+
|
956 |
|
|
+Proc_6 (Enum_Val_Par, Enum_Ref_Par)
|
957 |
|
|
+/*********************************/
|
958 |
|
|
+ /* executed once */
|
959 |
|
|
+ /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
|
960 |
|
|
+
|
961 |
|
|
+Enumeration Enum_Val_Par;
|
962 |
|
|
+Enumeration *Enum_Ref_Par;
|
963 |
|
|
+{
|
964 |
|
|
+ *Enum_Ref_Par = Enum_Val_Par;
|
965 |
|
|
+ if (! Func_3 (Enum_Val_Par))
|
966 |
|
|
+ /* then, not executed */
|
967 |
|
|
+ *Enum_Ref_Par = Ident_4;
|
968 |
|
|
+ switch (Enum_Val_Par)
|
969 |
|
|
+ {
|
970 |
|
|
+ case Ident_1:
|
971 |
|
|
+ *Enum_Ref_Par = Ident_1;
|
972 |
|
|
+ break;
|
973 |
|
|
+ case Ident_2:
|
974 |
|
|
+ if (Int_Glob > 100)
|
975 |
|
|
+ /* then */
|
976 |
|
|
+ *Enum_Ref_Par = Ident_1;
|
977 |
|
|
+ else *Enum_Ref_Par = Ident_4;
|
978 |
|
|
+ break;
|
979 |
|
|
+ case Ident_3: /* executed */
|
980 |
|
|
+ *Enum_Ref_Par = Ident_2;
|
981 |
|
|
+ break;
|
982 |
|
|
+ case Ident_4: break;
|
983 |
|
|
+ case Ident_5:
|
984 |
|
|
+ *Enum_Ref_Par = Ident_3;
|
985 |
|
|
+ break;
|
986 |
|
|
+ } /* switch */
|
987 |
|
|
+} /* Proc_6 */
|
988 |
|
|
+
|
989 |
|
|
+
|
990 |
|
|
+Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
|
991 |
|
|
+/**********************************************/
|
992 |
|
|
+ /* executed three times */
|
993 |
|
|
+ /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
|
994 |
|
|
+ /* Int_Par_Ref becomes 7 */
|
995 |
|
|
+ /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
|
996 |
|
|
+ /* Int_Par_Ref becomes 17 */
|
997 |
|
|
+ /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
|
998 |
|
|
+ /* Int_Par_Ref becomes 18 */
|
999 |
|
|
+One_Fifty Int_1_Par_Val;
|
1000 |
|
|
+One_Fifty Int_2_Par_Val;
|
1001 |
|
|
+One_Fifty *Int_Par_Ref;
|
1002 |
|
|
+{
|
1003 |
|
|
+ One_Fifty Int_Loc;
|
1004 |
|
|
+
|
1005 |
|
|
+ Int_Loc = Int_1_Par_Val + 2;
|
1006 |
|
|
+ *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
|
1007 |
|
|
+} /* Proc_7 */
|
1008 |
|
|
+
|
1009 |
|
|
+
|
1010 |
|
|
+Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
|
1011 |
|
|
+/*********************************************************************/
|
1012 |
|
|
+ /* executed once */
|
1013 |
|
|
+ /* Int_Par_Val_1 == 3 */
|
1014 |
|
|
+ /* Int_Par_Val_2 == 7 */
|
1015 |
|
|
+Arr_1_Dim Arr_1_Par_Ref;
|
1016 |
|
|
+Arr_2_Dim Arr_2_Par_Ref;
|
1017 |
|
|
+int Int_1_Par_Val;
|
1018 |
|
|
+int Int_2_Par_Val;
|
1019 |
|
|
+{
|
1020 |
|
|
+ REG One_Fifty Int_Index;
|
1021 |
|
|
+ REG One_Fifty Int_Loc;
|
1022 |
|
|
+
|
1023 |
|
|
+ Int_Loc = Int_1_Par_Val + 5;
|
1024 |
|
|
+ Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
|
1025 |
|
|
+ Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
|
1026 |
|
|
+ Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
|
1027 |
|
|
+ for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
|
1028 |
|
|
+ Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
|
1029 |
|
|
+ Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
|
1030 |
|
|
+ Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
|
1031 |
|
|
+ Int_Glob = 5;
|
1032 |
|
|
+} /* Proc_8 */
|
1033 |
|
|
+
|
1034 |
|
|
+
|
1035 |
|
|
+Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val)
|
1036 |
|
|
+/*************************************************/
|
1037 |
|
|
+ /* executed three times */
|
1038 |
|
|
+ /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
|
1039 |
|
|
+ /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
|
1040 |
|
|
+ /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
|
1041 |
|
|
+
|
1042 |
|
|
+Capital_Letter Ch_1_Par_Val;
|
1043 |
|
|
+Capital_Letter Ch_2_Par_Val;
|
1044 |
|
|
+{
|
1045 |
|
|
+ Capital_Letter Ch_1_Loc;
|
1046 |
|
|
+ Capital_Letter Ch_2_Loc;
|
1047 |
|
|
+
|
1048 |
|
|
+ Ch_1_Loc = Ch_1_Par_Val;
|
1049 |
|
|
+ Ch_2_Loc = Ch_1_Loc;
|
1050 |
|
|
+ if (Ch_2_Loc != Ch_2_Par_Val)
|
1051 |
|
|
+ /* then, executed */
|
1052 |
|
|
+ return (Ident_1);
|
1053 |
|
|
+ else /* not executed */
|
1054 |
|
|
+ {
|
1055 |
|
|
+ Ch_1_Glob = Ch_1_Loc;
|
1056 |
|
|
+ return (Ident_2);
|
1057 |
|
|
+ }
|
1058 |
|
|
+} /* Func_1 */
|
1059 |
|
|
+
|
1060 |
|
|
+
|
1061 |
|
|
+Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
|
1062 |
|
|
+/*************************************************/
|
1063 |
|
|
+ /* executed once */
|
1064 |
|
|
+ /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
|
1065 |
|
|
+ /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
|
1066 |
|
|
+
|
1067 |
|
|
+Str_30 Str_1_Par_Ref;
|
1068 |
|
|
+Str_30 Str_2_Par_Ref;
|
1069 |
|
|
+{
|
1070 |
|
|
+ REG One_Thirty Int_Loc;
|
1071 |
|
|
+ Capital_Letter Ch_Loc;
|
1072 |
|
|
+
|
1073 |
|
|
+ Int_Loc = 2;
|
1074 |
|
|
+ while (Int_Loc <= 2) /* loop body executed once */
|
1075 |
|
|
+ if (Func_1 (Str_1_Par_Ref[Int_Loc],
|
1076 |
|
|
+ Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
|
1077 |
|
|
+ /* then, executed */
|
1078 |
|
|
+ {
|
1079 |
|
|
+ Ch_Loc = 'A';
|
1080 |
|
|
+ Int_Loc += 1;
|
1081 |
|
|
+ } /* if, while */
|
1082 |
|
|
+ if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
|
1083 |
|
|
+ /* then, not executed */
|
1084 |
|
|
+ Int_Loc = 7;
|
1085 |
|
|
+ if (Ch_Loc == 'R')
|
1086 |
|
|
+ /* then, not executed */
|
1087 |
|
|
+ return (true);
|
1088 |
|
|
+ else /* executed */
|
1089 |
|
|
+ {
|
1090 |
|
|
+ if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
|
1091 |
|
|
+ /* then, not executed */
|
1092 |
|
|
+ {
|
1093 |
|
|
+ Int_Loc += 7;
|
1094 |
|
|
+ Int_Glob = Int_Loc;
|
1095 |
|
|
+ return (true);
|
1096 |
|
|
+ }
|
1097 |
|
|
+ else /* executed */
|
1098 |
|
|
+ return (false);
|
1099 |
|
|
+ } /* if Ch_Loc */
|
1100 |
|
|
+} /* Func_2 */
|
1101 |
|
|
+
|
1102 |
|
|
+
|
1103 |
|
|
+Boolean Func_3 (Enum_Par_Val)
|
1104 |
|
|
+/***************************/
|
1105 |
|
|
+ /* executed once */
|
1106 |
|
|
+ /* Enum_Par_Val == Ident_3 */
|
1107 |
|
|
+Enumeration Enum_Par_Val;
|
1108 |
|
|
+{
|
1109 |
|
|
+ Enumeration Enum_Loc;
|
1110 |
|
|
+
|
1111 |
|
|
+ Enum_Loc = Enum_Par_Val;
|
1112 |
|
|
+ if (Enum_Loc == Ident_3)
|
1113 |
|
|
+ /* then, executed */
|
1114 |
|
|
+ return (true);
|
1115 |
|
|
+ else /* not executed */
|
1116 |
|
|
+ return (false);
|
1117 |
|
|
+} /* Func_3 */
|
1118 |
|
|
+
|
1119 |
|
|
+#ifdef CONFIG_RISCV64
|
1120 |
|
|
+#pragma GCC diagnostic pop
|
1121 |
|
|
+#endif
|
1122 |
|
|
diff --git a/arch/riscv64/soc/riscv_gnss/soc.c b/arch/riscv64/soc/riscv_gnss/soc.c
|
1123 |
|
|
index 72639bd..bce73c1 100644
|
1124 |
|
|
--- a/arch/riscv64/soc/riscv_gnss/soc.c
|
1125 |
|
|
+++ b/arch/riscv64/soc/riscv_gnss/soc.c
|
1126 |
|
|
@@ -216,6 +216,11 @@ static int shell_cmd_soc_pnp(int argc, char *argv[])
|
1127 |
|
|
}
|
1128 |
|
|
|
1129 |
|
|
/**
|
1130 |
|
|
+ * @brief Run Dhrystone 2.1 benchmark
|
1131 |
|
|
+ */
|
1132 |
|
|
+extern int shell_cmd_soc_dhry(int argc, char *argv[]);
|
1133 |
|
|
+
|
1134 |
|
|
+/**
|
1135 |
|
|
* @brief Check hardware target configuration is it inferred or not.
|
1136 |
|
|
*
|
1137 |
|
|
* inferred hardware target is used for RTL simulation of the whole SOC design.
|
1138 |
|
|
@@ -246,6 +251,7 @@ static int riscv_gnss_soc_init(struct device *arg)
|
1139 |
|
|
struct shell_cmd soc_commands[] = {
|
1140 |
|
|
{ "info", shell_cmd_soc_info, "Show SoC RTL download link" },
|
1141 |
|
|
{ "pnp", shell_cmd_soc_pnp, "Show Plug'n'Play information" },
|
1142 |
|
|
+ { "dhry", shell_cmd_soc_dhry, "Run Dhrystone 2.1. benchmark" },
|
1143 |
|
|
{ NULL, NULL }
|
1144 |
|
|
};
|
1145 |
|
|
|