Compare commits

..

No commits in common. "f99db9409f88f7c59b783ac10cdbaae7f5960ed4" and "339d6b0f2c4c457a1d054cc9d8db89d2e6b2c7b0" have entirely different histories.

13 changed files with 710 additions and 962 deletions

@ -1 +1 @@
Subproject commit 6e2a7a12fe59238fca0a807cee68f3a4a2678c5c
Subproject commit f21ea46befe7401cc35205d3b64e3991504b6289

View File

@ -1,31 +0,0 @@
cmake_minimum_required(VERSION 3.21)
project(coremark C)
set(TARGET coremark)
set(CMAKE_BUILD_TYPE Release)
# Source files
set(SOURCES
core_portme.c
cvt.c
ee_printf.c
cm/core_list_join.c
cm/core_main.c
cm/core_matrix.c
cm/core_state.c
cm/core_util.c
)
# Create executable
add_executable(coremark ${SOURCES})
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/cm)
target_compile_options(${TARGET} PRIVATE -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -fno-builtin-strnlen -fno-common -funroll-loops -finline-functions -falign-functions=16 -falign-jumps=4 -falign-loops=4 -finline-limit=1000 -fno-if-conversion2 -fselective-scheduling -fno-crossjumping -freorder-blocks-and-partition -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -fno-common -funroll-loops -finline-functions -falign-functions=16 -falign-jumps=4 -falign-loops=4 -finline-limit=1000 -fno-if-conversion2 -fselective-scheduling -fno-crossjumping -freorder-blocks-and-partition )
target_compile_definitions(${TARGET} PRIVATE PERFORMANCE_RUN=1 CLOCKS_PER_SEC=10000000 FLAGS_STR="" PERFORMANCE_RUN=1 CLOCKS_PER_SEC=10000000 ITERATIONS=600)
set(BOARD "iss" CACHE STRING "Target board")
add_subdirectory(../../bare-metal-bsp bsp)
target_link_libraries(${TARGET} PRIVATE bsp)
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
COMMENT "Creating disassembly for ${TARGET}")

View File

@ -1,109 +0,0 @@
{
"version": 3,
"vendor": {
"conan": {}
},
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "ISS_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "Moonlight_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "TGC_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "ISS_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "Moonlight_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "TGC_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "ISS_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "Moonlight_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "TGC_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "ISS_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "Moonlight_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "TGC_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
}
]
}

View File

