diff options
author | Andrew Waterman <andrew@sifive.com> | 2017-03-21 17:04:49 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2017-03-21 17:04:49 -0700 |
commit | 9fbc573597c8087ab0aa8e20d8835cfc2c5097a4 (patch) | |
tree | 469c6767566934c0e723dd269e611447bdea65a8 | |
parent | d2bd84a096a97ff4b8f41035c984991d0df922c1 (diff) | |
download | riscv-tests-9fbc573597c8087ab0aa8e20d8835cfc2c5097a4.zip riscv-tests-9fbc573597c8087ab0aa8e20d8835cfc2c5097a4.tar.gz riscv-tests-9fbc573597c8087ab0aa8e20d8835cfc2c5097a4.tar.bz2 |
Remove smips/host-debugging cruft
-rw-r--r-- | benchmarks/Makefile | 32 | ||||
-rw-r--r-- | benchmarks/common/util.h | 50 | ||||
-rw-r--r-- | benchmarks/dhrystone/dhrystone_main.c | 50 | ||||
-rw-r--r-- | benchmarks/median/median_main.c | 10 | ||||
-rw-r--r-- | benchmarks/mt-matmul/mt-matmul.c | 9 | ||||
-rw-r--r-- | benchmarks/mt-vvadd/mt-vvadd.c | 11 | ||||
-rw-r--r-- | benchmarks/multiply/multiply_main.c | 11 | ||||
-rw-r--r-- | benchmarks/qsort/qsort_main.c | 20 | ||||
-rw-r--r-- | benchmarks/readme.txt | 7 | ||||
-rw-r--r-- | benchmarks/rsort/rsort.c | 11 | ||||
-rw-r--r-- | benchmarks/towers/towers_main.c | 60 | ||||
-rw-r--r-- | benchmarks/vvadd/vvadd_main.c | 14 |
12 files changed, 9 insertions, 276 deletions
diff --git a/benchmarks/Makefile b/benchmarks/Makefile index 531d981..15509d0 100644 --- a/benchmarks/Makefile +++ b/benchmarks/Makefile @@ -30,24 +30,10 @@ bmarks = \ mt-vvadd \ mt-matmul \ -bmarks_host = \ - median \ - qsort \ - towers \ - vvadd \ - multiply \ - spmv \ - vec-vvadd \ - vec-cmplxmult \ - vec-matmul \ - #-------------------------------------------------------------------- # Build rules #-------------------------------------------------------------------- -HOST_OPTS = -std=gnu99 -DPREALLOCATE=0 -DHOST_DEBUG=1 -HOST_COMP = gcc $(HOST_OPTS) - RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf- RISCV_GCC ?= $(RISCV_PREFIX)gcc RISCV_GCC_OPTS ?= -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf @@ -72,7 +58,7 @@ bmarks_riscv_bin = $(addsuffix .riscv, $(bmarks)) bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks)) bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks)) -bmarks_defs = -DPREALLOCATE=1 -DHOST_DEBUG=0 +bmarks_defs = -DPREALLOCATE=1 bmarks_cycles = 80000 $(bmarks_riscv_dump): %.riscv.dump: %.riscv @@ -97,22 +83,6 @@ run-riscv: $(bmarks_riscv_out) junk += $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(bmarks_riscv_hex) $(bmarks_riscv_out) #------------------------------------------------------------ -# Build and run benchmarks on host machine - -bmarks_host_bin = $(addsuffix .host, $(bmarks_host)) -bmarks_host_out = $(addsuffix .host.out, $(bmarks_host)) - -$(bmarks_host_out): %.host.out: %.host - ./$< > $@ - -host: $(bmarks_host_bin) -run-host: $(bmarks_host_out) - echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \ - $(bmarks_host_out); echo; - -junk += $(bmarks_host_bin) $(bmarks_host_out) - -#------------------------------------------------------------ # Default all: riscv diff --git a/benchmarks/common/util.h b/benchmarks/common/util.h index 22f81cf..a3e2e8c 100644 --- a/benchmarks/common/util.h +++ b/benchmarks/common/util.h @@ -3,62 +3,12 @@ #ifndef __UTIL_H #define __UTIL_H -//-------------------------------------------------------------------------- -// Macros - -// Set HOST_DEBUG to 1 if you are going to compile this for a host -// machine (ie Athena/Linux) for debug purposes and set HOST_DEBUG -// to 0 if you are compiling with the smips-gcc toolchain. - -#ifndef HOST_DEBUG -#define HOST_DEBUG 0 -#endif - -// Set PREALLOCATE to 1 if you want to preallocate the benchmark -// function before starting stats. If you have instruction/data -// caches and you don't want to count the overhead of misses, then -// you will need to use preallocation. - -#ifndef PREALLOCATE -#define PREALLOCATE 0 -#endif - -// Set SET_STATS to 1 if you want to carve out the piece that actually -// does the computation. - -#if HOST_DEBUG -#include <stdio.h> -static void setStats(int enable) {} -#else extern void setStats(int enable); -#endif #include <stdint.h> #define static_assert(cond) switch(0) { case 0: case !!(long)(cond): ; } -static void printArray(const char name[], int n, const int arr[]) -{ -#if HOST_DEBUG - int i; - printf( " %10s :", name ); - for ( i = 0; i < n; i++ ) - printf( " %3d ", arr[i] ); - printf( "\n" ); -#endif -} - -static void printDoubleArray(const char name[], int n, const double arr[]) -{ -#if HOST_DEBUG - int i; - printf( " %10s :", name ); - for ( i = 0; i < n; i++ ) - printf( " %g ", arr[i] ); - printf( "\n" ); -#endif -} - static int verify(int n, const volatile int* test, const int* verify) { int i; diff --git a/benchmarks/dhrystone/dhrystone_main.c b/benchmarks/dhrystone/dhrystone_main.c index 492270a..9c7bcf5 100644 --- a/benchmarks/dhrystone/dhrystone_main.c +++ b/benchmarks/dhrystone/dhrystone_main.c @@ -5,45 +5,13 @@ //-------------------------------------------------------------------------- // // This is the classic Dhrystone synthetic integer benchmark. -// You should not change anything except the HOST_DEBUG and -// PREALLOCATE macros for your timing run. +// #pragma GCC optimize ("no-inline") #include "dhrystone.h" -//-------------------------------------------------------------------------- -// Macros - -// Set HOST_DEBUG to 1 if you are going to compile this for a host -// machine (ie Athena/Linux) for debug purposes and set HOST_DEBUG -// to 0 if you are compiling with the smips-gcc toolchain. - -#ifndef HOST_DEBUG -#define HOST_DEBUG 0 -#endif - -// Set PREALLOCATE to 1 if you want to preallocate the benchmark -// function before starting stats. If you have instruction/data -// caches and you don't want to count the overhead of misses, then -// you will need to use preallocation. - -#ifndef PREALLOCATE -#define PREALLOCATE 0 -#endif - -// Set SET_STATS to 1 if you want to carve out the piece that actually -// does the computation. - -#ifndef SET_STATS -#define SET_STATS 0 -#endif - -#if HOST_DEBUG -# define debug_printf printf -#else void debug_printf(const char* str, ...); -#endif #include "util.h" @@ -101,21 +69,7 @@ int main (int argc, char** argv) REG int Number_Of_Runs; /* Arguments */ -#if HOST_DEBUG - if (argc > 2) - { - printf("Usage: %s [number of loops]\n", argv[0]); - exit (1); - } - if (argc == 2) - { - Number_Of_Runs = atoi (argv[1]); - } - else if (Number_Of_Runs <= 0) -#endif - { - Number_Of_Runs = NUMBER_OF_RUNS; - } + Number_Of_Runs = NUMBER_OF_RUNS; /* Initializations */ diff --git a/benchmarks/median/median_main.c b/benchmarks/median/median_main.c index c7fd6a6..b62ecd1 100644 --- a/benchmarks/median/median_main.c +++ b/benchmarks/median/median_main.c @@ -7,8 +7,7 @@ // This benchmark performs a 1D three element median filter. The // input data (and reference data) should be generated using the // median_gendata.pl perl script and dumped to a file named -// dataset1.h You should not change anything except the -// HOST_DEBUG and PREALLOCATE macros for your timing run. +// dataset1.h. #include "util.h" @@ -26,10 +25,6 @@ int main( int argc, char* argv[] ) { int results_data[DATA_SIZE]; - // Output the input array - printArray( "input", DATA_SIZE, input_data ); - printArray( "verify", DATA_SIZE, verify_data ); - #if PREALLOCATE // If needed we preallocate everything in the caches median( DATA_SIZE, input_data, results_data ); @@ -40,9 +35,6 @@ int main( int argc, char* argv[] ) median( DATA_SIZE, input_data, results_data ); setStats(0); - // Print out the results - printArray( "results", DATA_SIZE, results_data ); - // Check the results return verify( DATA_SIZE, results_data, verify_data ); } diff --git a/benchmarks/mt-matmul/mt-matmul.c b/benchmarks/mt-matmul/mt-matmul.c index 9c68ada..dbb7562 100644 --- a/benchmarks/mt-matmul/mt-matmul.c +++ b/benchmarks/mt-matmul/mt-matmul.c @@ -12,10 +12,6 @@ // using the matmul_gendata.pl perl script and dumped to a file named // dataset.h. - -// print out arrays, etc. -//#define DEBUG - //-------------------------------------------------------------------------- // Includes @@ -57,10 +53,5 @@ void thread_entry(int cid, int nc) int res = verify(ARRAY_SIZE, results_data, verify_data); -#ifdef DEBUG - printArray("results:", ARRAY_SIZE, results_data); - printArray("verify :", ARRAY_SIZE, verify_data); -#endif - exit(res); } diff --git a/benchmarks/mt-vvadd/mt-vvadd.c b/benchmarks/mt-vvadd/mt-vvadd.c index 8709166..54c9602 100644 --- a/benchmarks/mt-vvadd/mt-vvadd.c +++ b/benchmarks/mt-vvadd/mt-vvadd.c @@ -12,9 +12,6 @@ // generated using the vvadd_gendata.pl perl script and dumped // to a file named dataset.h -// to print out arrays, etc. -//#define DEBUG - //-------------------------------------------------------------------------- // Includes @@ -57,10 +54,6 @@ void thread_entry(int cid, int nc) stats(vvadd(cid, nc, DATA_SIZE, input1_data, input2_data, results_data); barrier(nc), DATA_SIZE); if(cid == 0) { -#ifdef DEBUG - printDoubleArray("out-of-place results: ", DATA_SIZE, results_data); - printDoubleArray("out-of-place verify : ", DATA_SIZE, verify_data); -#endif int res = verifyDouble(DATA_SIZE, results_data, verify_data); if(res) exit(res); } @@ -76,10 +69,6 @@ void thread_entry(int cid, int nc) stats(vvadd(cid, nc, DATA_SIZE, results_data, input2_data, results_data); barrier(nc), DATA_SIZE); if(cid == 0) { -#ifdef DEBUG - printDoubleArray("in-place results: ", DATA_SIZE, results_data); - printDoubleArray("in-place verify : ", DATA_SIZE, verify_data); -#endif int res = verifyDouble(DATA_SIZE, results_data, verify_data); if(res) exit(res); } diff --git a/benchmarks/multiply/multiply_main.c b/benchmarks/multiply/multiply_main.c index aed3e0d..ea225eb 100644 --- a/benchmarks/multiply/multiply_main.c +++ b/benchmarks/multiply/multiply_main.c @@ -7,8 +7,7 @@ // This benchmark tests the software multiply implemenation. The // input data (and reference data) should be generated using the // multiply_gendata.pl perl script and dumped to a file named -// dataset1.h You should not change anything except the -// HOST_DEBUG and VERIFY macros for your timing run. +// dataset1.h #include "util.h" @@ -27,11 +26,6 @@ int main( int argc, char* argv[] ) int i; int results_data[DATA_SIZE]; - // Output the input arrays - printArray( "input1", DATA_SIZE, input_data1 ); - printArray( "input2", DATA_SIZE, input_data2 ); - printArray( "verify", DATA_SIZE, verify_data ); - #if PREALLOCATE for (i = 0; i < DATA_SIZE; i++) { @@ -45,9 +39,6 @@ int main( int argc, char* argv[] ) results_data[i] = multiply( input_data1[i], input_data2[i] ); } setStats(0); - - // Print out the results - printArray( "results", DATA_SIZE, results_data ); // Check the results return verify( DATA_SIZE, results_data, verify_data ); diff --git a/benchmarks/qsort/qsort_main.c b/benchmarks/qsort/qsort_main.c index e962e82..18adc25 100644 --- a/benchmarks/qsort/qsort_main.c +++ b/benchmarks/qsort/qsort_main.c @@ -8,10 +8,7 @@ // implementation is largely adapted from Numerical Recipes for C. The // input data (and reference data) should be generated using the // qsort_gendata.pl perl script and dumped to a file named -// dataset1.h The smips-gcc toolchain does not support system calls -// so printf's can only be used on a host system, not on the smips -// processor simulator itself. You should not change anything except -// the HOST_DEBUG and PREALLOCATE macros for your timing run. +// dataset1.h. #include "util.h" #include <string.h> @@ -76,10 +73,6 @@ void sort(size_t n, type arr[]) for (;;) { -#if HOST_DEBUG - printArray( "", n, arr ); -#endif - // Insertion sort when subarray small enough. if ( ir-l < INSERTION_THRESHOLD ) { @@ -122,10 +115,6 @@ void sort(size_t n, type arr[]) // Push pointers to larger subarray on stack, // process smaller subarray immediately. -#if HOST_DEBUG - assert(stackp < stack+NSTACK); -#endif - if ( ir-i+1 >= j-l ) { stackp[0] = ir; @@ -147,10 +136,6 @@ void sort(size_t n, type arr[]) int main( int argc, char* argv[] ) { - // Output the input array - printArray( "input", DATA_SIZE, input_data ); - printArray( "verify", DATA_SIZE, verify_data ); - #if PREALLOCATE // If needed we preallocate everything in the caches sort(DATA_SIZE, verify_data); @@ -163,9 +148,6 @@ int main( int argc, char* argv[] ) sort( DATA_SIZE, input_data ); setStats(0); - // Print out the results - printArray( "test", DATA_SIZE, input_data ); - // Check the results return verify( DATA_SIZE, input_data, verify_data ); } diff --git a/benchmarks/readme.txt b/benchmarks/readme.txt index a14780f..d90fe2d 100644 --- a/benchmarks/readme.txt +++ b/benchmarks/readme.txt @@ -37,13 +37,6 @@ points to make about the toolchain. about how to write assembly in C here: http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html - + If you look at the example benchmarks you will see that I have two - important macros HOST_DEBUG and VERIFY. Use HOST_DEBUG to compile the - benchmark on your host workstation (ie use standard gcc on Athena/Linux - box) and then debug the benchmark. Since you are using standard gcc you - can use printf's to make sure that your benchmark actually works before - trying it out on your RISCV processor. - + Debugging C compiled code on the RISCV processor is a real pain. It is hard to associate the assembly with the C code and there is no debugger. So if you encounter a bug in your processor when running a C diff --git a/benchmarks/rsort/rsort.c b/benchmarks/rsort/rsort.c index dc53642..7ffc12a 100644 --- a/benchmarks/rsort/rsort.c +++ b/benchmarks/rsort/rsort.c @@ -8,10 +8,7 @@ // implementation is largely adapted from Numerical Recipes for C. The // input data (and reference data) should be generated using the // qsort_gendata.pl perl script and dumped to a file named -// dataset1.h The smips-gcc toolchain does not support system calls -// so printf's can only be used on a host system, not on the smips -// processor simulator itself. You should not change anything except -// the HOST_DEBUG and PREALLOCATE macros for your timing run. +// dataset1.h #include "util.h" #include <string.h> @@ -107,9 +104,6 @@ void sort(size_t n, type* arrIn, type* scratchIn) int main( int argc, char* argv[] ) { static type scratch[DATA_SIZE]; - // Output the input array - printArray( "input", DATA_SIZE, input_data ); - printArray( "verify", DATA_SIZE, verify_data ); #if PREALLOCATE // If needed we preallocate everything in the caches @@ -123,9 +117,6 @@ int main( int argc, char* argv[] ) sort(DATA_SIZE, input_data, scratch); setStats(0); - // Print out the results - printArray( "test", DATA_SIZE, input_data ); - // Check the results return verify( DATA_SIZE, input_data, verify_data ); } diff --git a/benchmarks/towers/towers_main.c b/benchmarks/towers/towers_main.c index 03de47d..8c2355a 100644 --- a/benchmarks/towers/towers_main.c +++ b/benchmarks/towers/towers_main.c @@ -13,10 +13,7 @@ // disc on top of a smaller disc. // // This implementation starts with NUM_DISC discs and uses a recursive -// algorithm to sovel the puzzle. The smips-gcc toolchain does not support -// system calls so printf's can only be used on a host system, not on the -// smips processor simulator itself. You should not change anything except -// the HOST_DEBUG and PREALLOCATE macros for your timing run. +// algorithm to sovel the puzzle. #include "util.h" @@ -140,34 +137,6 @@ void towers_clear( struct Towers* this ) } -#if HOST_DEBUG -void towers_print( struct Towers* this ) -{ - struct Node* ptr; - int i, numElements; - - printf( " pegA: " ); - for ( i = 0; i < ((this->numDiscs)-list_getSize(&(this->pegA))); i++ ) - printf( ". " ); - for ( ptr = this->pegA.head; ptr != 0; ptr = ptr->next ) - printf( "%d ", ptr->val ); - - printf( " pegB: " ); - for ( i = 0; i < ((this->numDiscs)-list_getSize(&(this->pegB))); i++ ) - printf( ". " ); - for ( ptr = this->pegB.head; ptr != 0; ptr = ptr->next ) - printf( "%d ", ptr->val ); - - printf( " pegC: " ); - for ( i = 0; i < ((this->numDiscs)-list_getSize(&(this->pegC))); i++ ) - printf( ". " ); - for ( ptr = this->pegC.head; ptr != 0; ptr = ptr->next ) - printf( "%d ", ptr->val ); - - printf( "\n" ); -} -#endif - void towers_solve_h( struct Towers* this, int n, struct List* startPeg, struct List* tempPeg, @@ -176,9 +145,6 @@ void towers_solve_h( struct Towers* this, int n, int val; if ( n == 1 ) { -#if HOST_DEBUG - towers_print(this); -#endif val = list_pop(startPeg); list_push(destPeg,val); this->numMoves++; @@ -202,43 +168,25 @@ int towers_verify( struct Towers* this ) int numDiscs = 0; if ( list_getSize(&this->pegA) != 0 ) { -#if HOST_DEBUG - printf( "ERROR: Peg A is not empty!\n" ); -#endif return 2; } if ( list_getSize(&this->pegB) != 0 ) { -#if HOST_DEBUG - printf( "ERROR: Peg B is not empty!\n" ); -#endif return 3; } if ( list_getSize(&this->pegC) != this->numDiscs ) { -#if HOST_DEBUG - printf( " ERROR: Expected %d discs but found only %d discs!\n", \ - this->numDiscs, list_getSize(&this->pegC) ); -#endif return 4; } for ( ptr = this->pegC.head; ptr != 0; ptr = ptr->next ) { numDiscs++; if ( ptr->val != numDiscs ) { -#if HOST_DEBUG - printf( " ERROR: Expecting disc %d on peg C but found disc %d instead!\n", \ - numDiscs, ptr->val ); -#endif return 5; } } if ( this->numMoves != ((1 << this->numDiscs) - 1) ) { -#if HOST_DEBUG - printf( " ERROR: Expecting %d num moves but found %d instead!\n", \ - ((1 << this->numDiscs) - 1), this->numMoves ); -#endif return 6; } @@ -280,12 +228,6 @@ int main( int argc, char* argv[] ) towers_solve( &towers ); setStats(0); - // Print out the results - -#if HOST_DEBUG - towers_print( &towers ); -#endif - // Check the results return towers_verify( &towers ); } diff --git a/benchmarks/vvadd/vvadd_main.c b/benchmarks/vvadd/vvadd_main.c index 00e1593..d8ff01c 100644 --- a/benchmarks/vvadd/vvadd_main.c +++ b/benchmarks/vvadd/vvadd_main.c @@ -7,11 +7,7 @@ // This benchmark uses adds to vectors and writes the results to a // third vector. The input data (and reference data) should be // generated using the vvadd_gendata.pl perl script and dumped -// to a file named dataset1.h The smips-gcc toolchain does not -// support system calls so printf's can only be used on a host system, -// not on the smips processor simulator itself. You should not change -// anything except the HOST_DEBUG and PREALLOCATE macros for your timing -// runs. +// to a file named dataset1.h. #include "util.h" @@ -37,11 +33,6 @@ int main( int argc, char* argv[] ) { int results_data[DATA_SIZE]; - // Output the input array - printArray( "input1", DATA_SIZE, input1_data ); - printArray( "input2", DATA_SIZE, input2_data ); - printArray( "verify", DATA_SIZE, verify_data ); - #if PREALLOCATE // If needed we preallocate everything in the caches vvadd( DATA_SIZE, input1_data, input2_data, results_data ); @@ -52,9 +43,6 @@ int main( int argc, char* argv[] ) vvadd( DATA_SIZE, input1_data, input2_data, results_data ); setStats(0); - // Print out the results - printArray( "results", DATA_SIZE, results_data ); - // Check the results return verify( DATA_SIZE, results_data, verify_data ); } |