Browse Source

Have run_experiment use the right number of cores for each party

It uses the $PRAC_NUMA_P{0,1,2} variables to run nproc in each
container, and adds a "p:$nproc" or "-t $nproc" argument to each command
line (the choice depending on whether we're preprocessing or not).
Ian Goldberg 1 year ago
parent
commit
29e85669b3
1 changed files with 34 additions and 3 deletions
  1. 34 3
      docker/run-experiment

+ 34 - 3
docker/run-experiment

@@ -5,12 +5,43 @@ p0addr=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' prac_p0)
 p1addr=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' prac_p1)
 
 # Gather options and arguments
+preproc=0
 opts=""
 while getopts paot:ex arg; do
     opts+=" -${arg} ${OPTARG}"
+    if [ "$arg" = "p" ]; then
+        preproc=1
+    fi
 done
 shift $((OPTIND-1))
 
+# Get the number of cores usable by each party
+ncores_p0=1
+ncores_p1=1
+ncores_p2=1
+if [ "$whichexps" != "none" ]; then
+    ncores_p0=`docker exec -i prac_p0 $PRAC_NUMA_P0 nproc 2>/dev/null`
+    ncores_p1=`docker exec -i prac_p1 $PRAC_NUMA_P1 nproc 2>/dev/null`
+    ncores_p2=`docker exec -i prac_p2 $PRAC_NUMA_P2 nproc 2>/dev/null`
+fi
+
+ptarg_p0=""
+ptarg_p1=""
+ptarg_p2=""
+targ_p0=""
+targ_p1=""
+targ_p2=""
+
+if [ "$preproc" = 1 ]; then
+    ptarg_p0="p:${ncores_p0}"
+    ptarg_p1="p:${ncores_p1}"
+    ptarg_p2="p:${ncores_p2}"
+else
+    targ_p0="-t ${ncores_p0}"
+    targ_p1="-t ${ncores_p1}"
+    targ_p2="-t ${ncores_p2}"
+fi
+
 echo ===== Running prac $opts -- $*
 date "+===== Start %s %F %T"
 
@@ -18,9 +49,9 @@ date "+===== Start %s %F %T"
 savefile0=$$.p0.out
 savefile1=$$.p1.out
 savefile2=$$.p2.out
-docker exec -w /root/prac prac_p0 bash -c "$PRAC_NUMA_P0 stdbuf -o 0 ./prac $opts 0 $* > $savefile0 2>&1" &
-docker exec -w /root/prac prac_p1 bash -c "$PRAC_NUMA_P1 stdbuf -o 0 ./prac $opts 1 $p0addr $* > $savefile1 2>&1" &
-docker exec -w /root/prac prac_p2 bash -c "$PRAC_NUMA_P2 stdbuf -o 0 ./prac $opts 2 $p0addr $p1addr $* > $savefile2 2>&1" &
+docker exec -w /root/prac prac_p0 bash -c "$PRAC_NUMA_P0 stdbuf -o 0 ./prac $opts $targ_p0 0 $* $ptarg_p0 > $savefile0 2>&1" &
+docker exec -w /root/prac prac_p1 bash -c "$PRAC_NUMA_P1 stdbuf -o 0 ./prac $opts $targ_p1 1 $p0addr $* $ptarg_p1 > $savefile1 2>&1" &
+docker exec -w /root/prac prac_p2 bash -c "$PRAC_NUMA_P2 stdbuf -o 0 ./prac $opts $targ_p2 2 $p0addr $p1addr $* $ptarg_p2 > $savefile2 2>&1" &
 wait
 echo ===== P0 output
 docker exec -w /root/prac prac_p0 cat $savefile0