[PATCH 3/7] benchmarks/dhrystone: Port to RTEMS
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue Mar 28 12:55:58 UTC 2017
---
testsuites/benchmarks/dhrystone/Makefile.am | 5 ++-
testsuites/benchmarks/dhrystone/dhry.h | 12 +++++-
testsuites/benchmarks/dhrystone/dhry_1.c | 31 ++++++--------
testsuites/benchmarks/dhrystone/dhry_2.c | 8 ++--
testsuites/benchmarks/dhrystone/dhrystone.scn | 62 +++++++++++++++++++++++++++
testsuites/benchmarks/dhrystone/init.c | 14 ++++--
6 files changed, 105 insertions(+), 27 deletions(-)
diff --git a/testsuites/benchmarks/dhrystone/Makefile.am b/testsuites/benchmarks/dhrystone/Makefile.am
index 0354012..f9443e4 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
@@ -7,7 +7,8 @@ include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
-AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include -DTIME
+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..df52384 100644
--- a/testsuites/benchmarks/dhrystone/dhry.h
+++ b/testsuites/benchmarks/dhrystone/dhry.h
@@ -420,4 +420,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..7370bb0 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,7 +50,7 @@ extern int times ();
/* Measurements should last at least about 2 seconds */
#endif
#ifdef TIME
-extern long time();
+#include <time.h>
/* see library function "time" */
#define Too_Small_Time 2
/* Measurements should last at least 2 seconds */
@@ -66,7 +65,7 @@ float Microseconds,
/* end of variables for time measurement */
-main ()
+int main (int argc, char **argv)
/*****/
/* main program, corresponds to procedures */
@@ -114,13 +113,11 @@ 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");
printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
@@ -277,7 +274,7 @@ main ()
}
-Proc_1 (Ptr_Val_Par)
+void Proc_1 (Ptr_Val_Par)
/******************/
REG Rec_Pointer Ptr_Val_Par;
@@ -311,7 +308,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 +331,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 +346,7 @@ Rec_Pointer *Ptr_Ref_Par;
} /* Proc_3 */
-Proc_4 () /* without parameters */
+void Proc_4 (void) /* without parameters */
/*******/
/* executed once */
{
@@ -361,7 +358,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.scn b/testsuites/benchmarks/dhrystone/dhrystone.scn
index e69de29..206c475 100644
--- a/testsuites/benchmarks/dhrystone/dhrystone.scn
+++ b/testsuites/benchmarks/dhrystone/dhrystone.scn
@@ -0,0 +1,62 @@
+*** 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: 33770184
+ 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: 33770184
+ 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.0
+Dhrystones per Second: 12195.1
+
+*** 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
--
1.8.4.5
More information about the devel
mailing list