[rtems commit] benchmarks/whetstone: Port to RTEMS

Sebastian Huber sebh at rtems.org
Wed Mar 29 06:13:44 UTC 2017


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

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

benchmarks/whetstone: Port to RTEMS

Update #2958.

---

 testsuites/benchmarks/whetstone/Makefile.am   |  6 ++++--
 testsuites/benchmarks/whetstone/init.c        | 14 ++++++++++----
 testsuites/benchmarks/whetstone/whetstone.c   | 23 ++++++++++++++++-------
 testsuites/benchmarks/whetstone/whetstone.doc |  6 ++++--
 testsuites/benchmarks/whetstone/whetstone.scn |  5 +++++
 5 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/testsuites/benchmarks/whetstone/Makefile.am b/testsuites/benchmarks/whetstone/Makefile.am
index 6146952..a325ddc 100644
--- a/testsuites/benchmarks/whetstone/Makefile.am
+++ b/testsuites/benchmarks/whetstone/Makefile.am
@@ -1,5 +1,6 @@
 rtems_tests_PROGRAMS = whetstone
-whetstone_SOURCES = init.c
+whetstone_SOURCES = init.c whetstone.c
+whetstone_LDADD = -lm
 
 dist_rtems_tests_DATA = whetstone.scn whetstone.doc
 
@@ -8,8 +9,9 @@ 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 = $(whetstone_OBJECTS)
+LINK_OBJS = $(whetstone_OBJECTS) $(whetstone_LDADD)
 LINK_LIBS = $(whetstone_LDLIBS)
 
 whetstone$(EXEEXT): $(whetstone_OBJECTS) $(whetstone_DEPENDENCIES)
diff --git a/testsuites/benchmarks/whetstone/init.c b/testsuites/benchmarks/whetstone/init.c
index 075facc..b166118 100644
--- a/testsuites/benchmarks/whetstone/init.c
+++ b/testsuites/benchmarks/whetstone/init.c
@@ -20,15 +20,19 @@
 
 const char rtems_test_name[] = "WHETSTONE";
 
-static void test(void)
-{
-}
+int main(int argc, char **argv);
 
 static void Init(rtems_task_argument arg)
 {
+  char *argv[] = {
+    "whetstone",
+    "10000",
+    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
diff --git a/testsuites/benchmarks/whetstone/whetstone.c b/testsuites/benchmarks/whetstone/whetstone.c
index 159a11a..aa41353 100644
--- a/testsuites/benchmarks/whetstone/whetstone.c
+++ b/testsuites/benchmarks/whetstone/whetstone.c
@@ -58,7 +58,7 @@ C**********************************************************************
 #include <math.h>
 
 /* the following is optional depending on the timing function used */
-#include <time.h>
+#include <sys/time.h>
 
 /* map the FORTRAN math functions, etc. to the C versions */
 #define DSIN	sin
@@ -82,6 +82,15 @@ void P3(double X, double Y, double *Z);
 double T,T1,T2,E1[5];
 int J,K,L;
 
+static double
+Time(void)
+{
+	struct timeval tv;
+
+	gettimeofday(&tv, NULL);
+	return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -94,8 +103,8 @@ main(int argc, char *argv[])
 
 	/* added for this version */
 	long loopstart;
-	long startsec, finisec;
-	float KIPS;
+	double startsec, finisec;
+	double KIPS;
 	int continuous;
 
 	loopstart = 1000;		/* see the note about LOOP below */
@@ -120,7 +129,7 @@ C
 C	Start benchmark timing at this point.
 C
 */
-	startsec = time(0);
+	startsec = Time();
 
 /*
 C
@@ -355,7 +364,7 @@ C
 C      Stop benchmark timing at this point.
 C
 */
-	finisec = time(0);
+	finisec = Time();
 
 /*
 C----------------------------------------------------------------
@@ -372,10 +381,10 @@ C--------------------------------------------------------------------
 		return(1);
 	}
 
-	printf("Loops: %ld, Iterations: %d, Duration: %ld sec.\n",
+	printf("Loops: %ld, Iterations: %d, Duration: %f sec.\n",
 			LOOP, II, finisec-startsec);
 
-	KIPS = (100.0*LOOP*II)/(float)(finisec-startsec);
+	KIPS = (100.0*LOOP*II)/(finisec-startsec);
 	if (KIPS >= 1000.0)
 		printf("C Converted Double Precision Whetstones: %.1f MIPS\n", KIPS/1000.0);
 	else
diff --git a/testsuites/benchmarks/whetstone/whetstone.doc b/testsuites/benchmarks/whetstone/whetstone.doc
index b6c3383..0b21744 100644
--- a/testsuites/benchmarks/whetstone/whetstone.doc
+++ b/testsuites/benchmarks/whetstone/whetstone.doc
@@ -4,8 +4,10 @@ test set name: whetstone
 
 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 whetstone benchmark ported to RTEMS.
diff --git a/testsuites/benchmarks/whetstone/whetstone.scn b/testsuites/benchmarks/whetstone/whetstone.scn
index e69de29..17b066d 100644
--- a/testsuites/benchmarks/whetstone/whetstone.scn
+++ b/testsuites/benchmarks/whetstone/whetstone.scn
@@ -0,0 +1,5 @@
+*** BEGIN OF TEST WHETSTONE ***
+
+Loops: 10000, Iterations: 1, Duration: 347.679499 sec.
+C Converted Double Precision Whetstones: 2.9 MIPS
+*** END OF TEST WHETSTONE ***



More information about the vc mailing list