chunks = [[] for _ in range(size)] for i, chunk in enumerate(runs): print(f'i, chunk {i} {chunk} {runs[chunk]}') chunks[i % size].extend(runs[chunk]) else: data = None chunks = None data = comm.scatter(chunks, root=0) print(f'Node {rank} data {len(data)}') 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}')
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:,}' )
def execute(self): #print(f'Starting RunSingleSimulationTask {self.run_id} {self.workloads}') 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}') 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) CommandHelper.run_command( [ self.main_config.zstd, '-15', '--rm', '-f', '-D', f'{self.main_config.stats_dir}/zstd-dict', f'stats.txt', '-o', f'{self.main_config.stats_dir}/run_{self.rank}_{self.run_id}/stats.txt.zst' ], self.main_config.show_command_output, self.main_config.show_command_error, f'{self.main_config.out_dir}/run_{self.rank}_{self.run_id}/m5out' ) 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) JsonHelper.object_as_json_to_file( f'{self.main_config.stats_dir}/run_{self.rank}_{self.run_id}/workloads.json', self.workloads) 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: print(f'Error> {sys.exc_info()[0]}') print(f'Node {self.rank} RunSingleSimulationTask done {self.run_id:,}')