Forráskód Böngészése

Refactor gen_enclave_config.py to allow for calling get_heap_size directly

Ian Goldberg 11 hónapja
szülő
commit
4b7975abf6
1 módosított fájl, 9 hozzáadás és 4 törlés
  1. 9 4
      gen_enclave_config.py

+ 9 - 4
gen_enclave_config.py

@@ -25,9 +25,7 @@ CONFIG_FILE = "Enclave/Enclave.config.xml"
     num_WN_to_precompute: The default num_WN_to_precompute is 12 in App/start.cpp
 '''
 
-def generate_config(N, M, T, B, PRIVATE_ROUTE=True, PRO=1, PRI=1, PUO=1, PUI=1, num_WN_to_precompute=12):
-
-    cf = open(CONFIG_FILE, 'w+')
+def get_heap_size(N, M, T, B, PRIVATE_ROUTE=True, PRO=1, PRI=1, PUO=1, PUI=1, num_WN_to_precompute=12):
     clients_per_server = math.ceil(N/M)
 
     # Base heap of 2 MB per thread
@@ -53,6 +51,13 @@ def generate_config(N, M, T, B, PRIVATE_ROUTE=True, PRO=1, PRI=1, PUO=1, PUI=1,
         (clients_per_server * math.ceil(math.log(clients_per_server,2)) * 8))
 
     heap_size_page_aligned = math.ceil(heap_size/4096) * 4096
+    return heap_size_page_aligned
+
+def generate_config(N, M, T, B, PRIVATE_ROUTE=True, PRO=1, PRI=1, PUO=1, PUI=1, num_WN_to_precompute=12):
+
+    cf = open(CONFIG_FILE, 'w+')
+    heap_size_page_aligned = get_heap_size(N, M, T, B, PRIVATE_ROUTE,
+        PRO, PRI, PUO, PUI, num_WN_to_precompute)
     hex_heap_size = hex(heap_size_page_aligned)
 
     enclave_config = '''<!-- Please refer to User's Guide for the explanation of each field -->
@@ -67,7 +72,7 @@ def generate_config(N, M, T, B, PRIVATE_ROUTE=True, PRO=1, PRI=1, PUO=1, PUI=1,
   <MiscSelect>0</MiscSelect>
   <MiscMask>0xFFFFFFFF</MiscMask>
 </EnclaveConfiguration>
-    '''.format(H = str(hex_heap_size))
+    '''.format(H = hex_heap_size)
 
     #print (enclave_config)
     cf.write(enclave_config)