comparison packages/kernel/current/tests/dhrystone.c @ 16:4f2df4ab82c8 ecos-sw-1999-06-18

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