def execute(self): try: if len(self.workloads) != self.num_cpus: raise AssertionError( f'length of workloads ({len(self.workloads)}) ' f'is not equal to num_cpus ({self.num_cpus})') gem5_args: List[str] = [ self.main_config.gem5_executable_path, self.main_config.gem5_se_script_path, '--cpu-freq', self.main_config.cpu_freq, '--disable-l2', '1', '--num-cores', str(self.num_cpus) ] gem5_args.extend(self.workloads) CommandHelper.run_command([ 'mkdir', '-p', f'{self.main_config.out_dir}/run_{self.rank}_{self.run_id}' ], self.main_config.show_command_output, self.main_config.show_command_error) CommandHelper.run_command( gem5_args, self.main_config.show_command_output, self.main_config.show_command_error, f'{self.main_config.out_dir}/run_{self.rank}_{self.run_id}') stats = CommandHelper.run_command_output([ 'awk', '/sim_sec/ {print $2}', f'stats.txt' ], f'{self.main_config.out_dir}/run_{self.rank}_{self.run_id}/m5out' ).splitlines() CommandHelper.run_command([ 'rm', f'-rf', f'{self.main_config.out_dir}/run_{self.rank}_{self.run_id}' ], self.main_config.show_command_output, self.main_config.show_command_error) CommandHelper.run_command([ 'mkdir', '-p', f'{self.main_config.stats_dir}/run_{self.rank}_{self.run_id}' ], self.main_config.show_command_output, self.main_config.show_command_error) if len(stats) == 15: total_time_for_tasks = 0 for i in range(14): if i % 2 != 0: total_time_for_tasks += int(stats[i][2:]) - int( stats[i - 1][2:]) if total_time_for_tasks > self.find_runs_higher_than_this: print( f'node {self.rank} found higher simulation time {total_time_for_tasks} for workload {self.workloads}' ) JsonHelper.object_as_json_to_file( f'{self.main_config.stats_dir}/run_{self.rank}_{self.run_id}/workloads.json', [self.workloads, total_time_for_tasks, len(stats)]) else: print(f'Node {self.rank} wrong stats length {len(stats)}') JsonHelper.object_as_json_to_file( f'{self.main_config.stats_dir}/run_{self.rank}_{self.run_id}/workloads.json', [self.workloads, 0, len(stats)]) except OSError as e: print(f'OSError> {e.errno} {e.strerror} {e.filename}') except TypeError as e: print(f'TypeError> {e}') except AttributeError as e: print(f'AttributeError> {e}') except AssertionError as e: print(f'AssertionError> {e}') except NameError as e: print(f'NameError> {e}') except: print(f'Error> {sys.exc_info()[0]}') print( f'Node {self.rank} ValidateSingleSimulationTask done {self.run_id:,}' )
#from Tasks.GenerateThreadsAndValueSimulationsTask import GenerateThreadsAndValuesSimulationsTask if __name__ == "__main__": main_data = json.load(open('config.json')) benchmark_data = json.load(open('benchmarks.json')) main_config = MainConfig(main_data) benchmark_config = BenchmarkConfig(benchmark_data) comm = MPI.COMM_WORLD size = comm.Get_size() rank = comm.Get_rank() one = os.path.isdir(main_config.out_dir) #output = CommandHelper.run_command_output(['df', '-BM', '/local/mdelang']) hostname = CommandHelper.run_command_output(['hostname']) print(f'Node {rank} {hostname} {main_config.out_dir} exists {one}') if not one: try: os.makedirs(main_config.out_dir, exist_ok=True) except Exception as inst: print(type(inst)) print(inst.args) print(inst) print(sys.exc_info()[0]) benchmark, = [bench for bench in benchmark_config.benchmarks if bench.name == main_config.benchmark] start = datetime.datetime.now()
import sys from CommandHelper import CommandHelper if __name__ == "__main__": sim_secs_static = CommandHelper.run_command_output( ['awk', '/sim_sec/ {print $2}', f'stats_static.txt'], './').splitlines() sim_secs_static_nofp = CommandHelper.run_command_output( ['awk', '/sim_sec/ {print $2}', f'stats_static_nofp.txt'], './').splitlines() sim_secs_dynamic = CommandHelper.run_command_output( ['awk', '/sim_sec/ {print $2}', f'stats_dynamic.txt'], './').splitlines() sim_insts_static = CommandHelper.run_command_output( ['awk', '/sim_insts/ {print $2}', f'stats_static.txt'], './').splitlines() sim_insts_static_nofp = CommandHelper.run_command_output( ['awk', '/sim_insts/ {print $2}', f'stats_static_nofp.txt'], './').splitlines() sim_insts_dynamic = CommandHelper.run_command_output( ['awk', '/sim_insts/ {print $2}', f'stats_dynamic.txt'], './').splitlines() if len(sim_secs_static) != 27: print( f'static stats incorrect stats length {len(sim_secs_static)} {sim_secs_static}' ) sys.exit(-1)
totals = [] for run_dir in data: try: CommandHelper.run_command( ['mkdir', '-p', f'{main_config.out_dir}/{run_dir}'], main_config.show_command_output, main_config.show_command_error) CommandHelper.run_command([ main_config.zstd, '-D', f'{main_config.stats_dir}/zstd-dict', '-d', '-f', f'{main_config.stats_dir}/{run_dir}/stats.txt.zst', '-o', 'stats.txt' ], main_config.show_command_output, main_config.show_command_error, f'{main_config.out_dir}/{run_dir}') stats = CommandHelper.run_command_output( ['awk', '/sim_insts/ {print $2}', f'stats.txt'], f'{main_config.out_dir}/{run_dir}').splitlines() CommandHelper.run_command(['rm', '-rf', f'{run_dir}'], main_config.show_command_output, main_config.show_command_error, f'{main_config.out_dir}') if len(stats) != 3: print(f'Expected three stat results, got {len(stats)} {stats}') raise Exception totals.append((run_dir, int(stats[1]))) except Exception as inst: print(type(inst)) print(inst.args) print(inst)
find_runs_with_this_time = 624 identified_runs = [] for run_dir in data: try: CommandHelper.run_command( ['mkdir', '-p', f'{main_config.out_dir}/{run_dir}'], main_config.show_command_output, main_config.show_command_error) CommandHelper.run_command([ 'zstd', '-D', f'{main_config.out_dir}/zstd-dict', '-d', '-f', f'{main_config.stats_dir}/{run_dir}/stats.txt.zst', '-o', 'stats.txt' ], main_config.show_command_output, main_config.show_command_error, f'{main_config.out_dir}/{run_dir}') stats = CommandHelper.run_command_output( ['awk', '/sim_sec/ {print $2}', f'stats.txt'], f'{main_config.out_dir}/{run_dir}').splitlines() CommandHelper.run_command(['rm', '-rf', f'{run_dir}'], main_config.show_command_output, main_config.show_command_error, f'{main_config.out_dir}') if len(stats) != 27: continue else: total_time_for_tasks = 0 prev_time = 0 for i in range(26): if i % 2 == 0: prev_time = int(stats[i][2:]) else: #print(f'node {rank} adding {int(stats[i][2:]):,} {int(stats[i-1][2:]):,}')