Bläddra i källkod

application: make benchmark works on iar compiler

application: make benchmark works on iar compiler

Signed-off-by: Huaqi Fang <578567190@qq.com>

application: update coremark core_portme.h for iar compiler

Signed-off-by: Huaqi Fang <578567190@qq.com>

application: optimize dhrystone bench to remove compiler warning

Signed-off-by: Huaqi Fang <578567190@qq.com>
Huaqi Fang 2 år sedan
förälder
incheckning
603ebbb0bb

+ 6 - 5
application/baremetal/benchmark/coremark/core_portme.h

@@ -2,11 +2,10 @@
 #define CORE_PORTME_H
 
 #include "nuclei_sdk_soc.h"
-//Bob: put some macro here such that the IDE SDK do not need to specify the macro specially
-//#define FLAGS_STR "-O3 -fno-common -funroll-loops -finline-functions  -falign-functions=4 -falign-jumps=4 -falign-loops=4 -funswitch-loops -fpeel-loops -fgcse-sm -fgcse-las"
-//#define FLAGS_STR "-O2 -fno-common -funroll-loops -finline-functions -falign-functions=4 -falign-jumps=4 -falign-loops=4"
+
+
 #ifndef FLAGS_STR
-#define FLAGS_STR "-O2 -funroll-all-loops -finline-limit=600 -ftree-dominator-opts -fno-if-conversion2 -fselective-scheduling -fno-code-hoisting -fno-common -funroll-loops -finline-functions -falign-functions=4 -falign-jumps=4 -falign-loops=4"
+#define FLAGS_STR "Please check your compiler options!"
 #endif
 
 #ifndef PERFORMANCE_RUN
@@ -52,8 +51,10 @@
 
 #ifdef __GNUC__
 # define COMPILER_VERSION "GCC"__VERSION__
+#elif defined(__ICCRISCV__)
+# define COMPILER_VERSION "IAR "__VERSION__
 #else
-# error
+# define COMPILER_VERSION "Unknown Compiler"
 #endif
 
 #define MEM_METHOD MEM_STACK

+ 5 - 3
application/baremetal/benchmark/dhrystone/dhry.h

@@ -344,6 +344,9 @@
  *
  ***************************************************************************
  */
+#ifndef _DHRY_H_
+#define _DHRY_H_
+
 //Bob: here we add define TIME and NOENUM
 #define TIME
 #define NOENUM
@@ -386,8 +389,7 @@ Enumeration;
 
 /* General definitions: */
 
-#include <stdio.h>
-/* for strcpy, strcmp */
+#include <string.h>
 
 #define Null 0
 /* Value of a Null pointer */
@@ -422,4 +424,4 @@ typedef struct record {
     } variant;
 } Rec_Type, *Rec_Pointer;
 
-
+#endif

+ 108 - 121
application/baremetal/benchmark/dhrystone/dhry_1.c

@@ -17,10 +17,10 @@
 #include "dhry.h"
 
 #include <stdint.h>
-#include <string.h>
+#include <stdio.h>
 #include <stdlib.h>
-/* Global Variables: */
 
+/* Global Variables: */
 Rec_Pointer     Ptr_Glob,
                 Next_Ptr_Glob;
 int             Int_Glob;
@@ -30,10 +30,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
@@ -53,12 +49,21 @@ extern  int     times();
 /* Measurements should last at least about 2 seconds */
 #endif
 #ifdef TIME
-extern long     time();
+extern long     time(void);
 /* see library function "time"  */
 #define Too_Small_Time 2
 /* Measurements should last at least 2 seconds */
 #endif
 
+extern long csr_cycle(void);
+extern long csr_instret(void);
+extern Enumeration Func_1(Capital_Letter   Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val);
+extern Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref);
+extern Boolean Func_3(Enumeration Enum_Par_Val);
+extern void Proc_6(Enumeration Enum_Val_Par, Enumeration* Enum_Ref_Par);
+extern void Proc_7(One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, One_Fifty* Int_Par_Ref);
+extern void Proc_8(Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, int Int_1_Par_Val, int Int_2_Par_Val);
+
 long            Begin_Cycle,
                 End_Cycle,
                 User_Cycle;
