gen_enclave_config.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/usr/bin/python3
  2. import math
  3. import sys
  4. ###############################################################################
  5. # CONFIGS TO SET:
  6. CONFIG_FILE = "Enclave/Enclave.config.xml"
  7. ###############################################################################
  8. '''
  9. Generate a manifest file with:
  10. N: number of clients
  11. M: number of servers
  12. T: number of threads for each server
  13. B: msg_size
  14. PRIVATE_ROUTE: Private (True) / Public (False) route
  15. PRO: PRivate Out
  16. PRI: PRivate In
  17. PUO: PUblic Out
  18. PUI: PUblic In
  19. num_WN_to_precompute: The default num_WN_to_precompute is 12 in App/start.cpp
  20. '''
  21. def generate_config(N, M, T, B, PRIVATE_ROUTE=True, PRO=1, PRI=1, PUO=1, PUI=1, num_WN_to_precompute=12):
  22. cf = open(CONFIG_FILE, 'w+')
  23. clients_per_server = math.ceil(N/M)
  24. # Base heap of 2 MB per thread
  25. heap_size = 2000000 * T
  26. num_buffers = 5
  27. num_out_mult = PRO
  28. if(not(PRIVATE_ROUTE)):
  29. num_out_mult = PUO
  30. # Storage and Ingestion data stored per_client = 52 bytes
  31. heap_size += clients_per_server * (B + 60)
  32. # 5 Buffers of clients_per_server items of B size each for
  33. # private routing
  34. heap_size += (clients_per_server * B * num_buffers) * num_out_mult
  35. # Additional buffers for public routing
  36. if(not(PRIVATE_ROUTE)):
  37. heap_size += (clients_per_server * B * 3) + ((M-1)**2 * B * 4)
  38. # num_WN_to_precompute times size of each WN
  39. heap_size += (num_WN_to_precompute * num_out_mult * \
  40. (clients_per_server * math.ceil(math.log(clients_per_server,2)) * 8))
  41. heap_size_page_aligned = math.ceil(heap_size/4096) * 4096
  42. hex_heap_size = hex(heap_size_page_aligned)
  43. enclave_config = '''<!-- Please refer to User's Guide for the explanation of each field -->
  44. <EnclaveConfiguration>
  45. <ProdID>0</ProdID>
  46. <ISVSVN>0</ISVSVN>
  47. <StackMaxSize>0x40000</StackMaxSize>
  48. <HeapMaxSize>{H}</HeapMaxSize>
  49. <TCSNum>32</TCSNum>
  50. <TCSPolicy>1</TCSPolicy>
  51. <DisableDebug>0</DisableDebug>
  52. <MiscSelect>0</MiscSelect>
  53. <MiscMask>0xFFFFFFFF</MiscMask>
  54. </EnclaveConfiguration>
  55. '''.format(H = str(hex_heap_size))
  56. #print (enclave_config)
  57. cf.write(enclave_config)
  58. cf.close()
  59. if __name__ == "__main__":
  60. if(len(sys.argv)!=5):
  61. print("Incorrect usage!\n")
  62. print("./gen_enclave_config.py expects 4 parameters.")
  63. print("Usage: ./gen_enclave_config.py <N = number of clients> <M = number of servers> <T = number of threads> <B = message_size>")
  64. exit()
  65. n = int(sys.argv[1])
  66. m = int(sys.argv[2])
  67. t = int(sys.argv[3])
  68. b = int(sys.argv[4])
  69. generate_config(n, m, t, b)