diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2017-01-26 11:39:05 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2017-01-26 11:46:58 +0000 |
commit | 135336810120cb9ee70626b6c1d7f6e0638ebdb0 (patch) | |
tree | 59d4f19a7aa9257580ae3d6db563800321817f10 | |
parent | a2f0643e8d64a0c035c1fb55682118809004c057 (diff) |
Add rsync+ssh+flock method of remote compilation and make it default
--build sshfs://builder:port/scale corresponds to previous
sshfs-based or nfs-based method.
--build rsync://builder:port/scale (or just "--build builder")
corresponds to new method, which does not need any prior setup.
Change-Id: I24f5823212d721294eb317e2833e4aa33a5dc300
-rw-r--r-- | README | 10 | ||||
-rwxr-xr-x | spec2xxx-config | 117 |
2 files changed, 104 insertions, 23 deletions
@@ -18,17 +18,17 @@ quickly (i.e., use ssh connection multiplexing). Target requirements: - bash, tar, xz, pxz, other common utilities -- ssh client and server (if using cross-compilation) +- ssh client, rsync (if using cross-compilation) - sysroot with core libraries (if using cross-compilation against custom sysroot) - If using profiling support: Linux perf, cpufrequtils. For a 1-core system use "--bind 0 --helpercpu 0". +- [optional] cpufrequtils to fix cores' frequency. Builder requirements (if using cross-compilation): - bash, tar, xz, pxz, other common utilities -- ssh client and server -- sshfs +- ssh server, rsync - target compiler -- same user as on target; or, at least, access to same path as target's path to SPEC. +- ability to access mirror paths of target's installation of benchmarks. Typical usage: @@ -36,7 +36,7 @@ Typical usage: # Install SPEC CPU2006 $ ./spec2xxx-install -d $HOME/$(hostname)/cpu2006 ~/tmp/cpu2006-1.2-linaro.tar.xz # Generate config file from cpu2xxx.cfg and cpu2006.cfg templates -$ ./spec2xxx-config --config my-bmk-task --build builder.ssh --ccprefix $HOME/abe/builds/destdir/x86_64-unknown-linux-gnu/bin/aarch64-linux-gnu- --ccflags "-static --sysroot=$HOME/abe/sysroots/aarch64-linux-gnu" --bind 1 --helpercpu 0 --profiler perf --save-temps $HOME/$(hostname)/cpu2006 +$ ./spec2xxx-config --config my-bmk-task --build my-x86_64-box --ccprefix $HOME/abe/builds/destdir/x86_64-unknown-linux-gnu/bin/aarch64-linux-gnu- --ccflags "-static --sysroot=$HOME/abe/sysroots/aarch64-linux-gnu" --bind 1 --helpercpu 0 --profiler perf --save-temps $HOME/$(hostname)/cpu2006 # Examine that $HOME/$(hostname)/cpu2006/config/my-bmk-task.cfg is to your liking # Run SPEC for your config, use "-O3 -g" for optimization options. $ (cd $HOME/$(hostname)/cpu2006; . shrc; runspec -c my-bmk-task -e O3g -a run) diff --git a/spec2xxx-config b/spec2xxx-config index 5fd368b..c9c3259 100755 --- a/spec2xxx-config +++ b/spec2xxx-config @@ -48,35 +48,116 @@ if [ $# -gt 0 ]; then fi if [ x"$build" != x"" ]; then - build_scale="$(echo $build | sed -e "s#.*/##")" - if [ x"$build_scale" = x"$build" ]; then - build_scale="1" - else - build="$(echo $build | sed -e "s#/.*##")" + # [<type>://]<host>[:<port>][/<scale>] + + build_type="$(echo $build | sed -e "s#://.*##g")" + build_host="$(echo $build | sed -e "s#.*://##g" -e "s#:.*##g" -e "s#/.*##g")" + build_port="$(echo $build | sed -e "s#.*:##g" -e "s#/.*##g")" + build_scale="$(echo $build | sed -e "s#.*/##g")" + + if [ x"$build_type" = x"" ]; then build_type="rsync"; fi + if [ x"$build_host" = x"" ]; then + echo "ERROR: wrong --build: $build" + exit 1 fi + if [ x"$build_port" != x"" ]; then build_port="-p $build_port"; fi + if [ x"$build_scale" = x"" ]; then build_scale="1"; fi - for cc in gcc g++ gfortran; do - cat > $spec/bin/ssh-$config-$cc <<EOF -#!/bin/sh + if [ x"$build_type" = x"rsync" ]; then + lock=$spec/bin/ssh-$config.lock + count=$spec/bin/ssh-$config.lockcnt + rm -f $lock $count + + for cc in gcc g++ gfortran; do + cat > $spec/bin/ssh-$config-$cc <<EOF +#!/bin/bash + +set -e cmd=\$(echo "\$@" | sed -e 's#"#\\"#g' -e "s#'#\\'#g") -exec ssh $build "cd \$(pwd); exec $cc_prefix$cc \$cmd" +dir=\$(pwd) + +if echo \$dir | grep -q $spec/benchspec; then + lock=$lock + count=$count + + ( + flock -x 123 + + touch \$count + n=\$(cat \$count) + if [ x"\$n" = x"" ]; then n="0"; fi + + if [ x"\$n" = x"0" ]; then + rsync -e "ssh $build_port $build_host" --rsync-path "mkdir -p \$dir; rsync" -az --delete \$dir/ $build:\$dir/ + fi + + n=\$((\$n+1)) + echo \$n > \$count + ) 123>\$lock + + flock -s \$lock ssh $build_port $build_host "cd \$(pwd); exec $cc_prefix$cc \$cmd" | cat + res=\${PIPESTATUS[0]} + + ( + flock -x 123 + + n=\$(cat \$count) + if ! [ \$n -gt 0 ]; then exit 1; fi + + n=\$((\$n-1)) + echo \$n > \$count + + if [ x"\$n" = x"0" ]; then + rsync -e "ssh $build_port $build_host" -az --delete $build:\$dir/ \$dir/ + fi + ) 123>\$lock +else + ssh $build_port $build_host "cd \$(pwd); exec $cc_prefix$cc \$cmd" | cat + res=\${PIPESTATUS[0]} +fi + +exit \$res EOF - chmod +x $spec/bin/ssh-$config-$cc - done - cc_prefix="$spec/bin/ssh-$config-" + chmod +x $spec/bin/ssh-$config-$cc + done - cat > $spec/bin/ssh-$config-tar <<EOF + cat > $spec/bin/ssh-$config-tar <<EOF #!/bin/sh -exec ssh $build "cd \$(pwd); exec tar \$@" +set -e + +dir=\$(pwd) +rsync -e "ssh $build_port $build_host" --rsync-path "mkdir -p \$dir; rsync" -az --delete \$dir/ $build:\$dir/ +exec ssh $build_port $build_host "cd \$dir; exec tar \$@" EOF - chmod +x $spec/bin/ssh-$config-tar - tar_prog=$spec/bin/ssh-$config-tar + chmod +x $spec/bin/ssh-$config-tar + elif [ x"$build_type" = x"sshfs" ]; then + for cc in gcc g++ gfortran; do + cat > $spec/bin/ssh-$config-$cc <<EOF +#!/bin/sh + +cmd=\$(echo "\$@" | sed -e 's#"#\\"#g' -e "s#'#\\'#g") +exec ssh $build_port $build_host "cd \$(pwd); exec $cc_prefix$cc \$cmd" +EOF + done + cat > $spec/bin/ssh-$config-tar <<EOF +#!/bin/sh - ssh -fN -o ControlPersist=yes $build +exec ssh $build_port $build_host "cd \$(pwd); exec tar \$@" +EOF + else + echo "ERROR: Wrong --build type: $build_type" + exit 1 + fi + for cc in gcc g++ gfortran tar; do + chmod +x $spec/bin/ssh-$config-$cc + done + cc_prefix="$spec/bin/ssh-$config-" + tar_prog=$spec/bin/ssh-$config-tar + ssh -fN -o ControlPersist=yes $build_port $build_host - parallelize="$(ssh $build getconf _NPROCESSORS_ONLN)" + parallelize="$(ssh $build_port $build_host getconf _NPROCESSORS_ONLN)" parallelize="$(echo "scale=0; ($parallelize * $build_scale) / 1" | bc)" if [ "$parallelize" -gt "20" ]; then # Default configuration of ssh servers limit number of incoming |