#!/bin/bash # Returns a board name and cpu given a board type and benchmark name. # For instance: # $ bmk-to-board-cpu.sh --boardtype tk1 473.astar # tcwg-bmk-tk1-02 2 # indicates that if one wants to execute "473.astar" on a tk1 board, # one should use tcwg-bmk-tk1-02 cpu 2 # # cpu 0 is reserved for system tasks set -eu rundir=`pwd -P` mydir="$(dirname $0)" cd "${mydir}" mydir="$(pwd)" cd ${rundir} # Load benchmark/board table . ${mydir}/board-bmk-map.sh bench= boardtype= boardno= usage() { echo "Usage: $0 --boardtype board bench" exit 1 } while [ $# -ge 1 ] do case $1 in --boardtype) boardtype=$2 shift ;; *) if [ x"$bench" != x ]; then usage fi bench=$1 ;; esac shift done [ x"$bench" = x ] && usage [ x"$boardtype" = x ] && usage for board_cpu in ${!bmks[*]} do # We only parse indexes of the form boardno_cpuno case ${board_cpu} in *_[0-9]*) echo ${bmks[${board_cpu}]} | grep -q ${bench} && boardno=$(echo ${board_cpu%%_[0-9]*}) && cpu=$(echo ${board_cpu%%_[0-9]*}) ;; *) ;; esac done if [ x"$boardno" = x ]; then echo "Error: couldn't find a board to run $bench" exit 1 fi if [ x"$cpu" = x ]; then echo "Error: couldn't find a cpu to run $bench" exit 1 fi # Assume boards are numbered using 2 digits board=tcwg-bmk-${boardtype}-$(printf '%02d' $boardno) echo $board $cpu exit 0