From 069282803cf1f1dbf28f5a50016933d61f621c6a Mon Sep 17 00:00:00 2001
From: Yuya Hamamachi <yuya.hamamachi.sx@renesas.com>
Date: Wed, 15 Feb 2023 17:56:56 +0900
Subject: [PATCH 9/9] vm_atk2: vm2_atk2: Add Coremark benchmark

Signed-off-by: Yuya Hamamachi <yuya.hamamachi.sx@renesas.com>
---
 .gitignore                        |  3 ++-
 vm_atk2/vm2_atk2/Makefile         |  4 +++-
 vm_atk2/vm2_atk2/core_list_join.c |  1 +
 vm_atk2/vm2_atk2/core_main.c      |  1 +
 vm_atk2/vm2_atk2/core_matrix.c    |  1 +
 vm_atk2/vm2_atk2/core_portme.c    |  1 +
 vm_atk2/vm2_atk2/core_portme.h    |  1 +
 vm_atk2/vm2_atk2/core_state.c     |  1 +
 vm_atk2/vm2_atk2/core_util.c      |  1 +
 vm_atk2/vm2_atk2/coremark.h       |  1 +
 vm_atk2/vm2_atk2/sample1_vm2.c    | 10 ++++++++++
 11 files changed, 23 insertions(+), 2 deletions(-)
 create mode 120000 vm_atk2/vm2_atk2/core_list_join.c
 create mode 120000 vm_atk2/vm2_atk2/core_main.c
 create mode 120000 vm_atk2/vm2_atk2/core_matrix.c
 create mode 120000 vm_atk2/vm2_atk2/core_portme.c
 create mode 120000 vm_atk2/vm2_atk2/core_portme.h
 create mode 120000 vm_atk2/vm2_atk2/core_state.c
 create mode 120000 vm_atk2/vm2_atk2/core_util.c
 create mode 120000 vm_atk2/vm2_atk2/coremark.h

diff --git a/.gitignore b/.gitignore
index 48fa4e6..5ee6848 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@
 *.map
 Makefile.depend
 depend
-dhrystone*
\ No newline at end of file
+dhrystone*
+coremark/
diff --git a/vm_atk2/vm2_atk2/Makefile b/vm_atk2/vm2_atk2/Makefile
index 1bbbb73..a60bf6b 100644
--- a/vm_atk2/vm2_atk2/Makefile
+++ b/vm_atk2/vm2_atk2/Makefile
@@ -23,16 +23,18 @@ endif
 
 OBJNAME = atk2-sc1_vm2
 
-CDEFS := $(CDEFS) -DTIME
+CDEFS := $(CDEFS) -DTIME -DITERATIONS=30000
 
 ifeq ($(COMPILER),GHS)
 CDEFS := $(CDEFS) -D__GHS_HEAP__
 ADD_OBJ = dhry_1.o dhry_2.o
+ADD_OBJ := $(ADD_OBJ) core_list_join.o core_main.o core_matrix.o core_portme.o core_state.o core_util.o
 include ../Makefile.ghs
 endif
 
 ifeq ($(COMPILER),CCRH)
 LDFLAGS := -library=lib\\v850e3v5\\libmalloc.lib
 ADD_OBJ = dhry_1.obj dhry_2.obj
+ADD_OBJ := $(ADD_OBJ) core_list_join.obj core_main.obj core_matrix.obj core_portme.obj core_state.obj core_util.obj
 include ../Makefile.ccrh
 endif
