#!/usr/bin/env bash set -euo pipefail mode="${1:?usage: run_one.sh hip|fastpt-C [device]}" device="${2:-${DEVICE:-0}}" script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(cd "${script_dir}/.." && pwd)" out_dir="${OUT_ROOT:-${root}/results}/${mode}" build_dir="${root}/build-${mode}" source_dtk="${root}/../source_dtk_library_path.sh" if [[ -f "${source_dtk}" ]]; then # shellcheck disable=SC1091 source "${source_dtk}" fi if [[ "${mode}" == "fastpt-C" ]]; then set +u # shellcheck disable=SC1091 source /usr/local/bin/fastpt -C >/dev/null set -u elif [[ "${mode}" != "hip" ]]; then echo "usage: run_one.sh hip|fastpt-C [device]" >&2 exit 2 fi if [[ ! -x "${build_dir}/bin/device_query" || ! -f "${build_dir}/lib/libguard_ext.so" ]]; then bash "${script_dir}/build.sh" "${mode}" fi mkdir -p "${out_dir}" "${build_dir}/bin/device_query" \ "${device}" \ "${DEVICE_QUERY_LOOPS:-1000000}" \ "${DEVICE_QUERY_ROUNDS:-7}" \ "${DEVICE_QUERY_WARMUP:-10000}" \ > "${out_dir}/device_query.csv" python3 "${script_dir}/bench_guard.py" \ --device "${device}" \ --lib "${build_dir}/lib/libguard_ext.so" \ --inner-loops "${GUARD_INNER_LOOPS:-0,1,2,4,8,16,32,64}" \ --steps "${GUARD_STEPS:-10000}" \ --warmup "${GUARD_WARMUP:-1000}" \ --rounds "${GUARD_ROUNDS:-5}" \ > "${out_dir}/guard_loop.csv" echo "RUN_DONE,${mode},${out_dir}"