[rtems commit] benchmarks/dhrystone: Port to RTEMS

Sebastian Huber sebh at rtems.org
Wed Mar 29 06:12:57 UTC 2017


Module:    rtems
Branch:    master
Commit:    954ca410553f4c65c25700e077d6dca608ef471c
Changeset: http://git.rtems.org/rtems/commit/?id=954ca410553f4c65c25700e077d6dca608ef471c

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Mar 28 13:44:45 2017 +0200

benchmarks/dhrystone: Port to RTEMS

Update #2958.

---

 testsuites/benchmarks/dhrystone/Makefile.am   |  3 +-
 testsuites/benchmarks/dhrystone/dhry.h        | 14 +++++-
 testsuites/benchmarks/dhrystone/dhry_1.c      | 53 ++++++++++++----------
 testsuites/benchmarks/dhrystone/dhry_2.c      |  8 ++--
 testsuites/benchmarks/dhrystone/dhrystone.doc |  6 ++-
 testsuites/benchmarks/dhrystone/dhrystone.scn | 63 +++++++++++++++++++++++++++
 testsuites/benchmarks/dhrystone/init.c        | 14 ++++--
 7 files changed, 128 insertions(+), 33 deletions(-)

diff --git a/testsuites/benchmarks/dhrystone/Makefile.am b/testsuites/benchmarks/dhrystone/Makefile.am
index 0354012..73b6721 100644
--- a/testsuites/benchmarks/dhrystone/Makefile.am
+++ b/testsuites/benchmarks/dhrystone/Makefile.am
@@ -1,5 +1,5 @@
 rtems_tests_PROGRAMS = dhrystone
-dhrystone_SOURCES = init.c
+dhrystone_SOURCES = init.c dhry_1.c dhry_2.c
 
 dist_rtems_tests_DATA = dhrystone.scn dhrystone.doc
 
@@ -8,6 +8,7 @@ include $(top_srcdir)/../automake/compile.am
 include $(top_srcdir)/../automake/leaf.am
 
 AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CFLAGS += -fno-inline -fno-builtin
 
 LINK_OBJS = $(dhrystone_OBJECTS)
 LINK_LIBS = $(dhrystone_LDLIBS)
diff --git a/testsuites/benchmarks/dhrystone/dhry.h b/testsuites/benchmarks/dhrystone/dhry.h
index 1714562..4eaceeb 100644
--- a/testsuites/benchmarks/dhrystone/dhry.h
+++ b/testsuites/benchmarks/dhrystone/dhry.h
@@ -345,6 +345,8 @@
  ***************************************************************************
  */
 
+#define TIME
+
 /* Compiler and system dependent definitions: */
 
 #ifndef TIME
@@ -420,4 +422,14 @@ typedef struct record
           } variant;
       } Rec_Type, *Rec_Pointer;
 
-
+void Proc_1 (Rec_Pointer);
+void Proc_2 (One_Fifty *);
+void Proc_3 (Rec_Pointer *);
+void Proc_4 (void);
+void Proc_5 (void);
+void Proc_6 (Enumeration, Enumeration *);
+void Proc_7 (One_Fifty, One_Fifty, One_Fifty *);
+void Proc_8 (Arr_1_Dim, Arr_2_Dim, int, int);
+Enumeration Func_1 (Capital_Letter, Capital_Letter);
+Boolean Func_2 (Str_30, Str_30);
+Boolean Func_3 (Enumeration);
diff --git a/testsuites/benchmarks/dhrystone/dhry_1.c b/testsuites/benchmarks/dhrystone/dhry_1.c
index 7ab02a8..314ef34 100644
--- a/testsuites/benchmarks/dhrystone/dhry_1.c
+++ b/testsuites/benchmarks/dhrystone/dhry_1.c
@@ -17,6 +17,9 @@
 
 #include "dhry.h"
 
+#include <stdlib.h>
+#include <string.h>
+
 /* Global Variables: */
 
 Rec_Pointer     Ptr_Glob,
@@ -28,10 +31,6 @@ char            Ch_1_Glob,
 int             Arr_1_Glob [50];
 int             Arr_2_Glob [50] [50];
 
-extern char     *malloc ();
-Enumeration     Func_1 ();
-  /* forward declaration necessary since Enumeration may not simply be int */
-
 #ifndef REG
         Boolean Reg = false;
 #define REG
@@ -51,22 +50,30 @@ extern  int     times ();
                 /* Measurements should last at least about 2 seconds */
 #endif
 #ifdef TIME
-extern long     time();
+#include <sys/time.h>
                 /* see library function "time"  */
