[1] | 1 | #! /bin/bash |
---|
| 2 | |
---|
| 3 | #-------------------------------------------------------------------- |
---|
| 4 | # File : tsar-sim.sh |
---|
| 5 | # Author : Ghassan Almaless |
---|
| 6 | # Contact : ghassan.almaless@lip6.fr |
---|
| 7 | # Copyright : UPMC/LIP6 |
---|
| 8 | # Version : 1.2 |
---|
| 9 | # Date : 2010/11/07 (YYYY/MM/DD) |
---|
| 10 | #-------------------------------------------------------------------- |
---|
| 11 | # This script is released under the GNU public license version 2 |
---|
| 12 | #-------------------------------------------------------------------- |
---|
| 13 | # Description : |
---|
| 14 | # - This script will generate TSAR hardware description, |
---|
| 15 | # compile it to BIB binary format and than it will start |
---|
| 16 | # TSAR simulator. |
---|
| 17 | # |
---|
| 18 | # - The following arguments can be passed to this script (order is not relevant) |
---|
| 19 | # -xmax: number of clusters in a row |
---|
| 20 | # -ymax: number of clusters in a column |
---|
| 21 | # -nproc: number of CPUs per Cluster |
---|
| 22 | # -xfb: frameBuffer's X-length |
---|
| 23 | # -yfb: frameBuffer's Y-length |
---|
| 24 | # -bscpu: BootStrap CPU (0 to xmax*ymax*nproc-1) |
---|
| 25 | # -memsz: per cluster memory size in bytes. |
---|
| 26 | # -o: output file name |
---|
| 27 | # -g: generate TSAR hardware description, dont call the simulator. |
---|
| 28 | # Default values are (in order) 2 2 4 XX 0x800000 "arch-info.bin" |
---|
| 29 | #-------------------------------------------------------------------- |
---|
| 30 | |
---|
| 31 | if [ -z "$ALMOS_TOP" ] |
---|
| 32 | then |
---|
| 33 | echo "Error: ALMOS_TOP environment variable is missing" |
---|
| 34 | exit 1 |
---|
| 35 | fi |
---|
| 36 | |
---|
| 37 | xmax=2 |
---|
| 38 | ymax=2 |
---|
| 39 | ncpu=4 |
---|
| 40 | xfb=512 |
---|
| 41 | yfb=512 |
---|
| 42 | memsz=0xC00000 |
---|
| 43 | bscpu= # let gen-arch-info choose for us # |
---|
| 44 | output="arch-info.bin" |
---|
| 45 | noSim="false" |
---|
| 46 | |
---|
| 47 | usage() |
---|
| 48 | { |
---|
| 49 | echo "The following arguments can be passed to this script (order is not relevant)" |
---|
| 50 | echo " -xmax: number of clusters in a row" |
---|
| 51 | echo " -ymax: number of clusters in a column" |
---|
| 52 | echo " -nproc: number of CPUs per Cluster" |
---|
| 53 | echo " -xfb: frameBuffer's X-length" |
---|
| 54 | echo " -yfb: frameBuffer's Y-length" |
---|
| 55 | echo " -bscpu: BootStrap CPU (0 to xmax*ymax*nproc-1)" |
---|
| 56 | echo " -memsz: per cluster memory size in bytes" |
---|
| 57 | echo " -o: output file name" |
---|
| 58 | echo " -g: generate TSAR hardware description, dont call the simulator" |
---|
| 59 | echo "" |
---|
| 60 | echo "Default values are (in order) $xmax $ymax $ncpu $xfb $yfb $bscpu $memsz $output" |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | while [ $# -gt 0 ] |
---|
| 64 | do |
---|
| 65 | case "$1" in |
---|
| 66 | -xmax) xmax=$2; shift;; |
---|
| 67 | -ymax) ymax=$2; shift;; |
---|
| 68 | -nproc) ncpu=$2; shift;; |
---|
| 69 | -xfb) xfb=$2; shift;; |
---|
| 70 | -yfb) yfb=$2; shift;; |
---|
| 71 | -o) output="$2"; shift;; |
---|
| 72 | -bscpu) bscpu=$2; shift;; |
---|
| 73 | -memsz) memsz=$2; shift;; |
---|
| 74 | -g) noSim="true";; |
---|
| 75 | -*) echo "$0: error - unrecognized option $1" 1>&2; usage 1>&2; exit 1;; |
---|
| 76 | *) echo "unexpected option/argument $1" 1>&2; usage 1>$2; exit 2;; |
---|
| 77 | esac |
---|
| 78 | shift |
---|
| 79 | done |
---|
| 80 | |
---|
| 81 | memsz=$(printf "%d" $memsz) |
---|
| 82 | GEN_ARCH_INFO="$ALMOS_TOP/scripts/arch_info_gen.sh" |
---|
| 83 | INFO2BIB="$ALMOS_TOP/tools/bin/info2bib" |
---|
| 84 | SIM="$ALMOS_TOP/platform/bin/tsar-sim.x" |
---|
| 85 | INFO_FILE="/tmp/tsar-${xmax}${ymax}${ncpu}_${xfb}x${yfb}.info" |
---|
| 86 | |
---|
| 87 | error_arch_info() |
---|
| 88 | { |
---|
| 89 | echo "Cannot generate platform description, command faild or $GEN_ARCH_INFO is not in your PATH" |
---|
| 90 | exit 2 |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | error_info2bib() |
---|
| 94 | { |
---|
| 95 | echo "Cannot compile platform description to BIB binary format, command faild or $INFO2BIB is not in your PATH" |
---|
| 96 | exit 3 |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | error_sim() |
---|
| 100 | { |
---|
| 101 | echo "Cannot launch the simulator, command faild or $SIM is not in your PATH" |
---|
| 102 | exit 4 |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | $GEN_ARCH_INFO $memsz $xmax $ymax $ncpu $bscpu > $INFO_FILE || error_arch_info |
---|
| 106 | $INFO2BIB -i $INFO_FILE -o $output || error_info2bib |
---|
| 107 | |
---|
| 108 | if [ $noSim = "false" ]; then |
---|
| 109 | $SIM -XMAX $xmax -YMAX $ymax -NPROCS $ncpu -XFB $xfb -YFB $yfb -MEMSZ $memsz || error_sim |
---|
| 110 | fi |
---|
| 111 | |
---|
| 112 | #-------------------------------------------------------------------------------# |
---|
| 113 | # End of script # |
---|
| 114 | #-------------------------------------------------------------------------------# |
---|