diff --git a/llvm/projects/soc_simulator/src/driver.py b/llvm/projects/soc_simulator/src/driver.py index 062142edd9bda894d7bff38191aed0acfd8af973..23b7fe26b91c68f2cbaba9b0bb853295f2cb21df 100644 --- a/llvm/projects/soc_simulator/src/driver.py +++ b/llvm/projects/soc_simulator/src/driver.py @@ -248,7 +248,6 @@ def run_simulations(config_filename): prev_layer = curr_layer config_count += 1 print("\n") - config_count += 1 # because we're storing the count and not the index config_file.close() @@ -257,10 +256,8 @@ def display_results(results_filename): attributes_to_print = [results_time_key, results_energy_key] for attribute in attributes_to_print: - attribute_data = [] # Store as list and then write to file once bc syscalls are slow - attribute_data.append(attribute) - - attribute_data.append("Configuration,Total,Improvement") # header + results_file.write("%s\n" % attribute) + results_file.write("Configuration,Total,Improvement\n") baseline_val = aggregate_results[attribute][0] print(baseline_val) @@ -268,18 +265,15 @@ def display_results(results_filename): best_result = None for config_ind in range(config_count): - config_data = ["c%d" % config_ind] + results_file.write("c%d" % config_ind) time_or_energy_val = aggregate_results[attribute][config_ind] - config_data.append(str(time_or_energy_val)) - config_data.append(str(baseline_val / (time_or_energy_val + 0.0001))) - attribute_data.append(','.join(config_data)) + results_file.write(",%f" % time_or_energy_val) + results_file.write(",%f\n" % (baseline_val / (time_or_energy_val + 0.0001))) if not best_result or time_or_energy_val < best_result: best_result = time_or_energy_val best_config = config_ind - attribute_data.append("c%d,%d" % (best_config, aggregate_results[attribute][best_config])) - attribute_data.append("") # To add an additional new line - results_file.write('\n'.join(attribute_data)) + results_file.write("\nc%d,%f\n\n" % (best_config, aggregate_results[attribute][best_config])) results_file.close() if __name__ == "__main__":