+#define time(x) Time()
+static double Time(void)
+{
+  struct timeval tv;
+
+  gettimeofday(&tv, NULL);
+  return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
+}
 #define Too_Small_Time 2
                 /* Measurements should last at least 2 seconds */
 #endif
 
-long            Begin_Time,
+double          Begin_Time,
                 End_Time,
                 User_Time;
-float           Microseconds,
+double          Microseconds,
                 Dhrystones_Per_Second;
 
 /* end of variables for time measurement */
 
 
-main ()
+int main (int argc, char **argv)
 /*****/
 
   /* main program, corresponds to procedures        */
@@ -114,14 +121,13 @@ main ()
     printf ("Program compiled without 'register' attribute\n");
     printf ("\n");
   }
-  printf ("Please give the number of runs through the benchmark: ");
-  {
-    int n;
-    scanf ("%d", &n);
-    Number_Of_Runs = n;
+
+  Number_Of_Runs = atoi(argv[1]);
+  if (Number_Of_Runs < 1) {
+    return 1;
   }
-  printf ("\n");
 
+execution_start:
   printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
 
   /***************/
@@ -254,13 +260,14 @@ main ()
     printf ("Measured time too small to obtain meaningful results\n");
     printf ("Please increase number of runs\n");
     printf ("\n");
+    Number_Of_Runs *= 2;
+    goto execution_start;
   }
   else
   {
 #ifdef TIME
-    Microseconds = (float) User_Time * Mic_secs_Per_Second 
-                        / (float) Number_Of_Runs;
-    Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time;
+    Microseconds = User_Time * Mic_secs_Per_Second / Number_Of_Runs;
+    Dhrystones_Per_Second = Number_Of_Runs / User_Time;
 #else
     Microseconds = (float) User_Time * Mic_secs_Per_Second 
                         / ((float) HZ * ((float) Number_Of_Runs));
@@ -271,13 +278,15 @@ main ()
     printf ("%6.1f \n", Microseconds);
     printf ("Dhrystones per Second:                      ");
     printf ("%6.1f \n", Dhrystones_Per_Second);
+    printf ("DMIPS:                                      ");
+    printf ("%5.2f \n", Dhrystones_Per_Second / 1757.0);
     printf ("\n");
   }
   
 }
 
 
-Proc_1 (Ptr_Val_Par)
+void Proc_1 (Ptr_Val_Par)
 /******************/
 
 REG Rec_Pointer Ptr_Val_Par;
@@ -311,7 +320,7 @@ REG Rec_Pointer Ptr_Val_Par;
 } /* Proc_1 */
 
 
-Proc_2 (Int_Par_Ref)
+void Proc_2 (Int_Par_Ref)
 /******************/
     /* executed once */
     /* *Int_Par_Ref == 1, becomes 4 */
@@ -334,7 +343,7 @@ One_Fifty   *Int_Par_Ref;
 } /* Proc_2 */
 
 
-Proc_3 (Ptr_Ref_Par)
+void Proc_3 (Ptr_Ref_Par)
 /******************/
     /* executed once */
     /* Ptr_Ref_Par becomes Ptr_Glob */
@@ -349,7 +358,7 @@ Rec_Pointer *Ptr_Ref_Par;
 } /* Proc_3 */
 
 
-Proc_4 () /* without parameters */
+void Proc_4 (void) /* without parameters */
 /*******/
     /* executed once */
 {
@@ -361,7 +370,7 @@ Proc_4 () /* without parameters */
 } /* Proc_4 */
 
 
-Proc_5 () /* without parameters */
+void Proc_5 (void) /* without parameters */
 /*******/
     /* executed once */
 {
diff --git a/testsuites/benchmarks/dhrystone/dhry_2.c b/testsuites/benchmarks/dhrystone/dhry_2.c
index 63a3d3e..94a72eb 100644
--- a/testsuites/benchmarks/dhrystone/dhry_2.c
+++ b/testsuites/benchmarks/dhrystone/dhry_2.c
@@ -17,6 +17,8 @@
 
 #include "dhry.h"
 
+#include <string.h>
+
 #ifndef REG
 #define REG
         /* REG becomes defined as empty */
@@ -27,7 +29,7 @@ extern  int     Int_Glob;
 extern  char    Ch_1_Glob;
 
 
-Proc_6 (Enum_Val_Par, Enum_Ref_Par)
+void Proc_6 (Enum_Val_Par, Enum_Ref_Par)
 /*********************************/
     /* executed once */
     /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
@@ -61,7 +63,7 @@ Enumeration *Enum_Ref_Par;
 } /* Proc_6 */
 
 
-Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
+void Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
 /**********************************************/
     /* executed three times                                      */ 
     /* first call:      Int_1_Par_Val == 2, Int_2_Par_Val == 3,  */
@@ -81,7 +83,7 @@ One_Fifty      *Int_Par_Ref;
 } /* Proc_7 */
 
 
-Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
+void Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
 /*********************************************************************/
     /* executed once      */
     /* Int_Par_Val_1 == 3 */
diff --git a/testsuites/benchmarks/dhrystone/dhrystone.doc b/testsuites/benchmarks/dhrystone/dhrystone.doc
index aac6f23..9a47275 100644
--- a/testsuites/benchmarks/dhrystone/dhrystone.doc
+++ b/testsuites/benchmarks/dhrystone/dhrystone.doc
@@ -4,8 +4,10 @@ test set name: dhrystone
 
 directives:
 
-  TBD
+  None, this benchmark program depends on the compiler, standard libraries, the
+  processor and the memory system.  It is more or less independent of the
+  operating system, except some disturbance from the system clock service.
 
 concepts:
 
-  TBD
+  This is the dhrystone benchmark ported to RTEMS.
diff --git a/testsuites/benchmarks/dhrystone/dhrystone.scn b/testsuites/benchmarks/dhrystone/dhrystone.scn
index e69de29..cbb855f 100644
--- a/testsuites/benchmarks/dhrystone/dhrystone.scn
+++ b/testsuites/benchmarks/dhrystone/dhrystone.scn
@@ -0,0 +1,63 @@
+*** BEGIN OF TEST DHRYSTONE ***
+
+Dhrystone Benchmark, Version 2.1 (Language: C)
+
+Program compiled without 'register' attribute
+
+Execution starts, 1000000 runs through Dhrystone
+Execution ends
+
+Final values of the variables used in the benchmark:
+
+Int_Glob:            5
+        should be:   5
+Bool_Glob:           1
+        should be:   1
+Ch_1_Glob:           A
+        should be:   A
+Ch_2_Glob:           B
+        should be:   B
+Arr_1_Glob[8]:       7
+        should be:   7
+Arr_2_Glob[8][7]:    1000010
+        should be:   Number_Of_Runs + 10
+Ptr_Glob->
+  Ptr_Comp:          33770520
+        should be:   (implementation-dependent)
+  Discr:             0
+        should be:   0
+  Enum_Comp:         2
+        should be:   2
+  Int_Comp:          17
+        should be:   17
+  Str_Comp:          DHRYSTONE PROGRAM, SOME STRING
+        should be:   DHRYSTONE PROGRAM, SOME STRING
+Next_Ptr_Glob->
+  Ptr_Comp:          33770520
+        should be:   (implementation-dependent), same as above
+  Discr:             0
+        should be:   0
+  Enum_Comp:         1
+        should be:   1
+  Int_Comp:          18
+        should be:   18
+  Str_Comp:          DHRYSTONE PROGRAM, SOME STRING
+        should be:   DHRYSTONE PROGRAM, SOME STRING
+Int_1_Loc:           5
+        should be:   5
+Int_2_Loc:           13
+        should be:   13
+Int_3_Loc:           7
+        should be:   7
+Enum_Loc:            1
+        should be:   1
+Str_1_Loc:           DHRYSTONE PROGRAM, 1'ST STRING
+        should be:   DHRYSTONE PROGRAM, 1'ST STRING
+Str_2_Loc:           DHRYSTONE PROGRAM, 2'ND STRING
+        should be:   DHRYSTONE PROGRAM, 2'ND STRING
+
+Microseconds for one run through Dhrystone:   82.8 
+Dhrystones per Second:                      12078.2 
+DMIPS:                                       6.87 
+
+*** END OF TEST DHRYSTONE ***
diff --git a/testsuites/benchmarks/dhrystone/init.c b/testsuites/benchmarks/dhrystone/init.c
index 6e339d4..3e6245c 100644
--- a/testsuites/benchmarks/dhrystone/init.c
+++ b/testsuites/benchmarks/dhrystone/init.c
@@ -20,15 +20,19 @@
 
 const char rtems_test_name[] = "DHRYSTONE";
 
-static void test(void)
-{
-}
+int main(int argc, char **argv);
 
 static void Init(rtems_task_argument arg)
 {
+  char *argv[] = {
+    "dhrystone",
+    "1000000",
+    NULL
+  };
+
   TEST_BEGIN();
 
-  test();
+  main(2, argv);
 
   TEST_END();
   rtems_test_exit(0);
@@ -41,6 +45,8 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
 
+#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
+
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
 #define CONFIGURE_INIT




More information about the vc mailing list