示例#1
0
文件: Builder.py 项目: mority/pira
  def construct_pira_instr_kwargs(self) -> typing.Dict:
    L.get_logger().log('Builder::construct_pira_instr_keywords', level='debug')
    if not self.build_instr:
      raise BuilderException('Should not construct instrument kwargs in non-instrumentation mode.')

    pira_cc = ScorepSystemHelper.get_scorep_compliant_CC_command(self.instrumentation_file,
                                                                 self._compile_time_filtering)
    pira_cxx = ScorepSystemHelper.get_scorep_compliant_CXX_command(self.instrumentation_file,
                                                                   self._compile_time_filtering)
    pira_clflags = ScorepSystemHelper.get_scorep_needed_libs_c()
    pira_cxxlflags = ScorepSystemHelper.get_scorep_needed_libs_cxx()
    default_provider = D.BackendDefaults()
    pira_name = default_provider.get_default_exe_name()

    pira_kwargs = {
        'CC': pira_cc,
        'CXX': pira_cxx,
        'CLFLAGS': pira_clflags,
        'CXXLFLAGS': pira_cxxlflags,
        'PIRANAME': pira_name,
        'NUMPROCS': default_provider.get_default_number_of_processes(),
        'filter-file': self.instrumentation_file
    }
    L.get_logger().log('Builder::construct_pira_instr_keywords Returning.', level='debug')
    return pira_kwargs
示例#2
0
    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)
示例#3
0
 def get_instrumentation_flags(cls, instr_file: str,
                               compile_time_filter: bool) -> str:
     default_provider = D.BackendDefaults()
     flags = default_provider.get_default_instrumentation_flag() + ' '
     if compile_time_filter:
         flags += default_provider.get_default_instrumentation_selection_flag(
         ) + '=' + instr_file
     return flags
示例#4
0
文件: Analyzer.py 项目: rmmilewi/pira
    def analyze(self, target_config, iteration_number: int) -> str:
        default_provider = defaults.BackendDefaults()
        kwargs = default_provider.get_default_kwargs()

        flavor = target_config.get_flavor()
        build = target_config.get_build()
        benchmark = target_config.get_target()
        return self.analyze_local(flavor, build, benchmark, kwargs,
                                  iteration_number)
示例#5
0
    def test_get_no_instr_file_flags(self):
        s_mh = m.ScorepSystemHelper(self.cfg)
        s_mh.set_up(self.target_cfg, self.instr_cfg, False)
        instr_file = 'myFile.filt'
        ct_filter = False

        kw_dict = dff.BackendDefaults().get_default_kwargs()
        cc = kw_dict['CC']
        self.assertEqual('\"clang\"', cc)
        cpp = kw_dict['CXX']
        self.assertEqual('\"clang++\"', cpp)
示例#6
0
    def construct_pira_kwargs(self) -> typing.Dict:
        log.get_logger().log('Builder::construct_pira_keywords', level='debug')
        default_provider = defaults.BackendDefaults()

        kwargs = default_provider.get_default_kwargs()
        kwargs['CLFLAGS'] = ''
        kwargs['CXXLFLAGS'] = ''

        log.get_logger().log('Builder::construct_pira_keywords Returning.',
                             level='debug')
        return kwargs
示例#7
0
文件: Builder.py 项目: mority/pira
  def construct_pira_kwargs(self) -> typing.Dict:
    L.get_logger().log('Builder::construct_pira_keywords', level='debug')
    if self.build_instr:
      raise BuilderException('Should not construct non-instrument kwargs in instrumentation mode.')

    default_provider = D.BackendDefaults()

    kwargs = default_provider.get_default_kwargs()
    kwargs['CLFLAGS'] = ''
    kwargs['CXXLFLAGS'] = ''

    L.get_logger().log('Builder::construct_pira_keywords Returning.', level='debug')
    return kwargs
示例#8
0
    def get_scorep_compliant_CXX_command(cls,
                                         instr_file: str,
                                         compile_time_filter: bool = True
                                         ) -> str:
        """ Returns instrumentation flags for the C++ compiler.

    :instr_file: str: The file name to use for filtering
    :compile_time_filter: bool: Should compile-time filtering be used (default)
    """
        default_provider = D.BackendDefaults()
        cxx_str = default_provider.get_default_cpp_compiler_name(
        ) + ' ' + cls.get_instrumentation_flags(instr_file,
                                                compile_time_filter)
        return '\"' + cxx_str + '\"'
示例#9
0
    def get_scorep_compliant_CC_command(cls,
                                        instr_file: str,
                                        compile_time_filter: bool = True
                                        ) -> str:
        """ Returns instrumentation flags for the C compiler.

    :instr_file: str: The file name to use for filtering
    :compile_time_filter: bool: Should compile-time filtering be used (default)
    """
        default_provider = D.BackendDefaults()
        L.get_logger().log(
            'ScorepSystemHelper::get_scorep_compliant_CC_command: ',
            level='debug')
        cc_str = default_provider.get_default_c_compiler_name(
        ) + ' ' + cls.get_instrumentation_flags(instr_file,
                                                compile_time_filter)
        return '\"' + cc_str + '\"'
示例#10
0
文件: Runner.py 项目: rmmilewi/pira
    def run(self, target_config: TargetConfiguration,
            instrument_config: InstrumentConfig,
            compile_time_filtering: bool) -> float:
        """ Implements the actual invocation """
        functor_manager = fm.FunctorManager()
        run_functor = functor_manager.get_or_load_functor(
            target_config.get_build(), target_config.get_target(),
            target_config.get_flavor(), 'run')
        default_provider = defaults.BackendDefaults()
        kwargs = default_provider.get_default_kwargs()
        kwargs['util'] = util
        kwargs['LD_PRELOAD'] = default_provider.get_MPI_wrap_LD_PRELOAD()
        runtime = .0

        if run_functor.get_method()['active']:
            run_functor.active(target_config.get_target(), **kwargs)
            log.get_logger().log(
                'For the active functor we can barely measure runtime',
                level='warn')
            runtime = 1.0

        try:
            util.change_cwd(target_config.get_place())

            invoke_arguments = target_config.get_args_for_invocation()
            kwargs['args'] = invoke_arguments
            if invoke_arguments is not None:
                log.get_logger().log('LocalBaseRunner::run: (args) ' +
                                     str(invoke_arguments))

            command = run_functor.passive(target_config.get_target(), **kwargs)
            _, runtime = util.shell(command, time_invoc=True)
            log.get_logger().log(
                'LocalBaseRunner::run::passive_invocation -> Returned runtime: '
                + str(runtime),
                level='debug')

        except Exception as e:
            log.get_logger().log('LocalBaseRunner::run Exception\n' + str(e),
                                 level='error')
            raise RuntimeError('LocalBaseRunner::run caught exception. ' +
                               str(e))

        # TODO: Insert the data into the database
        return runtime
示例#11
0
文件: Analyzer.py 项目: mority/pira
    def analyze(self, target_config, iteration_number: int) -> str:
        # The sink needs to be set for the Analyzer to run
        if self._profile_sink is None:
            raise RuntimeError(
                'Analyzer::analyze: Profile Sink in Analyzer not set!')

        if target_config is None:
            raise RuntimeError(
                'Analyzer::analyze: TargetConfiguration object is None!')

        default_provider = D.BackendDefaults()
        kwargs = default_provider.get_default_kwargs()

        flavor = target_config.get_flavor()
        build = target_config.get_build()
        benchmark = target_config.get_target()
        return self.analyze_local(flavor, build, benchmark, kwargs,
                                  iteration_number)