build_xlcz.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. ZCF="_zcf"
  22. if [[ "$CORE" == *"x"* ]] ; then
  23. ZCF=""
  24. fi
  25. echo "text data bss dec filename cminscnt xlczinscnt valonqemu valonrtl"
  26. for ext in "" _xxlczbitop _xxlcz_nobitop _xxlcz _zca_zcb${ZCF}_zcmp_zcmt _zca_zcb${ZCF}_zcmp_zcmt_xxlcz ; do
  27. archext=${BASEEXT}$ext
  28. runarchext=$archext
  29. toelf=${TOLOC}/${CASE}_${CORE}${archext}_${DATE}_sim.elf
  30. makeopts=""
  31. if [[ "$ext" == *"_nobitop"* ]] ; then
  32. makeopts="APP_COMMON_FLAGS=\"-DNO_EXTRACTU\""
  33. archext=${archext/_nobitop/}
  34. fi
  35. if [[ "$ext" == *"bitop"* ]] ; then
  36. runarchext=${archext/bitop/}
  37. fi
  38. #echo "Build for ${CORE}${archext} -> $toelf"
  39. outstr=$(make CORE=$CORE ARCH_EXT=$archext $makeopts SIMULATION=1 SILENT=1 clean all | tail -n1)
  40. read -a parts <<< "$outstr"
  41. szstr="${parts[@]:0:4}"
  42. outstr=$(timeout --foreground ${TIMEOUT} make CORE=$CORE ARCH_EXT=$runarchext SIMULATION=1 SILENT=1 run_qemu 2>&1 | grep "CSV" | tail -n1)
  43. read -a parts <<< "$outstr"
  44. benchval=${parts[-1]}
  45. command cp -f ${CASE}.elf $toelf
  46. xlczinscnt=$(riscv64-unknown-elf-objdump -d -M no-aliases $toelf | grep -e "xl\." | wc -l)
  47. cminscnt=$(riscv64-unknown-elf-objdump -d -M no-aliases $toelf | grep -e "[c|cm]\." | wc -l)
  48. echo "$szstr $toelf $cminscnt $xlczinscnt $benchval"
  49. done