run-experiment.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/bin/bash
  2. # Get the IP addresses
  3. p0addr=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' duoram_p0)
  4. p1addr=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' duoram_p1)
  5. p2addr=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' duoram_p2)
  6. # The Duoram mode and size
  7. # mode is read, write, readwrite, or init
  8. duoramtype=2P
  9. phase=online
  10. mode=read
  11. size=20
  12. iters=128
  13. modeval=0
  14. if [ "$1" != "" ]; then
  15. mode="$1"
  16. fi
  17. if [ "$2" != "" ]; then
  18. size="$2"
  19. fi
  20. if [ "$3" != "" ]; then
  21. iters="$3"
  22. fi
  23. if [ "$4" != "" ]; then
  24. phase="$4"
  25. fi
  26. if [ "$5" != "" ]; then
  27. duoramtype="$5"
  28. fi
  29. if [ "$mode" = "read" ]; then
  30. modeval="0"
  31. fi
  32. if [ "$mode" = "write" ]; then
  33. modeval="0"
  34. fi
  35. if [ "$mode" = "readwrite" ]; then
  36. modeval="1"
  37. fi
  38. items=$((1<<size))
  39. echo ===== Running duoram $mode $size $iters
  40. date "+===== Start %s %F %T"
  41. if [ "$4" = "online" -a "$5" = "3P" ]; then
  42. # Run, saving the output
  43. savefilep2=$$.p2.out
  44. savefilep0=$$.p1.out
  45. savefilep1=$$.p0.out
  46. docker exec -w /root/duoram/duoram-online duoram_p2 bash -c "$DUORAM_NUMA_P2 stdbuf -o 0 ./p2 $p0addr $p1addr $size $iters $iters $iters 1 > $savefilep2 2>&1" &
  47. sleep 4
  48. docker exec -w /root/duoram/duoram-online duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./duoram1 $p0addr $p2addr $size $iters $iters $iters 1 > $savefilep1 2>&1" &
  49. sleep 2
  50. docker exec -w /root/duoram/duoram-online duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./duoram0 $p1addr $p2addr $size $iters $iters $iters 1 > $savefilep0 2>&1" &
  51. wait
  52. echo ===== P0 output
  53. docker exec -w /root/duoram/duoram-online duoram_p0 cat $savefilep0
  54. docker exec -w /root/duoram/duoram-online duoram_p0 rm -f $savefilep0
  55. echo ===== P1 output
  56. docker exec -w /root/duoram/duoram-online duoram_p1 cat $savefilep1
  57. docker exec -w /root/duoram/duoram-online duoram_p1 rm -f $savefilep1
  58. date "+===== End %s %F %T"
  59. fi
  60. if [ "$4" = "preproc" -a "$5" = "3P" ]; then
  61. # Run, saving the output
  62. savefilep2=$$.p2.out
  63. savefilep0=$$.p1.out
  64. savefilep1=$$.p0.out
  65. docker exec -w /root/duoram/preprocessing duoram_p2 bash -c "$DUORAM_NUMA_P2 stdbuf -o 0 ./p2preprocessing $p0addr $p1addr $iters $size $modeval > $savefilep2 2>&1" &
  66. sleep 4
  67. docker exec -w /root/duoram/preprocessing duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./preprocessing1 $p0addr $p2addr $iters $size $modeval > $savefilep1 2>&1" &
  68. sleep 2
  69. docker exec -w /root/duoram/preprocessing duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./preprocessing0 $p1addr $p2addr $iters $size $modeval > $savefilep0 2>&1" &
  70. wait
  71. echo ===== P0 output
  72. docker exec -w /root/duoram/preprocessing duoram_p0 cat $savefilep0
  73. docker exec -w /root/duoram/preprocessing duoram_p0 rm -f $savefilep0
  74. echo ===== P1 output
  75. docker exec -w /root/duoram/preprocessing duoram_p1 cat $savefilep1
  76. docker exec -w /root/duoram/preprocessing duoram_p1 rm -f $savefilep1
  77. date "+===== End %s %F %T"
  78. fi
  79. if [ "$1" = "read" -a "$5" = "2P" ]; then
  80. # Run, saving the output
  81. savefilep0=$$.p1.out
  82. savefilep1=$$.p0.out
  83. docker exec -w /root/duoram/cpir-read/cxx duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./spir_test1 $p0addr $size $iters $iters $iters > $savefilep1 2>&1" &
  84. echo "P0 launched"
  85. sleep 4
  86. docker exec -w /root/duoram/cpir-read/cxx duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./spir_test0 $p1addr $size $iters $iters $iters > $savefilep0 2>&1" &
  87. echo "P1 launched"
  88. wait
  89. echo ===== P0 output
  90. docker exec -w /root/duoram/cpir-read/cxx duoram_p0 cat $savefilep0
  91. docker exec -w /root/duoram/cpir-read/cxx duoram_p0 rm -f $savefilep0
  92. echo ===== P1 output
  93. docker exec -w /root/duoram/cpir-read/cxx duoram_p1 cat $savefilep1
  94. docker exec -w /root/duoram/cpir-read/cxx duoram_p1 rm -f $savefilep1
  95. date "+===== End %s %F %T"
  96. fi
  97. if [ "$1" = "write" -a "$5" = "2P" ]; then
  98. # Run, saving the output
  99. savefilep0=$$.p1.out
  100. savefilep1=$$.p0.out
  101. docker exec -w /root/duoram/2p-preprocessing duoram_p1 ./OT $p0addr $p1addr 1 128 &
  102. echo "P1 launched"
  103. sleep 1
  104. docker exec -w /root/duoram/2p-preprocessing duoram_p0 ./OT $p0addr $p1addr 0 128 &
  105. sleep 2
  106. docker exec -w /root/duoram/2p-preprocessing duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./preprocessing1 $p0addr $size $iters > $savefilep1 2>&1" &
  107. sleep 4
  108. docker exec -w /root/duoram/2p-preprocessing duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./preprocessing0 $p1addr $size $iters > $savefilep0 2>&1" &
  109. wait
  110. echo ===== P0 output
  111. docker exec -w /root/duoram/2p-preprocessing duoram_p0 cat $savefilep0
  112. docker exec -w /root/duoram/2p-preprocessing duoram_p0 rm -f $savefilep0
  113. echo ===== P1 output
  114. docker exec -w /root/duoram/2p-preprocessing duoram_p1 cat $savefilep1
  115. docker exec -w /root/duoram/2p-preprocessing duoram_p1 rm -f $savefilep1
  116. date "+===== End %s %F %T"
  117. fi