run-experiment 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 parameters
  7. #
  8. # mode is read, write, or readwrite
  9. mode=read
  10. # size is log_2 of the number of elements of the ORAM
  11. size=20
  12. # iters is the number of operations to do
  13. iters=128
  14. # phase is preproc or online
  15. phase=online
  16. # duoramtype is 3P or 2P (3-party or 2-party)
  17. duoramtype=3P
  18. # ramgb is the maximum amount of RAM to use in GB
  19. # (do not set it below 16)
  20. ramgb=16
  21. if [ "$1" != "" ]; then
  22. mode="$1"
  23. fi
  24. if [ "$2" != "" ]; then
  25. size="$2"
  26. fi
  27. if [ "$3" != "" ]; then
  28. iters="$3"
  29. fi
  30. if [ "$4" != "" ]; then
  31. phase="$4"
  32. fi
  33. if [ "$5" != "" ]; then
  34. duoramtype="$5"
  35. fi
  36. if [ "$6" != "" ]; then
  37. ramgb="$6"
  38. fi
  39. if [ "$duoramtype" = "3P" -a "$phase" = "preproc" ]; then
  40. numdpfs=$iters
  41. if [ "$mode" = "read" -o "$mode" = "write" ]; then
  42. numdpfs=$((3*iters))
  43. fi
  44. if [ "$mode" = "readwrite" ]; then
  45. numdpfs=$((6*iters))
  46. fi
  47. fi
  48. echo ===== Running duoram $mode $size $iters $phase $duoramtype $ramgb
  49. date "+===== Start %s %F %T"
  50. if [ "$4" = "online" -a "$5" = "3P" ]; then
  51. # Run, saving the output
  52. savefilep0=$$.p0.out
  53. savefilep1=$$.p1.out
  54. savefilep2=$$.p2.out
  55. docker exec -w /root/duoram/duoram-online duoram_p2 bash -c "$DUORAM_NUMA_P2 stdbuf -o 0 ./p2 $p0addr $p1addr $size $iters 0 $iters 1 > $savefilep2 2>&1" &
  56. sleep 4
  57. docker exec -w /root/duoram/duoram-online duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./duoram1 $p0addr $p2addr $size $iters 0 $iters 1 > $savefilep1 2>&1" &
  58. sleep 2
  59. docker exec -w /root/duoram/duoram-online duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./duoram0 $p1addr $p2addr $size $iters 0 $iters 1 > $savefilep0 2>&1" &
  60. wait
  61. echo ===== P0 output
  62. docker exec -w /root/duoram/duoram-online duoram_p0 cat $savefilep0
  63. docker exec -w /root/duoram/duoram-online duoram_p0 rm -f $savefilep0
  64. echo ===== P1 output
  65. docker exec -w /root/duoram/duoram-online duoram_p1 cat $savefilep1
  66. docker exec -w /root/duoram/duoram-online duoram_p1 rm -f $savefilep1
  67. echo ===== P2 output
  68. docker exec -w /root/duoram/duoram-online duoram_p2 cat $savefilep2
  69. docker exec -w /root/duoram/duoram-online duoram_p2 rm -f $savefilep2
  70. date "+===== End %s %F %T"
  71. fi
  72. if [ "$4" = "preproc" -a "$5" = "3P" ]; then
  73. # Run, saving the output
  74. savefilep0=$$.p0.out
  75. savefilep1=$$.p1.out
  76. savefilep2=$$.p2.out
  77. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p0 bash -c "rm -f *" &
  78. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p1 bash -c "rm -f *" &
  79. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p2 bash -c "rm -f *" &
  80. wait
  81. docker exec -w /root/duoram/preprocessing duoram_p2 bash -c "$DUORAM_NUMA_P2 stdbuf -o 0 ./p2preprocessing $p0addr $p1addr $numdpfs $size $ramgb > $savefilep2 2>&1" &
  82. sleep 4
  83. docker exec -w /root/duoram/preprocessing duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./preprocessing1 $p0addr $p2addr $numdpfs $size $ramgb > $savefilep1 2>&1" &
  84. sleep 2
  85. docker exec -w /root/duoram/preprocessing duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./preprocessing0 $p1addr $p2addr $numdpfs $size $ramgb > $savefilep0 2>&1" &
  86. wait
  87. echo ===== P0 output
  88. docker exec -w /root/duoram/preprocessing duoram_p0 cat $savefilep0
  89. docker exec -w /root/duoram/preprocessing duoram_p0 rm -f $savefilep0
  90. echo ===== P1 output
  91. docker exec -w /root/duoram/preprocessing duoram_p1 cat $savefilep1
  92. docker exec -w /root/duoram/preprocessing duoram_p1 rm -f $savefilep1
  93. echo ===== P2 output
  94. docker exec -w /root/duoram/preprocessing duoram_p2 cat $savefilep2
  95. docker exec -w /root/duoram/preprocessing duoram_p2 rm -f $savefilep2
  96. date "+===== End %s %F %T"
  97. fi
  98. if [ "$1" = "read" -a "$5" = "2P" ]; then
  99. # Run, saving the output
  100. savefilep0=$$.p0.out
  101. savefilep1=$$.p1.out
  102. nproc0=$(docker exec -w /root/duoram/cpir-read/cxx duoram_p0 bash -c "$DUORAM_NUMA_P0 nproc 2>/dev/null")
  103. nproc1=$(docker exec -w /root/duoram/cpir-read/cxx duoram_p1 bash -c "$DUORAM_NUMA_P1 nproc 2>/dev/null")
  104. docker exec -w /root/duoram/cpir-read/cxx duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./spir_test1 $p0addr $size $nproc1 $iters $iters > $savefilep1 2>&1" &
  105. echo "P1 launched"
  106. sleep 4
  107. docker exec -w /root/duoram/cpir-read/cxx duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./spir_test0 $p1addr $size $nproc0 $iters $iters > $savefilep0 2>&1" &
  108. echo "P0 launched"
  109. wait
  110. echo ===== P0 output
  111. docker exec -w /root/duoram/cpir-read/cxx duoram_p0 cat $savefilep0
  112. docker exec -w /root/duoram/cpir-read/cxx duoram_p0 rm -f $savefilep0
  113. echo ===== P1 output
  114. docker exec -w /root/duoram/cpir-read/cxx duoram_p1 cat $savefilep1
  115. docker exec -w /root/duoram/cpir-read/cxx duoram_p1 rm -f $savefilep1
  116. date "+===== End %s %F %T"
  117. fi
  118. if [ "$1" = "write" -a "$5" = "2P" -a "$4" = "preproc" ]; then
  119. # Run, saving the output
  120. savefilep0=$$.p0.out
  121. savefilep1=$$.p1.out
  122. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p0 bash -c "rm -f *" &
  123. docker exec -w /root/duoram/duoram-online/preprocflags duoram_p1 bash -c "rm -f *" &
  124. wait
  125. docker exec -w /root/duoram/2p-preprocessing duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./OT $p0addr $p1addr 1 $((128*iters*size)) > $savefilep1 2>&1" &
  126. echo "P1 launched"
  127. sleep 1
  128. docker exec -w /root/duoram/2p-preprocessing duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./OT $p0addr $p1addr 0 $((128*iters*size)) > $savefilep0 2>&1" &
  129. echo "P0 launched"
  130. sleep 2
  131. wait
  132. docker exec -w /root/duoram/2p-preprocessing duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./preprocessing1 $p0addr $iters $size $ramgb >> $savefilep1 2>&1" &
  133. echo "P1 launched"
  134. sleep 4
  135. docker exec -w /root/duoram/2p-preprocessing duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./preprocessing0 $p1addr $iters $size $ramgb >> $savefilep0 2>&1" &
  136. echo "P0 launched"
  137. wait
  138. echo ===== P0 output
  139. docker exec -w /root/duoram/2p-preprocessing duoram_p0 cat $savefilep0
  140. docker exec -w /root/duoram/2p-preprocessing duoram_p0 rm -f $savefilep0
  141. echo ===== P1 output
  142. docker exec -w /root/duoram/2p-preprocessing duoram_p1 cat $savefilep1
  143. docker exec -w /root/duoram/2p-preprocessing duoram_p1 rm -f $savefilep1
  144. date "+===== End %s %F %T"
  145. fi
  146. if [ "$1" = "write" -a "$5" = "2P" -a "$4" = "online" ]; then
  147. # Run, saving the output
  148. savefilep0=$$.p0.out
  149. savefilep1=$$.p1.out
  150. docker exec -w /root/duoram/duoram-online duoram_p1 bash -c "$DUORAM_NUMA_P1 stdbuf -o 0 ./2Pduoram1 $p0addr $p2addr $size $iters $iters $iters 1 > $savefilep1 2>&1" &
  151. echo "P1 launched"
  152. sleep 4
  153. docker exec -w /root/duoram/duoram-online duoram_p0 bash -c "$DUORAM_NUMA_P0 stdbuf -o 0 ./2Pduoram0 $p1addr $p2addr $size $iters $iters $iters 1 > $savefilep0 2>&1" &
  154. echo "P0 launched"
  155. wait
  156. echo ===== P0 output
  157. docker exec -w /root/duoram/duoram-online duoram_p0 cat $savefilep0
  158. docker exec -w /root/duoram/duoram-online duoram_p0 rm -f $savefilep0
  159. echo ===== P1 output
  160. docker exec -w /root/duoram/duoram-online duoram_p1 cat $savefilep1
  161. docker exec -w /root/duoram/duoram-online duoram_p1 rm -f $savefilep1
  162. date "+===== End %s %F %T"
  163. fi