Skip to content

Commit

Permalink
Use clock_gettime64 directly in STREAM example
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Nov 24, 2023
1 parent b161645 commit 72cd410
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion binaries/STREAM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option(TUNED "Tuned vectorized version" OFF)

if (GCC_TRIPLE STREQUAL "riscv32-unknown-elf")
if (TUNED)
set(RISCV_ABI "-march=rv32gv_zba -mabi=ilp32d")
set(RISCV_ABI "-march=rv32gv_zba_zbb_zbc_zbs -mabi=ilp32d")
else()
set(RISCV_ABI "")
endif()
Expand Down
4 changes: 3 additions & 1 deletion binaries/STREAM/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
set -e

GCC_TRIPLE="riscv64-unknown-elf"

export CC=riscv64-unknown-linux-gnu-gcc
export CXX=riscv64-unknown-linux-gnu-g++
#GCC_TRIPLE="riscv32-unknown-elf"
#export CC=riscv32-unknown-elf-gcc
#export CXX=riscv32-unknown-elf-g++

mkdir -p build
pushd build
Expand Down
20 changes: 15 additions & 5 deletions binaries/STREAM/src/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,25 @@ checktick()
/* A gettimeofday routine to give access to the wall
clock timer on most UNIX-like systems. */

#include <sys/time.h>
#include <time.h>
static inline int clock_gettime64(int clk_id, struct timespec *tp)
{
register long a0 asm("a0") = clk_id;
register struct timespec * a1 asm("a1") = tp;
register long syscall_id asm("a7") = 403;

asm("ecall" : "+r"(a0), "=m"(*a1)
: "r"(a1), "r"(syscall_id));

return a0;
}

double mysecond()
{
struct timeval tp;
struct timezone tzp;
struct timespec ts;

(void) gettimeofday(&tp,&tzp);
return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 );
(void) clock_gettime64(1, &ts);
return ( (double) ts.tv_sec + (double) ts.tv_nsec * 1.e-9 );
}

#ifndef abs
Expand Down

0 comments on commit 72cd410

Please sign in to comment.