@ -15,58 +15,55 @@ limitations under the License.
Original Author: Shay Gal-on
*/
#include "core_portme.h"
#include "coremark.h"
#include <unistd.h>
// Read cycle CSR
unsigned long long _read_cycle() {
unsigned long long result;
unsigned long lower;
unsigned long upper1;
unsigned long upper2;
#include "core_portme.h"
//Read cycle CSR
unsigned long long _read_cycle()
{
unsigned long long result;
unsigned long lower;
unsigned long upper1;
unsigned long upper2;
asm volatile("repeat_cycle_%=: csrr %0, cycleh;\n"
" csrr %1, cycle;\n"
" csrr %2, cycleh;\n"
" bne %0, %2, repeat_cycle_%=;\n"
: "=r"(upper1), "=r"(lower),
"=r"(upper2) // Outputs : temp variable for load result
:
:);
*(unsigned long *)(&result) = lower;
*((unsigned long *)(&result) + 1) = upper1;
asm volatile (
"repeat_cycle_%=: csrr %0, cycleh;\n"
" csrr %1, cycle;\n"
" csrr %2, cycleh;\n"
" bne %0, %2, repeat_cycle_%=;\n"
: "=r" (upper1),"=r" (lower),"=r" (upper2) // Outputs : temp variable for load result
:
:
);
*(unsigned long *)(&result) = lower;
*((unsigned long *)(&result)+1) = upper1;
return result;
return result;
}
// extern volatile int tohost;
// extern volatile int fromhost;
volatile int tohost;
volatile int fromhost;
void write_hex(int fd, uint32_t hex);
void exit(int n) {
write_hex(STDERR_FILENO, 1);
// tohost = 0x1;
for (;;)
;
void exit(int n){
tohost = 0x1;
for (;;);
}
void __libc_init_array(void) {
/*
size_t count;
size_t i;
count = __preinit_array_end - __preinit_array_start;
for (i = 0; i < count; i++)
__preinit_array_start[i] ();
void __libc_init_array (void) {
/*
size_t count;
size_t i;
count = __preinit_array_end - __preinit_array_start;
for (i = 0; i < count; i++)
__preinit_array_start[i] ();
#ifdef HAVE_INIT_FINI
_init ();
#endif
#ifdef HAVE_INIT_FINI
_init ();
#endif
count = __init_array_end - __init_array_start;
for (i = 0; i < count; i++)
__init_array_start[i] ();
*/
count = __init_array_end - __init_array_start;
for (i = 0; i < count; i++)
__init_array_start[i] ();
*/
}
#if VALIDATION_RUN
volatile ee_s32 seed1_volatile = 0x3415;
@ -92,7 +89,10 @@ volatile ee_s32 seed5_volatile = 0;
time.h and windows.h definitions included.
*/
CORETIMETYPE
barebones_clock() { return (CORETIMETYPE)_read_cycle(); }
barebones_clock()
{
return (CORETIMETYPE)_read_cycle();
}
/* Define : TIMER_RES_DIVIDER
Divider to trade off timer resolution and total time that can be
measured.
@ -101,11 +101,11 @@ barebones_clock() { return (CORETIMETYPE)_read_cycle(); }
does not occur. If there are issues with the return value overflowing,
increase this value.
*/
#define GETMYTIME(_t) (*_t = barebones_clock())
#define MYTIMEDIFF(fin, ini) ((fin) - (ini))
#define TIMER_RES_DIVIDER 1
#define GETMYTIME(_t) (*_t = barebones_clock())
#define MYTIMEDIFF(fin, ini) ((fin) - (ini))
#define TIMER_RES_DIVIDER 1
#define SAMPLE_TIME_IMPLEMENTATION 1
#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
/** Define Host specific (POSIX), or target specific global time variables. */
static CORETIMETYPE start_time_val, stop_time_val;
@ -118,7 +118,11 @@ static CORETIMETYPE start_time_val, stop_time_val;
example code) or zeroing some system parameters - e.g. setting the cpu clocks
cycles to 0.
*/
void start_time(void) { GETMYTIME(&start_time_val); }
void
start_time(void)
{
GETMYTIME(&start_time_val);
}
/* Function : stop_time
This function will be called right after ending the timed portion of the
benchmark.
@ -127,7 +131,11 @@ void start_time(void) { GETMYTIME(&start_time_val); }
example code) or other system parameters - e.g. reading the current value of
cpu cycles counter.
*/
void stop_time(void) { GETMYTIME(&stop_time_val); }
void
stop_time(void)
{
GETMYTIME(&stop_time_val);
}
/* Function : get_time
Return an abstract "ticks" number that signifies time on the system.
@ -138,9 +146,11 @@ void stop_time(void) { GETMYTIME(&stop_time_val); }
controlled by <TIMER_RES_DIVIDER>
*/
CORE_TICKS
get_time(void) {
CORE_TICKS elapsed = (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
return elapsed;
get_time(void)
{
CORE_TICKS elapsed
= (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
return elapsed;
}
/* Function : time_in_secs
Convert the value returned by get_time to seconds.
@ -149,9 +159,11 @@ get_time(void) {
floating point. Default implementation implemented by the EE_TICKS_PER_SEC
macro above.
*/
secs_ret time_in_secs(CORE_TICKS ticks) {
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
return retval;
secs_ret
time_in_secs(CORE_TICKS ticks)
{
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
return retval;
}
ee_u32 default_num_contexts = 1;
@ -160,18 +172,27 @@ ee_u32 default_num_contexts = 1;
Target specific initialization code
Test for some common mistakes.
*/
void portable_init(core_portable *p, int *argc, char *argv[]) {
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
ee_printf("ERROR! Please define ee_ptr_int to a type that holds a "
"pointer!\n");
}
if (sizeof(ee_u32) != 4) {
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
}
p->portable_id = 1;
ee_printf("portable_init finished.\n");
void
portable_init(core_portable *p, int *argc, char *argv[])
{
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *))
{
ee_printf(
"ERROR! Please define ee_ptr_int to a type that holds a "
"pointer!\n");
}
if (sizeof(ee_u32) != 4)
{
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
}
p->portable_id = 1;
ee_printf("portable_init finished.\n");
}
/* Function : portable_fini
Target specific final code
*/
void portable_fini(core_portable *p) { p->portable_id = 0; }
void
portable_fini(core_portable *p)
{
p->portable_id = 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,2 @@
dhrystone
/dhrystone.dis
build/

View File

@ -1,19 +0,0 @@
cmake_minimum_required(VERSION 3.21)
project(dhrystone C)
set(TARGET dhrystone)
set(ITERATIONS 50000)
add_executable(${TARGET} dhry_1.c dhry_2.c dhry_stubs.c)
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_compile_options(${TARGET} PRIVATE -fno-inline -fno-builtin-printf -fno-common -Wno-implicit -funroll-loops -fpeel-loops -fgcse-sm -fgcse-las)
target_compile_definitions(${TARGET} PRIVATE ITERATIONS=${ITERATIONS} HZ=32768 TIME NO_INIT)
set(BOARD "iss" CACHE STRING "Target board")
add_subdirectory(../../bare-metal-bsp bsp)
target_link_libraries(${TARGET} PRIVATE bsp)
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
COMMENT "Creating disassembly for ${TARGET}")

View File

@ -1,109 +0,0 @@
{
"version": 3,
"vendor": {
"conan": {}
},
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "ISS_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "Moonlight_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "TGC_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "ISS_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "Moonlight_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "TGC_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "ISS_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "Moonlight_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "TGC_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "ISS_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "Moonlight_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "TGC_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
}
]
}

View File

@ -1,5 +1,4 @@
#include "platform.h"
#include <unistd.h>
#ifndef ITERATIONS
#define ITERATIONS 20000
#endif
@ -7,16 +6,20 @@
/* The functions in this file are only meant to support Dhrystone on an
* embedded RV32 system and are obviously incorrect in general. */
long time(void) { return get_timer_value(); }
long time(void)
{
return get_timer_value();
}
// set the number of dhrystone iterations
void __wrap_scanf(const char *fmt, int *n) { *n = ITERATIONS; }
// extern volatile uint64_t tohost;
void exit(int n) {
// tohost = 0x1;
write_hex(STDERR_FILENO, 1);
for (;;)
;
void __wrap_scanf(const char* fmt, int* n)
{
*n = ITERATIONS;
}
extern volatile uint32_t tohost;
void exit(int n){
tohost = 0x1;
for (;;);
}

View File

@ -1,3 +1,2 @@
/hello
/hello.dis
build/

View File

@ -1,13 +0,0 @@
cmake_minimum_required(VERSION 3.21)
project(hello-world C)
set(TARGET hello)
add_executable(${TARGET} hello.c)
set(BOARD "iss" CACHE STRING "Target board")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../bare-metal-bsp bsp)
target_link_libraries(${TARGET} PRIVATE bsp)
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
COMMENT "Creating disassembly for ${TARGET}")

View File

@ -1,109 +0,0 @@
{
"version": 3,
"vendor": {
"conan": {}
},
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "ISS_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "Moonlight_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "TGC_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "ISS_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "Moonlight_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "TGC_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "ISS_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "Moonlight_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "TGC_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "ISS_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "Moonlight_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "TGC_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
}
]
}

View File

@ -1,21 +1,24 @@
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include "platform.h"
#include <string.h>
#include "encoding.h"
int factorial(int i){
volatile int result = 1;
for (int ii = 1; ii <= i; ii++) {
result = result * ii;
}
return result;
int factorial(int i) {
volatile int result = 1;
for (int ii = 1; ii <= i; ii++) {
result = result * ii;
}
return result;
}
int main() {
int result = factorial(10);
printf("Factorial is %d", result);
return 0;
int main()
{
volatile int result = factorial (10);
printf("Factorial is %d\n", result);
printf("End of execution");
return 0;
}