build_xlcz.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/env bash
  2. # how to use
  3. # cd <Nuclei SDK>/application/baremetal/benchmark/coremark
  4. # /path/to/build_xlcz.sh [CORE] [BASEEXT] [TOLOC]
  5. # CORE used to run on
  6. CORE=${1:-n300f}
  7. # BASE Extension on this CORE
  8. BASEEXT=${2:-_zba_zbb_zbc_zbs}
  9. # Copy to location
  10. TOLOC=${3:-${HOME}/benchelfs/xlcz}
  11. DATE=$(date +%Y%m%d)
  12. CASE=$(basename $(pwd))
  13. # for whetstone need to pass TIMEOUT=20s /path/to/build_xlcz.sh
  14. if [ "x$CASE" = "xwhetstone" ] ; then
  15. TIMEOUT=${TIMEOUT:-20s}
  16. else
  17. TIMEOUT=${TIMEOUT:-3s}
  18. fi
  19. mkdir -p $TOLOC
  20. echo "INFO: Benchmark $CASE run on $CORE with base extension $BASEEXT, generated elfs will be copy to $TOLOC, TIMEOUT $TIMEOUT"
  21. echo "text data bss dec filename cminscnt xlczinscnt valonqemu valonrtl"
  22. for ext in "" _xxlczbitop _xxlcz_nobitop _xxlcz _zca_zcb_zcf_zcmp_zcmt _zca_zcb_zcf_zcmp_zcmt_xxlcz ; do
  23. archext=${BASEEXT}$ext
  24. runarchext=$archext
  25. toelf=${TOLOC}/${CASE}_${CORE}${archext}_${DATE}_sim.elf
  26. makeopts=""
  27. if [[ "$ext" == *"_nobitop"* ]] ; then
  28. makeopts="APP_COMMON_FLAGS=\"-DNO_EXTRACTU\""
  29. archext=${archext/_nobitop/}
  30. fi
  31. if [[ "$ext" == *"bitop"* ]] ; then
  32. runarchext=${archext/bitop/}
  33. fi
  34. #echo "Build for ${CORE}${archext} -> $toelf"
  35. outstr=$(make CORE=$CORE ARCH_EXT=$archext $makeopts SIMULATION=1 SILENT=1 clean all | tail -n1)
  36. read -a parts <<< "$outstr"
  37. szstr="${parts[@]:0:4}"
  38. outstr=$(timeout --foreground ${TIMEOUT} make CORE=$CORE ARCH_EXT=$runarchext SIMULATION=1 SILENT=1 run_qemu 2>&1 | grep "CSV" | tail -n1)
  39. read -a parts <<< "$outstr"
  40. benchval=${parts[-1]}
  41. command cp -f ${CASE}.elf $toelf
  42. xlczinscnt=$(riscv64-unknown-elf-objdump -d -M no-aliases $toelf | grep -e "xl\." | wc -l)
  43. cminscnt=$(riscv64-unknown-elf-objdump -d -M no-aliases $toelf | grep -e "[c|cm]\." | wc -l)
  44. echo "$szstr $toelf $cminscnt $xlczinscnt $benchval"
  45. done