Skip to content

Commit

Permalink
added vagrant stuff for experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
dpzmick committed Mar 21, 2016
1 parent d969641 commit 43f97ba
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 35 deletions.
10 changes: 3 additions & 7 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
# vi: set ft=ruby :

# creates n of each machine type
cores = [1,2,4,8]
cores = [1,2,4]
how_many = 4

boxes = []

starting_port = 9000
cores.each do |dcores|
for n in 1..how_many
box = {
:name => "cores" + dcores.to_s + "n" + n.to_s,
:port => starting_port + n + dcores * 100,
:mem => "1024",
:mem => "2048",
:cpu => dcores.to_s
}

Expand All @@ -24,7 +22,7 @@ end
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.provision "shell", path: "build_machine.sh"
config.vm.provision "shell", path: "build_machine.sh", privileged: false

boxes.each do |opts|
config.vm.define opts[:name] do |config|
Expand All @@ -34,8 +32,6 @@ Vagrant.configure(2) do |config|
v.customize ["modifyvm", :id, "--memory", opts[:mem]]
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
end

config.vm.network "forwarded_port", guest: 22, host: opts[:port], id: "ssh"
end
end
end
14 changes: 9 additions & 5 deletions build_machine.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
#!/bin/bash

# roughly what needs to happen to set up a new machine
sudo apt-get install git -y
# sudo apt-get install vim -y

# get java
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u74-b02/jdk-8u74-linux-x64.tar.gz -nv

tar xzf jdk-8u74-linux-x64.tar.gz
rm jdk-8u74-linux-x64.tar.gz

echo "export JAVA_HOME=~/jdk1.8.0_74" >> /home/vagrant/.bashrc
echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /home/vagrant/.bashrc
echo "export JAVA_HOME=~/jdk1.8.0_74" > ~/.bashrc
echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> ~/.bashrc

# get lein
mkdir bin
cd bin
wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -nv
chmod +x lein
echo "export PATH=~/bin:\$PATH" >> /home/vagrant/.bashrc
echo "export PATH=~/bin:\$PATH" >> ~/.bashrc
echo "export LEIN_ROOT=1" >> ~/.bashrc

# get the code
cd /home/vagrant
apt-get install git -y
cd
git clone https://github.com/dpzmick/auto_parallel.git
63 changes: 41 additions & 22 deletions run_remote.sh
Original file line number Diff line number Diff line change
@@ -1,47 +1,66 @@
#!/bin/bash

# wrapper around run suite that runs the suite remotely

display_usage() {
echo -e "usage $0 host auto_parallel_local num_cpus local_out specs"
echo -e "usage $0 num_cpus num_boxes local_out specs"
echo -e "where"
echo -e "\thost - remote host"
echo -e "\tauto_parallel_local - directory with auto parallel code locally"
echo -e "\tnum_cpus - number of cpus to use remotely"
echo -e "\tnum_cpus - number of cpus in each vm"
echo -e "\tnum_boxes - number of vms to create"
echo -e "\tlocal_out - local directory to put output in"
echo -e "\tspecs - specs to run, relative to the auto_parallel root on the remote"
}

# configs
ssh_config_file=/tmp/vagrant-ssh-cfg
auto_parallel_dir_local=.
auto_parallel_dir_remote=/home/vagrant/auto_parallel

if [ $# -lt 4 ]
then
display_usage
exit 1
fi

host=$1
auto_parallel_dir_local=$2
auto_parallel_dir_remote=/root/auto_parallel
num_cpus=$3
local_output_dir=$4
num_cpus=$1
num_boxes=$2
local_out=$3

# idk
tmp=( "$@" )
specs=( "${tmp[@]:3}" )
specs=$(echo "${specs[*]}")

echo $specs
# bring up all the vms
# save the hosts to the config file one at a time
for n in `seq 1 $num_boxes` ; do
host="cores"$num_cpus"n"$n
vagrant up $host
vagrant ssh-config $host >> $ssh_config_file
done

# run the benchmarks,
for n in `seq 1 $num_boxes` ; do
host="cores"$num_cpus"n"$n
( echo cd $auto_parallel_dir_remote ; echo git pull ; rm -rf out ; \
echo ./run_suite.sh out $specs) | \
{ ssh -F $ssh_config_file $host 2>&1 | sed "s/^/$host==>/" ; } &
done
wait

echo "pushing directory" $auto_parallel_dir_local
# copy the results into the local directory
for n in `seq 1 $num_boxes` ; do
host="cores"$num_cpus"n"$n
mkdir -p $local_out/$host
scp -F $ssh_config_file -r $host:$auto_parallel_dir_remote/out $local_out/$host
done

# copy a dir to run something
rsync -a $auto_parallel_dir_local root@$host:$(dirname $auto_parallel_dir_remote)
# shut down all the vms
# for n in `seq 1 $num_boxes` ; do
# host="cores"$num_cpus"n"$n
# vagrant halt $host
# done

ssh root@$host auto_parallel_dir_remote=$auto_parallel_dir_remote num_cpus=$num_cpus specs=\"$specs\" 'bash -s' <<'ENDSSH'
cd $auto_parallel_dir_remote
./run_suite.sh $num_cpus out $specs
ENDSSH

echo "pulling directory" $auto_parallel_dir_remote/out
# echo "pulling directory" $auto_parallel_dir_remote/out

# copy an output dir back
rsync -a root@$host:$auto_parallel_dir_remote/out .
# # copy an output dir back
# rsync -a root@$host:$auto_parallel_dir_remote/out .
5 changes: 4 additions & 1 deletion run_suite.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# TODO log cpu usage
# TODO log git commit hash

display_usage() {
echo -e "usage $0 output_dir specs_to_run"
echo -e "where"
Expand All @@ -20,7 +23,7 @@ source ./env
set +a

output_dir=$1
output_dir=$output_dir/$(date +"%s")
output_dir=$output_dir/$(date +"%s")-$(hostname)
log_file=$output_dir/log

tmp=( "$@" )
Expand Down

0 comments on commit 43f97ba

Please sign in to comment.