#!/bin/bash set -e set -x ${0%%-prepare}-check prepare host=$HOST target=$TARGET spec=$SPEC config=$CONFIG cc_prefix=$1 optimize="$2" cpuinfo=$3 if [ "$host" != "$target" ]; then local=false else local=true fi spec=$(cd $spec; pwd) $local || sshfs $target:$spec $spec for cc in gcc g++ gfortran; do cat > $spec/bin/ssh-$config-$cc < $cpuinfo fi hw_model="$(cat $cpuinfo | grep Hardware | head -n 1 | sed -e 's/.*: //')" hw_cpu="$(cat $cpuinfo | grep "model name\|Processor" | head -n 1 | sed -e 's/.*: //')" hw_fpu="$(cat $cpuinfo | grep Features | head -n 1 | sed -e 's/.*: //')" sw_os="$(ssh $target uname -r | head -n 1)" sw_compiler="$(${cc_prefix}gcc -v 2>&1 | tail -n 1)" sw_compiler="$sw_compiler $(${cc_prefix}gcc -v 2>&1 | grep 'Configured with' | head -n 1)" case "$hw_cpu" in *"v7l"*) mcpu="-mcpu=cortex-a15" ;; *"aarch64"*) mcpu="-mcpu=cortex-a57" ;; *) mcpu="" ;; esac case "$hw_fpu" in *"neon"*"vfpv4"*) mfpu="-mfpu=neon-vfpv4" ;; *) mfpu="" ;; esac arch="$(ssh $target uname -m)" case "$arch" in "aarch64"|"x86_64") spec_cpu2000_lp64="-DSPEC_CPU2000_LP64" spec_cpu_lp64="-DSPEC_CPU_LP64" ;; "armv7l"|"ia32"|*) spec_cpu2000_lp64="" spec_cpu_lp64="" ;; esac case "$arch" in "aarch64") case "$optimize" in *"cortex-a53"*) taskset_cpu="1" ;; *) taskset_cpu="4" ;; esac ;; *) taskset_cpu="1" ;; esac cfg_tmpl="$(dirname $0)/cpu2xxx.cfg" if grep CPU2000 $spec/shrc; then cfg_tmpl="$cfg_tmpl $(dirname $0)/cpu2000.cfg" iterations="3" elif grep CPU2006 $spec/shrc; then cfg_tmpl="$cfg_tmpl $(dirname $0)/cpu2006.cfg" iterations="3" fi cat $cfg_tmpl | sed \ -e "s#@HW_MODEL@#$hw_model#g" \ -e "s#@HW_CPU@#$hw_cpu#g" \ -e "s#@HW_FPU@#$hw_fpu#g" \ -e "s#@SW_OS@#$sw_os#g" \ -e "s#@SW_COMPILER@#$sw_compiler#g" \ -e "s#@PARALLELIZE@#$(getconf _NPROCESSORS_ONLN)#g" \ -e "s#@SUBMIT@#taskset -c $taskset_cpu \$command#g" \ -e "s#@ITERATIONS@#$iterations#g" \ -e "s#@ITERATIONS_2@#$(($iterations+2))#g" \ -e "s#@ITERATIONS_4@#$(($iterations+4))#g" \ -e "s#@CC@#ssh-$config-gcc#g" \ -e "s#@CXX@#ssh-$config-g++#g" \ -e "s#@FORTRAN@#ssh-$config-gfortran#g" \ -e "s#@OPTIMIZE@#$optimize#g" \ -e "s#@MCPU@#$mcpu#g" \ -e "s#@MFPU@#$mfpu#g" \ -e "s#@PROFILEDIR@#$spec#g" \ -e "s#@DSPEC_CPU2000_LP64@#$spec_cpu2000_lp64#g" \ -e "s#@DSPEC_CPU_LP64@#$spec_cpu_lp64#g" \ > $spec/config/$config.tmp if ! diff -u $spec/config/$config.tmp $spec/config/$config.cfg | head -n 8 | grep __MD5__; then mv $spec/config/$config.tmp $spec/config/$config.cfg else rm $spec/config/$config.tmp fi $local || fusermount -uz $spec