-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dhrystone and whetstone benchmarks on fs
- Loading branch information
Showing
3 changed files
with
356 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,49 @@ | ||
FROM --platform=$BUILDPLATFORM ubuntu:22.04 as cross-builder | ||
ENV BUILD_BASE=/tmp/build-extra | ||
|
||
# Install dependencies | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
ca-certificates \ | ||
wget \ | ||
crossbuild-essential-riscv64 \ | ||
gcc-12-riscv64-linux-gnu \ | ||
&& \ | ||
adduser developer -u 499 --gecos ",,," --disabled-password && \ | ||
mkdir -p ${BUILD_BASE} && chown -R developer:developer ${BUILD_BASE} && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
USER developer | ||
WORKDIR ${BUILD_BASE} | ||
|
||
# Build benchmark binaries | ||
COPY fs/dhrystone.patch ${BUILD_BASE}/ | ||
COPY fs/shasumfile ${BUILD_BASE}/ | ||
RUN mkdir benchmarks && cd benchmarks && \ | ||
wget https://www.netlib.org/benchmark/whetstone.c https://www.netlib.org/benchmark/dhry-c && \ | ||
shasum -ca 256 ../shasumfile &&\ | ||
bash dhry-c && \ | ||
patch -p1 < ../dhrystone.patch && \ | ||
riscv64-linux-gnu-gcc-12 -O2 -o whetstone whetstone.c -lm && \ | ||
riscv64-linux-gnu-gcc-12 -O2 -o dhrystone dhry_1.c dhry_2.c -lm | ||
|
||
# Final image | ||
FROM --platform=linux/riscv64 riscv64/ubuntu:22.04 | ||
ARG TOOLS_DEB=machine-emulator-tools-v0.14.0.deb | ||
ADD ${TOOLS_DEB} /tmp/ | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
busybox-static=1:1.30.1-7ubuntu3 \ | ||
coreutils=8.32-4.1ubuntu1 \ | ||
bash=5.1-6ubuntu1 \ | ||
bc=1.07.1-3build1 \ | ||
curl=7.81.0-1ubuntu1.15 \ | ||
device-tree-compiler=1.6.1-1 \ | ||
jq=1.6-2.1ubuntu3 \ | ||
lua5.4=5.4.4-1 \ | ||
/tmp/${TOOLS_DEB} && \ | ||
busybox-static=1:1.30.1-7ubuntu3 \ | ||
coreutils=8.32-4.1ubuntu1 \ | ||
bash=5.1-6ubuntu1 \ | ||
bc=1.07.1-3build1 \ | ||
curl=7.81.0-1ubuntu1.15 \ | ||
device-tree-compiler=1.6.1-1 \ | ||
jq=1.6-2.1ubuntu3 \ | ||
lua5.4=5.4.4-1 \ | ||
/tmp/${TOOLS_DEB} && \ | ||
useradd --create-home --user-group dapp && \ | ||
rm -rf /var/lib/apt/lists/* /tmp/${TOOLS_DEB} | ||
RUN useradd --create-home --user-group dapp | ||
COPY --from=cross-builder /tmp/build-extra/benchmarks/whetstone /usr/bin/ | ||
COPY --from=cross-builder /tmp/build-extra/benchmarks/dhrystone /usr/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,311 @@ | ||
diff -Nru a/dhry.h b/dhry.h | ||
--- a/dhry.h | ||
+++ b/dhry.h | ||
@@ -345,6 +345,9 @@ | ||
*************************************************************************** | ||
*/ | ||
|
||
+#ifndef DHRY_H | ||
+#define DHRY_H | ||
+ | ||
/* Compiler and system dependent definitions: */ | ||
|
||
#ifndef TIME | ||
@@ -359,6 +362,10 @@ | ||
/* for "times" */ | ||
#endif | ||
|
||
+#ifndef HZ | ||
+#include <sys/param.h> | ||
+#endif | ||
+ | ||
#define Mic_secs_Per_Second 1000000.0 | ||
/* Berkeley UNIX C returns process times in seconds/HZ */ | ||
|
||
@@ -384,6 +391,8 @@ | ||
/* General definitions: */ | ||
|
||
#include <stdio.h> | ||
+#include <stdlib.h> | ||
+#include <string.h> | ||
/* for strcpy, strcmp */ | ||
|
||
#define Null 0 | ||
@@ -420,4 +429,16 @@ | ||
} variant; | ||
} Rec_Type, *Rec_Pointer; | ||
|
||
+void Proc_1(Rec_Pointer Ptr_Val_Par); | ||
+void Proc_2(One_Fifty *Int_Par_Ref); | ||
+void Proc_3(Rec_Pointer *Ptr_Ref_Par); | ||
+void Proc_4(); | ||
+void Proc_5(); | ||
+void Proc_6(Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par); | ||
+void Proc_7(One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, One_Fifty *Int_Par_Ref); | ||
+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); | ||
|
||
+Enumeration Func_1(Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val); | ||
+Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref); | ||
+Boolean Func_3(Enumeration Enum_Par_Val); | ||
+#endif | ||
diff -Nru a/dhry_1.c b/dhry_1.c | ||
--- a/dhry_1.c | ||
+++ b/dhry_1.c | ||
@@ -17,6 +17,8 @@ | ||
|
||
#include "dhry.h" | ||
|
||
+#include <stdint.h> | ||
+ | ||
/* Global Variables: */ | ||
|
||
Rec_Pointer Ptr_Glob, | ||
@@ -28,9 +30,6 @@ | ||
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; | ||
@@ -45,13 +44,11 @@ | ||
|
||
#ifdef TIMES | ||
struct tms time_info; | ||
-extern int times (); | ||
/* see library function "times" */ | ||
#define Too_Small_Time 120 | ||
/* Measurements should last at least about 2 seconds */ | ||
#endif | ||
#ifdef TIME | ||
-extern long time(); | ||
/* see library function "time" */ | ||
#define Too_Small_Time 2 | ||
/* Measurements should last at least 2 seconds */ | ||
@@ -65,8 +62,7 @@ | ||
|
||
/* end of variables for time measurement */ | ||
|
||
- | ||
-main () | ||
+int main (int argc, char *argv[]) | ||
/*****/ | ||
|
||
/* main program, corresponds to procedures */ | ||
@@ -101,6 +97,15 @@ | ||
/* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */ | ||
/* overflow may occur for this array element. */ | ||
|
||
+ Number_Of_Runs = 0; | ||
+ if (argc == 2) | ||
+ { | ||
+ if (atoi(argv[1]) > 0) | ||
+ { | ||
+ Number_Of_Runs = atoi(argv[1]); | ||
+ } | ||
+ } | ||
+ | ||
printf ("\n"); | ||
printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n"); | ||
printf ("\n"); | ||
@@ -114,13 +119,6 @@ | ||
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; | ||
- } | ||
- printf ("\n"); | ||
|
||
printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs); | ||
|
||
@@ -211,7 +209,7 @@ | ||
printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]); | ||
printf (" should be: Number_Of_Runs + 10\n"); | ||
printf ("Ptr_Glob->\n"); | ||
- printf (" Ptr_Comp: %d\n", (int) Ptr_Glob->Ptr_Comp); | ||
+ printf (" Ptr_Comp: %ld\n", (uintptr_t) Ptr_Glob->Ptr_Comp); | ||
printf (" should be: (implementation-dependent)\n"); | ||
printf (" Discr: %d\n", Ptr_Glob->Discr); | ||
printf (" should be: %d\n", 0); | ||
@@ -222,7 +220,7 @@ | ||
printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp); | ||
printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n"); | ||
printf ("Next_Ptr_Glob->\n"); | ||
- printf (" Ptr_Comp: %d\n", (int) Next_Ptr_Glob->Ptr_Comp); | ||
+ printf (" Ptr_Comp: %ld\n", (uintptr_t) Next_Ptr_Glob->Ptr_Comp); | ||
printf (" should be: (implementation-dependent), same as above\n"); | ||
printf (" Discr: %d\n", Next_Ptr_Glob->Discr); | ||
printf (" should be: %d\n", 0); | ||
@@ -273,15 +271,14 @@ | ||
printf ("%6.1f \n", Dhrystones_Per_Second); | ||
printf ("\n"); | ||
} | ||
- | ||
+ | ||
+ return 0; | ||
} | ||
|
||
|
||
-Proc_1 (Ptr_Val_Par) | ||
+void Proc_1 (REG Rec_Pointer Ptr_Val_Par) | ||
/******************/ | ||
- | ||
-REG Rec_Pointer Ptr_Val_Par; | ||
- /* executed once */ | ||
+/* executed once */ | ||
{ | ||
REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp; | ||
/* == Ptr_Glob_Next */ | ||
@@ -311,12 +308,10 @@ | ||
} /* Proc_1 */ | ||
|
||
|
||
-Proc_2 (Int_Par_Ref) | ||
+void Proc_2 (One_Fifty *Int_Par_Ref) | ||
/******************/ | ||
/* executed once */ | ||
/* *Int_Par_Ref == 1, becomes 4 */ | ||
- | ||
-One_Fifty *Int_Par_Ref; | ||
{ | ||
One_Fifty Int_Loc; | ||
Enumeration Enum_Loc; | ||
@@ -334,13 +329,10 @@ | ||
} /* Proc_2 */ | ||
|
||
|
||
-Proc_3 (Ptr_Ref_Par) | ||
+void Proc_3 (Rec_Pointer *Ptr_Ref_Par) | ||
/******************/ | ||
/* executed once */ | ||
/* Ptr_Ref_Par becomes Ptr_Glob */ | ||
- | ||
-Rec_Pointer *Ptr_Ref_Par; | ||
- | ||
{ | ||
if (Ptr_Glob != Null) | ||
/* then, executed */ | ||
@@ -349,7 +341,7 @@ | ||
} /* Proc_3 */ | ||
|
||
|
||
-Proc_4 () /* without parameters */ | ||
+void Proc_4 () /* without parameters */ | ||
/*******/ | ||
/* executed once */ | ||
{ | ||
@@ -361,7 +353,7 @@ | ||
} /* Proc_4 */ | ||
|
||
|
||
-Proc_5 () /* without parameters */ | ||
+void Proc_5 () /* without parameters */ | ||
/*******/ | ||
/* executed once */ | ||
{ | ||
diff -Nru a/dhry_2.c b/dhry_2.c | ||
--- a/dhry_2.c | ||
+++ b/dhry_2.c | ||
@@ -27,13 +27,10 @@ | ||
extern char Ch_1_Glob; | ||
|
||
|
||
-Proc_6 (Enum_Val_Par, Enum_Ref_Par) | ||
+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)) | ||
@@ -61,7 +58,7 @@ | ||
} /* 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, */ | ||
@@ -70,9 +67,6 @@ | ||
/* 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; | ||
|
||
@@ -81,15 +75,11 @@ | ||
} /* 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; | ||
@@ -106,15 +96,12 @@ | ||
} /* 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; | ||
@@ -132,14 +119,11 @@ | ||
} /* 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; | ||
@@ -174,11 +158,10 @@ | ||
} /* Func_2 */ | ||
|
||
|
||
-Boolean Func_3 (Enum_Par_Val) | ||
+Boolean Func_3 (Enumeration Enum_Par_Val) | ||
/***************************/ | ||
/* executed once */ | ||
/* Enum_Par_Val == Ident_3 */ | ||
-Enumeration Enum_Par_Val; | ||
{ | ||
Enumeration Enum_Loc; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
333e4ceca042c146f63eec605573d16ae8b07166cbc44a17bec1ea97c6f1efbf whetstone.c | ||
038a7e9169787125c3451a6c941f3aca5db2d2f3863871afcdce154ef17f4e3e dhry-c |