diff --git a/vm_atk2/vm2_atk2/core_list_join.c b/vm_atk2/vm2_atk2/core_list_join.c
new file mode 120000
index 0000000..1c0999c
--- /dev/null
+++ b/vm_atk2/vm2_atk2/core_list_join.c
@@ -0,0 +1 @@
+./coremark/core_list_join.c
\ No newline at end of file
diff --git a/vm_atk2/vm2_atk2/core_main.c b/vm_atk2/vm2_atk2/core_main.c
new file mode 120000
index 0000000..e94a1b6
--- /dev/null
+++ b/vm_atk2/vm2_atk2/core_main.c
@@ -0,0 +1 @@
+./coremark/core_main.c
\ No newline at end of file
diff --git a/vm_atk2/vm2_atk2/core_matrix.c b/vm_atk2/vm2_atk2/core_matrix.c
new file mode 120000
index 0000000..5bb6ed7
--- /dev/null
+++ b/vm_atk2/vm2_atk2/core_matrix.c
@@ -0,0 +1 @@
+./coremark/core_matrix.c
\ No newline at end of file
diff --git a/vm_atk2/vm2_atk2/core_portme.c b/vm_atk2/vm2_atk2/core_portme.c
new file mode 120000
index 0000000..cbc65f9
--- /dev/null
+++ b/vm_atk2/vm2_atk2/core_portme.c
@@ -0,0 +1 @@
+./coremark/barebones/core_portme.c
\ No newline at end of file
diff --git a/vm_atk2/vm2_atk2/core_portme.h b/vm_atk2/vm2_atk2/core_portme.h
new file mode 120000
index 0000000..2ec0308
--- /dev/null
+++ b/vm_atk2/vm2_atk2/core_portme.h
@@ -0,0 +1 @@
+./coremark/barebones/core_portme.h
\ No newline at end of file
diff --git a/vm_atk2/vm2_atk2/core_state.c b/vm_atk2/vm2_atk2/core_state.c
new file mode 120000
index 0000000..c2ef5cb
--- /dev/null
+++ b/vm_atk2/vm2_atk2/core_state.c
@@ -0,0 +1 @@
+./coremark/core_state.c
\ No newline at end of file
diff --git a/vm_atk2/vm2_atk2/core_util.c b/vm_atk2/vm2_atk2/core_util.c
new file mode 120000
index 0000000..3414701
--- /dev/null
+++ b/vm_atk2/vm2_atk2/core_util.c
@@ -0,0 +1 @@
+./coremark/core_util.c
\ No newline at end of file
diff --git a/vm_atk2/vm2_atk2/coremark.h b/vm_atk2/vm2_atk2/coremark.h
new file mode 120000
index 0000000..4a34b07
--- /dev/null
+++ b/vm_atk2/vm2_atk2/coremark.h
@@ -0,0 +1 @@
+./coremark/coremark.h
\ No newline at end of file
diff --git a/vm_atk2/vm2_atk2/sample1_vm2.c b/vm_atk2/vm2_atk2/sample1_vm2.c
index 5edcbfb..3134b43 100644
--- a/vm_atk2/vm2_atk2/sample1_vm2.c
+++ b/vm_atk2/vm2_atk2/sample1_vm2.c
@@ -556,6 +556,7 @@ uint32 time() {return TICK_TO_SEC(g_timer_cnt);}
 volatile char __ghsend_heap[HEAPSIZE*2];
 volatile char* __ghsbegin_heap = &__ghsend_heap[HEAPSIZE*2-1];
 #endif
+#include "coremark.h"
 volatile uint8 shared_memory[16][16];
 volatile uint8 result_array[4][17];
 extern void dhrystone_main(void);
@@ -733,6 +734,11 @@ void ms_sleep(ms){
 	end = TICK_TO_MSEC(g_timer_cnt) + ms;
 	while(end > TICK_TO_MSEC(g_timer_cnt));
 }
+void sec_sleep(sec){
+	volatile uint32 end;
+	end = TICK_TO_SEC(g_timer_cnt) + sec;
+	while(end > TICK_TO_SEC(g_timer_cnt));
+}
 TASK(Task3)
 {
 	uint32 wait_cnt = 0;
@@ -743,6 +749,10 @@ TASK(Task3)
 
 	ms_sleep(100);
 
+	coremark_main();
+
+	sec_sleep(60);
+
 	while (1) {
 		ms_sleep(1000);
 		syslog(LOG_INFO, "g_timer_cnt = %u", g_timer_cnt);
-- 
2.34.1

