Skip to content
Snippets Groups Projects
Commit d579f04c authored by Elizabeth's avatar Elizabeth
Browse files

Implemented code to run promise simulator

parent 8c507806
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
from collections import defaultdict from collections import defaultdict
import os import os
import subprocess
import sys import sys
def build_nested_default_dict(): def build_nested_default_dict():
...@@ -145,6 +146,38 @@ def quantize(curr_layer, prev_layer, h2f_f2h_operation_ind, layer_data): ...@@ -145,6 +146,38 @@ def quantize(curr_layer, prev_layer, h2f_f2h_operation_ind, layer_data):
assert(False) # Error: Should never reach this section assert(False) # Error: Should never reach this section
def run_promise_simulation(swing, layer_data):
layer_name = layer_data["Name"]
patch_factor = 1
if is_conv(layer_name):
rows_a = layer_data["N"] * layer_data["H"] * layer_data["W"] \
/ (layer_data["Sh"] * layer_data["Sw"])
cols_a = layer_data["Cin"] * layer_data["Kh"] * layer_data["Kw"]
rows_b = cols_a
cols_b = layer_data["Cout"]
patch_factor = layer_data["Kh"] * layer_data["Kw"]
elif is_fc(layer_name):
rows_a = layer_data["RA"]
cols_a = layer_data["CA"]
rows_b = cols_a
cols_b = layer_data["CB"]
else:
print("PROMISE can't run whatever this layer is.")
exit(1)
# Run promise simulator
# TODO need to print time and energy so we can pipe it
# get output --> total time and energy
ptm_process = subprocess.Popen(["./ptm", str(rows_a), str(cols_a), str(rows_b), \
str(cols_b), str(patch_factor), str(swing)])
output, _ = ptm_process.communicate()
total_time_energy = output.strip().split(' ')
assert(len(total_time_energy) == 2)
return total_time_energy[0], total_time_energy[1]
def run_simulations(config_filename, results_filename): def run_simulations(config_filename, results_filename):
config_file = open(config_filename, "r") config_file = open(config_filename, "r")
results_file = open(results_filename, "w") results_file = open(results_filename, "w")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment