From: Christopher Celio Date: Thu, 10 Oct 2013 22:07:05 +0000 (-0700) Subject: Merge branch 'master' of github.com:ucb-bar/riscv-tests X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=995c0da477a875a3c47ae1839e76ae45e803c940;hp=57f2254feaf4e3595a5b6cce48ebcfbebaaa3c67;p=riscv-tests.git Merge branch 'master' of github.com:ucb-bar/riscv-tests --- diff --git a/benchmarks/common/crt.S b/benchmarks/common/crt.S index ac5d9ba..563360a 100644 --- a/benchmarks/common/crt.S +++ b/benchmarks/common/crt.S @@ -44,6 +44,11 @@ _start: li x30,0 li x31,0 +#ifdef __riscv64 + setpcr status, SR_S64 + setpcr status, SR_U64 +#endif + # enable fp setpcr status, SR_EF @@ -89,12 +94,43 @@ _start: fmv.s.x f31,x0 1: + lui a0, %hi(trap_entry) + add a0, a0, %lo(trap_entry) + mtpcr a0, evec + + lui a0, %hi(main) + add a0, a0, %lo(main) + mtpcr a0, epc + # only allow core 0 to proceed 1:mfpcr a0, hartid bnez a0, 1b la sp,stacktop - jal main + + # jmp to main as a user program + eret +1:b 1b + +.align 4 +.globl trap_entry +trap_entry: # only check for SYS_exit, otherwise crash out + li a3, 1337 # magic "bad things" happened error code + mfpcr a1, cause + li a2, 6 # syscall exception number + bne a1, a2, exit_error +handle_syscall: + li a1, 93 # SYS_exit number + bne v0, a1, exit_error + li a1, 1 # successful exit code + move a3, a0 + bne a3, a1, exit_error + mtpcr a1, tohost # exit successfully (tohost == 1) +1:b 1b +exit_error: + sll a3, a3, 1 + or a3, a3, 1 + mtpcr a3, tohost 1:b 1b .bss diff --git a/benchmarks/common/util.h b/benchmarks/common/util.h index 83b2b6c..79d9256 100644 --- a/benchmarks/common/util.h +++ b/benchmarks/common/util.h @@ -5,6 +5,8 @@ #ifndef __UTIL_H #define __UTIL_H +#include + #define rdcycle() ({ unsigned long _c; asm volatile ("rdcycle %0" : "=r"(_c) :: "memory"); _c; }) #define rdinstret() ({ unsigned long _c; asm volatile ("rdinstret %0" : "=r"(_c) :: "memory"); _c; }) @@ -27,6 +29,32 @@ void __attribute__((noinline)) barrier() __sync_synchronize(); } - + + + + + +void finishTest(int test_result) +{ +#if HOST_DEBUG + if ( test_result == 1 ) + printf( "*** PASSED ***\n" ); + else + printf( "*** FAILED *** (tohost = %d)\n", test_result); + exit(0); +#else + { + // perform exit syscall + asm volatile( + "move a0,%0 ;" + "li a1,0 ;" + "li a2,0 ;" + "li a3,0 ;" + "li v0,%1 ;" + "syscall" : : "r"(test_result) , "i"(SYS_exit)); + } +#endif +} + #endif //__UTIL_H diff --git a/benchmarks/dgemm/dgemm_main.c b/benchmarks/dgemm/dgemm_main.c index 72c90ef..7fd7dc2 100644 --- a/benchmarks/dgemm/dgemm_main.c +++ b/benchmarks/dgemm/dgemm_main.c @@ -2,6 +2,9 @@ // Double-precision general matrix multiplication benchmark //-------------------------------------------------------------------------- +int ncores = 1; +#include "util.h" + //-------------------------------------------------------------------------- // Macros @@ -61,20 +64,6 @@ void printArray( char name[], long n, const double arr[] ) } #endif -void finishTest( int toHostValue ) -{ -#if HOST_DEBUG - if ( toHostValue == 1 ) - printf( "*** PASSED ***\n" ); - else - printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); - exit(0); -#else - asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); - while ( 1 ) { } -#endif -} - void setStats( int enable ) { #if ( !HOST_DEBUG && SET_STATS ) diff --git a/benchmarks/dhrystone/dhrystone_main.c b/benchmarks/dhrystone/dhrystone_main.c index c2a8038..93b79da 100644 --- a/benchmarks/dhrystone/dhrystone_main.c +++ b/benchmarks/dhrystone/dhrystone_main.c @@ -8,6 +8,9 @@ #include "dhrystone.h" +int ncores = 1; +#include "util.h" + //-------------------------------------------------------------------------- // Macros @@ -44,20 +47,6 @@ int __attribute__((noinline)) do_fprintf(FILE* f, const char* str, ...) } #endif -void finishTest( int toHostValue ) -{ -#if HOST_DEBUG - if ( toHostValue == 1 ) - printf( "*** PASSED ***\n" ); - else - printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); - exit(0); -#else - asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); - while ( 1 ) { } -#endif -} - void setStats( int enable ) { #if ( !HOST_DEBUG && SET_STATS ) diff --git a/benchmarks/median/median_main.c b/benchmarks/median/median_main.c index 5c435dd..0691bec 100644 --- a/benchmarks/median/median_main.c +++ b/benchmarks/median/median_main.c @@ -10,6 +10,9 @@ #include "median.h" +int ncores = 1; +#include "util.h" + //-------------------------------------------------------------------------- // Macros @@ -67,20 +70,6 @@ void printArray( char name[], int n, int arr[] ) } #endif -void finishTest( int toHostValue ) -{ -#if HOST_DEBUG - if ( toHostValue == 1 ) - printf( "*** PASSED ***\n" ); - else - printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); - exit(0); -#else - asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); - while ( 1 ) { } -#endif -} - void setStats( int enable ) { #if ( !HOST_DEBUG && SET_STATS ) diff --git a/benchmarks/multiply/multiply_main.c b/benchmarks/multiply/multiply_main.c index f2ce12b..ca359eb 100644 --- a/benchmarks/multiply/multiply_main.c +++ b/benchmarks/multiply/multiply_main.c @@ -10,6 +10,9 @@ #include "multiply.h" +int ncores = 1; +#include "util.h" + //-------------------------------------------------------------------------- // Macros @@ -76,20 +79,6 @@ void printArray( char name[], int n, int arr[] ) } #endif -void finishTest( int toHostValue ) -{ -#if HOST_DEBUG - if ( toHostValue == 1 ) - printf( "*** PASSED ***\n" ); - else - printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); - exit(0); -#else - asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); - while ( 1 ) { } -#endif -} - void setStats( int enable ) { #if ( !HOST_DEBUG && SET_STATS ) diff --git a/benchmarks/qsort/qsort_main.c b/benchmarks/qsort/qsort_main.c index 486b8fc..e61eef2 100644 --- a/benchmarks/qsort/qsort_main.c +++ b/benchmarks/qsort/qsort_main.c @@ -11,6 +11,9 @@ // processor simulator itself. You should not change anything except // the HOST_DEBUG and PREALLOCATE macros for your timing run. +int ncores = 1; +#include "util.h" + //-------------------------------------------------------------------------- // Macros @@ -83,20 +86,6 @@ void printArray( char name[], int n, int arr[] ) } #endif -void finishTest( int toHostValue ) -{ -#if HOST_DEBUG - if ( toHostValue == 1 ) - printf( "*** PASSED ***\n" ); - else - printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); - exit(0); -#else - asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); - while ( 1 ) { } -#endif -} - void setStats( int enable ) { #if ( !HOST_DEBUG && SET_STATS ) diff --git a/benchmarks/spmv/spmv_main.c b/benchmarks/spmv/spmv_main.c index afb1cf1..d765ca2 100644 --- a/benchmarks/spmv/spmv_main.c +++ b/benchmarks/spmv/spmv_main.c @@ -2,6 +2,9 @@ // Double-precision general matrix multiplication benchmark //-------------------------------------------------------------------------- +int ncores = 1; +#include "util.h" + //-------------------------------------------------------------------------- // Macros @@ -61,20 +64,6 @@ void printArray( char name[], long n, const double arr[] ) } #endif -void finishTest( int toHostValue ) -{ -#if HOST_DEBUG - if ( toHostValue == 1 ) - printf( "*** PASSED ***\n" ); - else - printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); - exit(0); -#else - asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); - while ( 1 ) { } -#endif -} - void setStats( int enable ) { #if ( !HOST_DEBUG && SET_STATS ) diff --git a/benchmarks/towers/towers_main.c b/benchmarks/towers/towers_main.c index aa61665..724b73b 100644 --- a/benchmarks/towers/towers_main.c +++ b/benchmarks/towers/towers_main.c @@ -16,6 +16,9 @@ // smips processor simulator itself. You should not change anything except // the HOST_DEBUG and PREALLOCATE macros for your timing run. +int ncores = 1; +#include "util.h" + //-------------------------------------------------------------------------- // Macros @@ -50,20 +53,6 @@ //-------------------------------------------------------------------------- // Helper functions -void finishTest( int toHostValue ) -{ -#if HOST_DEBUG - if ( toHostValue == 1 ) - printf( "*** PASSED ***\n" ); - else - printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); - exit(0); -#else - asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); - while ( 1 ) { } -#endif -} - void setStats( int enable ) { #if ( !HOST_DEBUG && SET_STATS ) diff --git a/benchmarks/vvadd/vvadd_main.c b/benchmarks/vvadd/vvadd_main.c index 70b3f75..0be3051 100644 --- a/benchmarks/vvadd/vvadd_main.c +++ b/benchmarks/vvadd/vvadd_main.c @@ -10,7 +10,10 @@ // not on the smips processor simulator itself. You should not change // anything except the HOST_DEBUG and PREALLOCATE macros for your timing // runs. - + +int ncores = 1; +#include "util.h" + //-------------------------------------------------------------------------- // Macros @@ -68,19 +71,19 @@ void printArray( char name[], int n, int arr[] ) } #endif -void finishTest( int toHostValue ) -{ -#if HOST_DEBUG - if ( toHostValue == 1 ) - printf( "*** PASSED ***\n" ); - else - printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); - exit(0); -#else - asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); - while ( 1 ) { } -#endif -} +//void finishTest( int toHostValue ) +//{ +//#if HOST_DEBUG +// if ( toHostValue == 1 ) +// printf( "*** PASSED ***\n" ); +// else +// printf( "*** FAILED *** (tohost = %d)\n", toHostValue ); +// exit(0); +//#else +// asm( "mtpcr %0, tohost" : : "r" (toHostValue) ); +// while ( 1 ) { } +//#endif +//} void setStats( int enable ) {