common 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env bash
  2. common_abspath() (
  3. echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
  4. )
  5. common_bench_cmd() (
  6. # Benchmark a command.
  7. #
  8. # $1: command to benchmark
  9. # $2: where to append write results to. Default: /dev/null.
  10. #
  11. # Result format:
  12. #
  13. # cmd <command run>
  14. # time <time in seconds to finish>
  15. # exit_status <exit status>
  16. cmd="$1"
  17. results_file="${2:-/dev/null}"
  18. printf 'cmd ' >> "$results_file"
  19. env time --append -f 'time %e' --output="$results_file" "${root_dir}/eeval" -a "$cmd" "$results_file"
  20. printf "exit_status $?\n" >> "$results_file"
  21. )
  22. set_common_vars() {
  23. arch="$1"
  24. gem5="${2:-false}"
  25. common_suffix="${3:-}"
  26. buildroot_dir="${root_dir}/buildroot"
  27. arch_dir="$arch"
  28. if [ -n "$common_suffix" ]; then
  29. arch_dir="${arch_dir}-${common_suffix}"
  30. fi
  31. out_arch_dir="${out_dir}/${arch_dir}"
  32. buildroot_out_dir="${out_arch_dir}/buildroot"
  33. build_dir="${buildroot_out_dir}/build"
  34. images_dir="${buildroot_out_dir}/images"
  35. host_dir="${buildroot_out_dir}/host"
  36. gem5_out_dir="${out_arch_dir}/gem5"
  37. m5out_dir="${gem5_out_dir}/m5out"
  38. qemu_out_dir="${out_arch_dir}/qemu"
  39. if "$gem5"; then
  40. common_out_run_dir="$gem5_out_dir"
  41. common_trace_txt_file="${common_out_run_dir}/m5out/trace.txt"
  42. else
  43. common_out_run_dir="$qemu_out_dir"
  44. common_trace_txt_file="${common_out_run_dir}/trace.txt"
  45. fi
  46. }
  47. root_dir="$(pwd)"
  48. out_dir="${root_dir}/out"
  49. common_bench_boot="${out_dir}/bench-boot.txt"
  50. data_dir="${root_dir}/data"
  51. p9_dir="${data_dir}/9p"
  52. readfile_file="${data_dir}/readfile"
  53. common_dir="${out_dir}/common"
  54. f="${data_dir}/cli"
  55. if [ -f "$f" ]; then
  56. . "$f"
  57. fi
  58. # Default arch.
  59. arch=x86_64
  60. gem5=false