@@ -89,6 +94,100 @@ static char *dec2str(uint32_t val)
     return str;
 }
 
+void Proc_3(Rec_Pointer* Ptr_Ref_Par)
+/******************/
+/* executed once */
+/* Ptr_Ref_Par becomes Ptr_Glob */
+{
+    if (Ptr_Glob != Null)
+        /* then, executed */
+    {
+        *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
+    }
+    Proc_7(10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
+} /* Proc_3 */
+
+void Proc_1(REG Rec_Pointer Ptr_Val_Par)
+/******************/
+/* executed once */
+{
+    REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
+    /* == Ptr_Glob_Next */
+    /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp,    */
+    /* corresponds to "rename" in Ada, "with" in Pascal           */
+
+    structassign(*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
+    Ptr_Val_Par->variant.var_1.Int_Comp = 5;
+    Next_Record->variant.var_1.Int_Comp
+        = Ptr_Val_Par->variant.var_1.Int_Comp;
+    Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
+    Proc_3(&Next_Record->Ptr_Comp);
+    /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
+                        == Ptr_Glob->Ptr_Comp */
+    if (Next_Record->Discr == Ident_1)
+        /* then, executed */
+    {
+        Next_Record->variant.var_1.Int_Comp = 6;
+        Proc_6(Ptr_Val_Par->variant.var_1.Enum_Comp,
+               &Next_Record->variant.var_1.Enum_Comp);
+        Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
+        Proc_7(Next_Record->variant.var_1.Int_Comp, 10,
+               &Next_Record->variant.var_1.Int_Comp);
+    } else { /* not executed */
+        structassign(*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
+    }
+} /* Proc_1 */
+
+void Proc_2(One_Fifty* Int_Par_Ref)
+/******************/
+/* executed once */
+/* *Int_Par_Ref == 1, becomes 4 */
+{
+    One_Fifty  Int_Loc;
+    Enumeration   Enum_Loc;
+
+    Int_Loc = *Int_Par_Ref + 10;
+    do /* executed once */
+        if (Ch_1_Glob == 'A')
+            /* then, executed */
+        {
+            Int_Loc -= 1;
+            *Int_Par_Ref = Int_Loc - Int_Glob;
+            Enum_Loc = Ident_1;
+        } /* if */
+    while (Enum_Loc != Ident_1); /* true */
+} /* Proc_2 */
+
+void Proc_4(void)  /* without parameters */
+/*******/
+/* executed once */
+{
+    Boolean Bool_Loc;
+
+    Bool_Loc = Ch_1_Glob == 'A';
+    Bool_Glob = Bool_Loc | Bool_Glob;
+    Ch_2_Glob = 'B';
+} /* Proc_4 */
+
+void Proc_5(void)  /* without parameters */
+/*******/
+/* executed once */
+{
+    Ch_1_Glob = 'A';
+    Bool_Glob = false;
+} /* Proc_5 */
+
+/* Procedure for the assignment of structures,          */
+/* if the C compiler doesn't support this feature       */
+#ifdef  NOSTRUCTASSIGN
+void memcpy(register char* d, register char* s, register int l)
+{
+    while (l--) {
+        *d++ = *s++;
+    }
+}
+#endif
+
 int main(void)
 /*****/
 
@@ -136,8 +235,6 @@ int main(void)
     }
     printf("Please give the number of runs through the benchmark: \n");
     {
-        int n;
-        //Bob: We dont use scanf
 #ifdef CFG_SIMULATION
         //Bob: for simulation we make it small
         Number_Of_Runs = 200;
@@ -158,7 +255,7 @@ int main(void)
     Begin_Time = (long) time_info.tms_utime;
 #endif
 #ifdef TIME
-    Begin_Time = time((long*) 0);
+    Begin_Time = time();
 #endif
     Begin_Instret =  csr_instret();
     Begin_Cycle =  csr_cycle();
@@ -218,7 +315,7 @@ int main(void)
     End_Time = (long) time_info.tms_utime;
 #endif
 #ifdef TIME
-    End_Time = time((long*) 0);
+    End_Time = time();
 #endif
 
     printf("Execution ends\n");
@@ -317,113 +414,3 @@ int main(void)
 }
 
 
-Proc_1(Ptr_Val_Par)
-/******************/
-
-REG Rec_Pointer Ptr_Val_Par;
-/* executed once */
-{
-    REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
-    /* == Ptr_Glob_Next */
-    /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp,    */
-    /* corresponds to "rename" in Ada, "with" in Pascal           */
-
-    structassign(*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
-    Ptr_Val_Par->variant.var_1.Int_Comp = 5;
-    Next_Record->variant.var_1.Int_Comp
-        = Ptr_Val_Par->variant.var_1.Int_Comp;
-    Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
-    Proc_3(&Next_Record->Ptr_Comp);
-    /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
-                        == Ptr_Glob->Ptr_Comp */
-    if (Next_Record->Discr == Ident_1)
-        /* then, executed */
-    {
-        Next_Record->variant.var_1.Int_Comp = 6;
-        Proc_6(Ptr_Val_Par->variant.var_1.Enum_Comp,
-               &Next_Record->variant.var_1.Enum_Comp);
-        Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
-        Proc_7(Next_Record->variant.var_1.Int_Comp, 10,
-               &Next_Record->variant.var_1.Int_Comp);
-    } else { /* not executed */
-        structassign(*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
-    }
-} /* Proc_1 */
-
-
-Proc_2(Int_Par_Ref)
-/******************/
-/* executed once */
-/* *Int_Par_Ref == 1, becomes 4 */
-
-One_Fifty*   Int_Par_Ref;
-{
-    One_Fifty  Int_Loc;
-    Enumeration   Enum_Loc;
-
-    Int_Loc = *Int_Par_Ref + 10;
-    do /* executed once */
-        if (Ch_1_Glob == 'A')
-            /* then, executed */
-        {
-            Int_Loc -= 1;
-            *Int_Par_Ref = Int_Loc - Int_Glob;
-            Enum_Loc = Ident_1;
-        } /* if */
-    while (Enum_Loc != Ident_1); /* true */
-} /* Proc_2 */
-
-
-Proc_3(Ptr_Ref_Par)
-/******************/
-/* executed once */
-/* Ptr_Ref_Par becomes Ptr_Glob */
-
-Rec_Pointer* Ptr_Ref_Par;
-
-{
-    if (Ptr_Glob != Null)
-        /* then, executed */
-    {
-        *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
-    }
-    Proc_7(10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
-} /* Proc_3 */
-
-
-Proc_4()  /* without parameters */
-/*******/
-/* executed once */
-{
-    Boolean Bool_Loc;
-
-    Bool_Loc = Ch_1_Glob == 'A';
-    Bool_Glob = Bool_Loc | Bool_Glob;
-    Ch_2_Glob = 'B';
-} /* Proc_4 */
-
-
-Proc_5()  /* without parameters */
-/*******/
-/* executed once */
-{
-    Ch_1_Glob = 'A';
-    Bool_Glob = false;
-} /* Proc_5 */
-
-
-/* Procedure for the assignment of structures,          */
-/* if the C compiler doesn't support this feature       */
-#ifdef  NOSTRUCTASSIGN
-memcpy(d, s, l)
-register char*   d;
-register char*   s;
-register int    l;
-{
-    while (l--) {
-        *d++ = *s++;
-    }
-}
-#endif
-
-

+ 24 - 40
application/baremetal/benchmark/dhrystone/dhry_2.c

@@ -34,13 +34,28 @@ extern int strcmp_xlcz(const char* str1, const char* str2);
 #define STRCMP(str1, str2) strcmp(str1, str2)
 #endif
 
-Proc_6(Enum_Val_Par, Enum_Ref_Par)
+
+Boolean Func_3(Enumeration Enum_Par_Val)
+/***************************/
+/* executed once        */
+/* Enum_Par_Val == Ident_3 */
+{
+    Enumeration Enum_Loc;
+
+    Enum_Loc = Enum_Par_Val;
+    if (Enum_Loc == Ident_3)
+        /* then, executed */
+    {
+        return (true);
+    } else { /* not executed */
+        return (false);
+    }
+} /* Func_3 */
+
+void Proc_6(Enumeration Enum_Val_Par, Enumeration* Enum_Ref_Par)
 /*********************************/
 /* executed once */
 /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
-
-Enumeration  Enum_Val_Par;
-Enumeration* Enum_Ref_Par;
 {
     *Enum_Ref_Par = Enum_Val_Par;
     if (! Func_3(Enum_Val_Par))
@@ -73,7 +88,7 @@ Enumeration* Enum_Ref_Par;
 } /* Proc_6 */
 
 
-Proc_7(Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
+void Proc_7(One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, One_Fifty* Int_Par_Ref)
 /**********************************************/
 /* executed three times                                      */
 /* first call:      Int_1_Par_Val == 2, Int_2_Par_Val == 3,  */
@@ -82,9 +97,6 @@ Proc_7(Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
 /*                  Int_Par_Ref becomes 17                   */
 /* third call:      Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
 /*                  Int_Par_Ref becomes 18                   */
-One_Fifty       Int_1_Par_Val;
-One_Fifty       Int_2_Par_Val;
-One_Fifty*      Int_Par_Ref;
 {
     One_Fifty Int_Loc;
 
@@ -93,15 +105,11 @@ 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_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, int Int_1_Par_Val, int Int_2_Par_Val)
 /*********************************************************************/
 /* executed once      */
 /* Int_Par_Val_1 == 3 */
 /* Int_Par_Val_2 == 7 */
-Arr_1_Dim       Arr_1_Par_Ref;
-Arr_2_Dim       Arr_2_Par_Ref;
-int             Int_1_Par_Val;
-int             Int_2_Par_Val;
 {
     REG One_Fifty Int_Index;
     REG One_Fifty Int_Loc;
@@ -119,15 +127,12 @@ int             Int_2_Par_Val;
 } /* Proc_8 */
 
 
-Enumeration Func_1(Ch_1_Par_Val, Ch_2_Par_Val)
+Enumeration Func_1(Capital_Letter   Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
 /*************************************************/
 /* executed three times                                         */
 /* first call:      Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R'    */
 /* second call:     Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C'    */
 /* third call:      Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C'    */
-
-Capital_Letter   Ch_1_Par_Val;
-Capital_Letter   Ch_2_Par_Val;
 {
     Capital_Letter        Ch_1_Loc;
     Capital_Letter        Ch_2_Loc;
@@ -145,14 +150,12 @@ Capital_Letter   Ch_2_Par_Val;
 } /* Func_1 */
 
 
-Boolean Func_2(Str_1_Par_Ref, Str_2_Par_Ref)
+Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref)
 /*************************************************/
 /* executed once */
 /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
 /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
 
-Str_30  Str_1_Par_Ref;
-Str_30  Str_2_Par_Ref;
 {
     REG One_Thirty        Int_Loc;
     Capital_Letter    Ch_Loc;
@@ -188,23 +191,4 @@ Str_30  Str_2_Par_Ref;
     } /* if Ch_Loc */
 } /* Func_2 */
 
-#undef STRCMP
-
-Boolean Func_3(Enum_Par_Val)
-/***************************/
-/* executed once        */
-/* Enum_Par_Val == Ident_3 */
-Enumeration Enum_Par_Val;
-{
-    Enumeration Enum_Loc;
-
-    Enum_Loc = Enum_Par_Val;
-    if (Enum_Loc == Ident_3)
-        /* then, executed */
-    {
-        return (true);
-    } else { /* not executed */
-        return (false);
-    }
-} /* Func_3 */
-
+#undef STRCMP

+ 0 - 3
application/baremetal/benchmark/dhrystone/dhry_stubs.c

@@ -1,8 +1,5 @@
 #include "nuclei_sdk_soc.h"
 
-/* The functions in this file are only meant to support Dhrystone on an
- * embedded RV32 system and are obviously incorrect in general. */
-
 long csr_cycle(void)
 {
     return __get_rv_cycle();