I’m not on gentoo. I’m on a debian image 69 sdcard /boot with a fedora 38 rootfs on my nvme as /.
I haven’t upgraded to the newer march debian image/firmware.
I did a dnf upgrade this morning.
As mentioned here: Safe CFLAGS - Gentoo Wiki
davidm@fc38-rv64-vf2-YOW 2023-03-16_06:15:21_EDT : ~
$ gcc -v -E -x c /dev/null -o /dev/null -march=native 2>&1 | grep /cc1 | grep mtune
davidm@fc38-rv64-vf2-YOW 2023-03-16_06:17:27_EDT : ~
That gave me nothing.
Yeah so I imagine the rv64 stuff for fedora 38 gcc 13 is tuned to hifive unmatched.
davidm@fc38-rv64-vf2-YOW 2023-03-16_06:19:03_EDT : ~
$ gcc -v -E -x c /dev/null -o /dev/null
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
Target: riscv64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.0.1-20230215/obj-riscv64-redhat-linux/isl-install --with-arch=rv64gc --with-abi=lp64d --with-multilib-list=lp64d --build=riscv64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.1 20230215 (Red Hat 13.0.1-0) (GCC)
COLLECT_GCC_OPTIONS='-v' '-E' '-o' '/dev/null' '-march=rv64imafdc_zicsr_zifencei' '-mabi=lp64d' '-misa-spec=20191213' '-march=rv64imafdc_zicsr_zifencei'
/usr/libexec/gcc/riscv64-redhat-linux/13/cc1 -E -quiet -v /dev/null -o /dev/null -march=rv64imafdc_zicsr_zifencei -mabi=lp64d -misa-spec=20191213 -march=rv64imafdc_zicsr_zifencei -dumpbase null
ignoring nonexistent directory "/usr/lib/gcc/riscv64-redhat-linux/13/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/riscv64-redhat-linux/13/../../../../riscv64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/riscv64-redhat-linux/13/include
/usr/local/include
/usr/include
End of search list.
COMPILER_PATH=/usr/libexec/gcc/riscv64-redhat-linux/13/:/usr/libexec/gcc/riscv64-redhat-linux/13/:/usr/libexec/gcc/riscv64-redhat-linux/:/usr/lib/gcc/riscv64-redhat-linux/13/:/usr/lib/gcc/riscv64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/riscv64-redhat-linux/13/:/lib64/lp64d/../lib64/lp64d/:/usr/lib64/lp64d/../lib64/lp64d/:/lib/../lib64/lp64d/:/usr/lib/../lib64/lp64d/:/lib64/lp64d/:/usr/lib64/lp64d/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-E' '-o' '/dev/null' '-march=rv64imafdc_zicsr_zifencei' '-mabi=lp64d' '-misa-spec=20191213' '-march=rv64imafdc_zicsr_zifencei'
davidm@fc38-rv64-vf2-YOW 2023-03-16_06:19:17_EDT : ~
$
I added this to my .bashrc this morning:
COMMON_FLAGS="-O3 -pipe -fomit-frame-pointer"
OPT_FLAGS="--param l1-cache-size=32 --param l2-cache-size=2048"
CFLAGS="-mabi=lp64d -march=rv64imafdc_zicsr_zba_zbb -mcpu=sifive-u74 -mtune=sifive-7-series ${COMMON_FLAGS} ${OPT_FLAGS}"
CXXFLAGS="-mabi=lp64d -march=rv64imafdc_zicsr_zba_zbb -mcpu=sifive-u74 -mtune=sifive-7-series ${COMMON_FLAGS} ${OPT_FLAGS}"
export PS1="\u@\h \D{%F_%T_%Z} : \w\n $ "
git clone https://github.com/sifive/benchmark-dhrystone.git
cd benchmark-dhrystone/
emacs -nw --color=no Makefile
I uncommented this line: benchmark-dhrystone/Makefile at master · sifive/benchmark-dhrystone · GitHub
Here are my results:
$ time ./dhrystone
Dhrystone Benchmark, Version 2.1 (Language: C)
Program compiled without 'register' attribute
Execution starts, 20000000 runs through Dhrystone
Execution ends
Final values of the variables used in the benchmark:
Int_Glob: 5
should be: 5
Bool_Glob: 1
should be: 1
Ch_1_Glob: A
should be: A
Ch_2_Glob: B
should be: B
Arr_1_Glob[8]: 7
should be: 7
Arr_2_Glob[8][7]: 20000010
should be: Number_Of_Runs + 10
Ptr_Glob->
Ptr_Comp: 94880
should be: (implementation-dependent)
Discr: 0
should be: 0
Enum_Comp: 2
should be: 2
Int_Comp: 17
should be: 17
Str_Comp: DHRYSTONE PROGRAM, SOME STRING
should be: DHRYSTONE PROGRAM, SOME STRING
Next_Ptr_Glob->
Ptr_Comp: 94880
should be: (implementation-dependent), same as above
Discr: 0
should be: 0
Enum_Comp: 1
should be: 1
Int_Comp: 18
should be: 18
Str_Comp: DHRYSTONE PROGRAM, SOME STRING
should be: DHRYSTONE PROGRAM, SOME STRING
Int_1_Loc: 5
should be: 5
Int_2_Loc: 13
should be: 13
Int_3_Loc: 7
should be: 7
Enum_Loc: 1
should be: 1
Str_1_Loc: DHRYSTONE PROGRAM, 1'ST STRING
should be: DHRYSTONE PROGRAM, 1'ST STRING
Str_2_Loc: DHRYSTONE PROGRAM, 2'ND STRING
should be: DHRYSTONE PROGRAM, 2'ND STRING
Microseconds for one run through Dhrystone: 0
Dhrystones per Second: 10000000
real 0m2.451s
user 0m2.439s
sys 0m0.011s
Yes, it would be preferrable to see these kinds of benchmark tools become a package within the default vf2 debian repo and possibly within the fedora 38 vf2 repos if such a thing will ever exist.