def SRAM_estimate_energy(self, interface): width = interface['attributes']['width'] depth = interface['attributes']['depth'] action_name = interface['action_name'] arguments = interface['arguments'] this_dir, this_filename = os.path.split(__file__) csv_file_path = os.path.join(this_dir,'data/SRAM.csv') energy = None with open(csv_file_path) as csv_file: reader = csv.DictReader(csv_file) for row in reader: if row['action_name'] == action_name and\ int(row['width']) == width and \ int(row['depth']) == depth: if DummyTableInterpolation.matched_arguments(row, arguments): energy = float(row['energy']) break # no exact energy recorded in the table, do linear interpolation if energy is None: if 12 < depth < 24: known_list = [{'x':12, 'y': 0.0}, {'x':224, 'y': 0.0}] # x is the depth, y is the energy elif 24 < depth < 224: known_list = [{'x':24, 'y': 0.0}, {'x':224, 'y': 0.0}] with open(csv_file_path) as csv_file: reader = csv.DictReader(csv_file) for row in reader: if int(row['width']) == width and int(row['depth']) == known_list[0]['x'] and row['action_name'] == action_name: if DummyTableInterpolation.matched_arguments(row, arguments): known_list[0]['y'] = float(row['energy']) if int(row['width']) == width and int(row['depth']) == known_list[1]['x'] and row['action_name'] == action_name: if DummyTableInterpolation.matched_arguments(row, arguments): known_list[1]['y'] = float(row['energy']) energy = oneD_linear_interpolation(depth, known_list) return energy
def intadder_estimate_energy(self, interface): this_dir, this_filename = os.path.split(__file__) nbit = interface['attributes']['datawidth'] csv_nbit = 32 csv_file_path = os.path.join(this_dir, 'data/adder.csv') energy = AladdinTable.query_csv_using_latency(interface, csv_file_path) if not nbit == csv_nbit: energy = oneD_linear_interpolation(nbit, [{ 'x': 0, 'y': 0 }, { 'x': csv_nbit, 'y': energy }]) return energy
def intadder_estimate_area(self, interface): this_dir, this_filename = os.path.split(__file__) nbit = interface['attributes']['datawidth'] csv_nbit = 32 csv_file_path = os.path.join(this_dir, 'data/adder.csv') area = AladdinAreaQueires.query_csv_area_using_latency( interface, csv_file_path) if not nbit == csv_nbit: area = oneD_linear_interpolation(nbit, [{ 'x': 0, 'y': 0 }, { 'x': csv_nbit, 'y': area }]) return area
def intadder_estimate_energy(self, interface): this_dir, this_filename = os.path.split(__file__) nbit = interface['attributes']['datawidth'] csv_nbit = 32 csv_file_path = os.path.join(this_dir, 'data/adder.csv') energy = AladdinTable.query_csv_using_latency(interface, csv_file_path) if not nbit == csv_nbit: energy = oneD_linear_interpolation(nbit, [{ 'x': 0, 'y': 0 }, { 'x': csv_nbit, 'y': energy }]) if 'type' in interface['attributes'].keys() and \ interface['attributes']['type'] == 'fft': print('DEBUGGING: using fft type') energy = energy * 4 return energy
def test_oneD_linear_interpolation(self): """ linear interpolation on one hardware attribute """ # Rough estimation of simple ripple carry adder: E_adder = E_full_adder * bitwidth + E_misc E_full_adder = 4 E_misc = 2 bitwidth_0 = 32 bitwidth_1 = 8 energy_0 = E_full_adder * bitwidth_0 + E_misc energy_1 = E_full_adder * bitwidth_1 + E_misc bitwidth_desired = 16 # expected output energy_desired = E_full_adder * bitwidth_desired + E_misc energy_interpolated = hf.oneD_linear_interpolation(bitwidth_desired,[{'x':bitwidth_0, 'y': energy_0}, {'x':bitwidth_1, 'y':energy_1}]) self.assertEqual(energy_interpolated, energy_desired)
def fpadder_estimate_energy(self, interface): this_dir, this_filename = os.path.split(__file__) nbit_exponent = interface['attributes']['exponent'] nbit_mantissa = interface['attributes']['mantissa'] nbit = nbit_mantissa + nbit_exponent if nbit_exponent + nbit_mantissa <= 32: csv_nbit = 32 csv_file_path = os.path.join(this_dir, 'data/fp_sp_adder.csv') else: csv_nbit = 64 csv_file_path = os.path.join(this_dir, 'data/fp_dp_adder.csv') energy = AladdinTable.query_csv_using_latency(interface, csv_file_path) if not nbit == csv_nbit: energy = oneD_linear_interpolation(nbit, [{ 'x': 0, 'y': 0 }, { 'x': csv_nbit, 'y': energy }]) return energy