run-experiment 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # Get the IP addresses
  3. p0addr=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' ${PRAC_DOCKER_PREFIX}prac_p0)
  4. p1addr=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' ${PRAC_DOCKER_PREFIX}prac_p1)
  5. # Gather options and arguments
  6. preproc=0
  7. opts=""
  8. while getopts paoC:t:ex arg; do
  9. opts+=" -${arg} ${OPTARG}"
  10. if [ "$arg" = "p" -o "$arg" = "a" ]; then
  11. preproc=1
  12. fi
  13. done
  14. shift $((OPTIND-1))
  15. # Get the number of cores usable by each party
  16. ncores_p0=1
  17. ncores_p1=1
  18. ncores_p2=1
  19. if [ "$whichexps" != "none" ]; then
  20. ncores_p0=`docker exec -i ${PRAC_DOCKER_PREFIX}prac_p0 $PRAC_NUMA_P0 nproc 2>/dev/null`
  21. ncores_p1=`docker exec -i ${PRAC_DOCKER_PREFIX}prac_p1 $PRAC_NUMA_P1 nproc 2>/dev/null`
  22. ncores_p2=`docker exec -i ${PRAC_DOCKER_PREFIX}prac_p2 $PRAC_NUMA_P2 nproc 2>/dev/null`
  23. fi
  24. targ_p0="-t ${ncores_p0}"
  25. targ_p1="-t ${ncores_p1}"
  26. targ_p2="-t ${ncores_p2}"
  27. echo ===== Running prac $opts -- $*
  28. date "+===== Start %s %F %T"
  29. # Run, saving the output
  30. savefile0=$$.p0.out
  31. savefile1=$$.p1.out
  32. savefile2=$$.p2.out
  33. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p0 bash -c "$PRAC_NUMA_P0 stdbuf -o 0 ./prac $opts $targ_p0 0 $* > $savefile0 2>&1" &
  34. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p1 bash -c "$PRAC_NUMA_P1 stdbuf -o 0 ./prac $opts $targ_p1 1 $p0addr $* > $savefile1 2>&1" &
  35. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p2 bash -c "$PRAC_NUMA_P2 stdbuf -o 0 ./prac $opts $targ_p2 2 $p0addr $p1addr $* > $savefile2 2>&1" &
  36. wait
  37. echo ===== P0 output
  38. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p0 cat $savefile0
  39. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p0 rm -f $savefile0
  40. echo ===== P1 output
  41. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p1 cat $savefile1
  42. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p1 rm -f $savefile1
  43. echo ===== P2 output
  44. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p2 cat $savefile2
  45. docker exec -w /root/prac ${PRAC_DOCKER_PREFIX}prac_p2 rm -f $savefile2
  46. date "+===== End %s %F %T"