def prepare_scorep_filter_file(self, filter_file: str) -> None: ''' Prepares the file that Score-P uses to include or exclude. NOTE: The filter_file is a positive list! We want to include these functions! ''' file_dir = U.get_base_dir(filter_file) file_content = U.read_file(filter_file) scorep_filter_file_content = self.append_scorep_footer( self.prepend_scorep_header(file_content)) scorep_filter_file_name = file_dir + '/scorep_filter_file.txt' U.write_file(scorep_filter_file_name, scorep_filter_file_content) return scorep_filter_file_name
def prepare_MPI_filtering(cls, filter_file: str) -> None: # Find which MPI functions to filter # Get all MPI functions (our filter_file is a WHITELIST) default_provider = D.BackendDefaults() mpi_funcs_dump = os.path.join(default_provider.instance.get_pira_dir(), 'mpi_funcs.dump') U.shell('wrap.py -d > ' + mpi_funcs_dump) all_MPI_functions_decls = U.read_file(mpi_funcs_dump).split('\n') all_MPI_functions = [] for fd in all_MPI_functions_decls: name = fd[fd.find(' '):fd.find('(')] all_MPI_functions.append(name.strip()) MPI_functions_to_filter = [] file_content = U.read_file(filter_file).split('\n') # We always want to measure MPI_Init and MPI_Finalize file_content.append('MPI_Init') file_content.append('MPI_Finalize') for l in file_content: if l.find('MPI_') > -1: L.get_logger().log( 'ScorepSystemHelper::prepare_MPI_filtering: Remove ' + l) # prevent double removal if l in all_MPI_functions: all_MPI_functions.remove(l) # Generate the .c file using the mpi wrap.py script L.get_logger().log( 'ScorepSystemHelper::prepare_MPI_filtering: About to filter ' + str(len(all_MPI_functions)) + ' MPI functions') wrap_script = '{{fn PIRA_Filter' for mpi_func in all_MPI_functions: wrap_script += ' ' + mpi_func wrap_script += '}}\n{{callfn}}\n{{endfn}}' default_provider = D.BackendDefaults() wrap_file = default_provider.get_wrap_w_file() if U.check_file(wrap_file): U.remove_file(wrap_file) U.write_file(wrap_file, wrap_script) wrap_c_path = default_provider.get_wrap_c_file() wrap_command = 'wrap.py -o ' + wrap_c_path + ' ' + wrap_file U.shell(wrap_command) # Compile it to .so file compile_mpi_wrapper_command = 'mpicc -shared -fPIC -o ' + default_provider.get_wrap_so_file( ) + ' ' + wrap_c_path U.shell(compile_mpi_wrapper_command)
def output_config(self, benchmark, output_dir): L.get_logger().log('ExtrapProfileSink::output_config:\ndir: ' + self._base_dir + '\nprefix: ' + self._prefix + '\npostfix: ' + self._postfix + '\nreps: ' + str(self._total_reps) + '\nNiter: ' + str(self._iteration + 1)) s = '' for p in self._params: s += p + ', ' L.get_logger().log('params: ' + s) json_str = json.dumps({ 'dir': self._base_dir, 'prefix': self._prefix, 'postfix': self._postfix, 'reps': int(self._total_reps), 'iter': int(self._iteration + 1), 'params': self._params }) out_file_final = output_dir + '/pgis_cfg_' + benchmark + '.json' U.write_file(out_file_final, json_str) return out_file_final