Example #1
0
 def _parse_implicit(self, args):
     projects = set()
     targets = set()
     applications = set()
     measurements = set()
     proj_ctrl = Project.controller()
     targ_ctrl = Target.controller(PROJECT_STORAGE)
     app_ctrl = Application.controller(PROJECT_STORAGE)
     meas_ctrl = Measurement.controller(PROJECT_STORAGE)
     for flag in 'impl_project', 'impl_target', 'impl_application', 'impl_measurement':
         for name in getattr(args, flag, []):
             prj = proj_ctrl.one({"name": name})
             tar = targ_ctrl.one({"name": name})
             app = app_ctrl.one({"name": name})
             mes = meas_ctrl.one({"name": name})
             ptam = set([prj, tar, app, mes]) - set([None])
             if len(ptam) > 1:
                 self.parser.error("'%s' is ambiguous.  Please use --project, --target, --application,"
                                   " or --measurement to specify configuration type." % name)
             elif len(ptam) == 0:
                 self.parser.error("'%s' is not a project, target, application, or measurement." % name)
             elif prj:
                 projects.add(prj)
             elif tar:
                 targets.add(tar)
             elif app:
                 applications.add(app)
             elif mes:
                 measurements.add(mes)
     return projects, targets, applications, measurements
Example #2
0
 def _parse_implicit(self, args, targets, applications, measurements):
     targ_ctrl = Target.controller(PROJECT_STORAGE)
     app_ctrl = Application.controller(PROJECT_STORAGE)
     meas_ctrl = Measurement.controller(PROJECT_STORAGE)
     for flag in 'impl_targets', 'impl_applications', 'impl_measurements':
         for name in getattr(args, flag, []):
             tar = targ_ctrl.one({"name": name})
             app = app_ctrl.one({"name": name})
             mes = meas_ctrl.one({"name": name})
             tam = set([tar, app, mes]) - set([None])
             if len(tam) > 1:
                 self.parser.error("'%s' is ambiguous.  Please use --target, --application,"
                                   " or --measurement to specify configuration type" % name)
             elif len(tam) == 0:
                 self.parser.error("'%s' is not a target, application, or measurement" % name)
             elif tar:
                 targets.add(tar)
             elif app:
                 applications.add(app)
             elif mes:
                 measurements.add(mes)
Example #3
0
    def main(self, argv):
        from tau.cli.commands.project.list import COMMAND as project_list

        args = self.parser.parse_args(args=argv)
        self.logger.debug('Arguments: %s', args)
    
        tar_ctrl = Target.controller(PROJECT_STORAGE)
        app_ctrl = Application.controller(PROJECT_STORAGE)
        meas_ctrl = Measurement.controller(PROJECT_STORAGE)
        proj_ctrl = Project.controller()
    
        project_name = args.name
        project = proj_ctrl.one({'name': project_name})
        if not project:
            self.parser.error("'%s' is not a project name. Type `%s` to see valid names." % 
                              (project_name, project_list.command))
    
        updates = dict(project.element)
        updates['name'] = getattr(args, 'new_name', project_name)
        targets = set(project['targets'])
        applications = set(project['applications'])
        measurements = set(project['measurements'])
        added = set()
        removed = set()
        
        for attr, ctrl, dest in [('add_targets', tar_ctrl, targets),
                                 ('add_applications', app_ctrl, applications),
                                 ('add_measurements', meas_ctrl, measurements)]:
            names = getattr(args, attr, [])
            for name in names:
                found = ctrl.one({'name': name})
                if not found:
                    self.parser.error("There is no %s named '%s'" % (ctrl.model.name, name))
                dest.add(found.eid)
                added.add(found)
    
        for name in set(getattr(args, "add", [])):
            tar = tar_ctrl.one({'name': name})
            app = app_ctrl.one({'name': name})
            mes = meas_ctrl.one({'name': name})
            tam = set([tar, app, mes]) - set([None])
            if len(tam) > 1:
                self.parser.error("'%s' is ambiguous. Use --add-targets, --add-applications,"
                                  " or --add-measurements to specify configuration type" % name)
            elif len(tam) == 0:
                self.parser.error("'%s' is not a target, application, or measurement" % name)
            else:
                added.update(tam)
            if tar:
                targets.add(tar.eid)
            elif app:
                applications.add(app.eid)
            elif mes:
                measurements.add(mes.eid)
    
        for attr, ctrl, dest in [('remove_targets', tar_ctrl, targets),
                                 ('remove_applications', app_ctrl, applications),
                                 ('remove_measurements', meas_ctrl, measurements)]:
            names = getattr(args, attr, [])
            for name in names:
                found = ctrl.one({'name': name})
                if not found:
                    self.parser.error('There is no %s named %r' % (ctrl.model.name, name))
                dest.remove(found.eid)
                removed.add(found)
    
        for name in set(getattr(args, "remove", [])):
            tar = tar_ctrl.one({'name': name})
            app = app_ctrl.one({'name': name})
            mes = meas_ctrl.one({'name': name})
            tam = set([tar, app, mes]) - set([None])
            if len(tam) > 1:
                self.parser.error("'%s' is ambiguous. Use --remove-targets, --remove-applications,"
                                  " or --remove-measurements to specify configuration type" % name)
            elif len(tam) == 0:
                self.parser.error("'%s' is not a target, application, or measurement" % name)
            else:
                removed.update(tam)
            if tar:
                targets.remove(tar.eid)
            elif app:
                applications.remove(app.eid)
            elif mes:
                measurements.remove(mes.eid)
    
        updates['targets'] = list(targets)
        updates['applications'] = list(applications)
        updates['measurements'] = list(measurements)
    
        proj_ctrl.update(updates, {'name': project_name})
        for model in added:
            self.logger.info("Added %s '%s' to project configuration '%s'.", 
                             model.name.lower(), model[model.key_attribute], project_name)
        for model in removed:
            self.logger.info("Removed %s '%s' from project configuration '%s'.", 
                             model.name.lower(), model[model.key_attribute], project_name)
        return EXIT_SUCCESS
Example #4
0
def attributes():
    from tau.model.project import Project
    from tau.model.target import Target
    from tau.model.application import Application
    from tau.cli.arguments import ParseBooleanAction
    return {
        'projects': {
            'collection': Project,
            'via': 'measurements',
            'description': "projects using this measurement"
        },
        'name': {
            'primary_key': True,
            'type': 'string',
            'unique': True,
            'description': "measurement configuration name",
            'argparse': {'help': 'measurement configuration name',
                         'metavar': '<measurement_name>'},
        
        },
        'profile': {
            'type': 'boolean',
            'default': True,
            'description': "generate application profiles",
            'argparse': {'flags': ('--profile',),
                         'group': 'output format',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
        },
        'trace': {
            'type': 'boolean',
            'default': False,
            'description': "generate application traces",
            'argparse': {'flags': ('--trace',),
                         'group': 'output format',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
            'compat': {True: Target.discourage('score-p_source', None)}
        },
        'sample': {
            'type': 'boolean',
            'default': True,
            'description': "use event-based sampling to gather performance data",
            'argparse': {'flags': ('--sample',),
                         'group': 'instrumentation',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
            'compat': {True: (Target.discourage('binutils_source', None),
                              Target.discourage('libunwind_source', None))}
        },
        'source_inst': {
            'type': 'string',
            'default': 'never',
            'description': "use hooks inserted into the application source code to gather performance data",
            'argparse': {'flags': ('--source-inst',),
                         'group': 'instrumentation',
                         'metavar': 'mode',
                         'nargs': '?',
                         'choices': ('automatic', 'manual', 'never'),
                         'const': 'automatic'},
            'compat': {lambda x: x in ('automatic', 'manual'):
                       Target.exclude('pdt_source', None)}
        },
        'compiler_inst': {
            'type': 'string',
            'default': 'fallback',
            'description': "use compiler-generated callbacks to gather performance data",
            'argparse': {'flags': ('--compiler-inst',),
                         'group': 'instrumentation',
                         'metavar': 'mode',
                         'nargs': '?',
                         'choices': ('always', 'fallback', 'never'),
                         'const': 'always'},
            'compat': {lambda x: x in ('always', 'fallback'):
                       (Target.discourage('binutils_source', None),
                        Target.discourage('libunwind_source', None))}
        },
        'link_only': {
            'type': 'boolean',
            'default': False,
            'description': "don't instrument, only link the TAU library to the application",
            'argparse': {'flags': ('--link-only',),
                         'group': 'instrumentation',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
        },
        'mpi': {
            'type': 'boolean',
            'default': False,
            'description': 'use MPI library wrapper to measure time spent in MPI methods',
            'argparse': {'flags': ('--mpi',),
                         'group': 'library',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
            'compat': {True:
                       (Target.require('MPI_CC'),
                        Target.require('MPI_CXX'),
                        Target.require('MPI_FC'))}
        },
        'openmp': {
            'type': 'string',
            'default': 'none',
            'description': 'use specified library to measure time spent in OpenMP directives',
            'argparse': {'flags': ('--openmp',),
                         'group': 'library',
                         'metavar': 'library',
                         'choices': ('none', 'opari', 'ompt'),
                         'nargs': 1},
            'compat': {'opari':
                       Application.require('openmp', True),
                       'ompt':
                       (Application.require('openmp', True),
                        Target.require('CC_ROLE', intel_only),
                        Target.require('CXX_ROLE', intel_only),
                        Target.require('FC_ROLE', intel_only))}
        },
        'cuda': {
            'type': 'boolean',
            'default': False,
            'description': 'measure cuda events via the CUPTI interface',
            'argparse': {'flags': ('--cuda',),
                         'group': 'library',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
            'compat': {True: Target.require('cuda')}
        },
        'opencl': {
            'type': 'boolean',
            'default': False,
            'description': 'measure OpenCL events',
            'argparse': {'flags': ('--opencl',),
                         'group': 'library',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
            'compat': {True: Target.require('opencl')}
        },
        'callpath': {
            'type': 'integer',
            'default': 2,
            'description': 'maximum depth for callpath recording',
            'argparse': {'flags': ('--callpath',),
                         'group': 'data',
                         'metavar': 'depth',
                         'nargs': '?',
                         'const': 2,
                         'type': int},
        },
        'io': {
            'type': 'boolean',
            'default': False,
            'description': 'measure time spent in POSIX I/O calls',
            'argparse': {'flags': ('--io',),
                         'group': 'library',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
        },
        'memory_usage': {
            'type': 'boolean',
            'default': False,
            'description': 'measure memory consumption',
            'argparse': {'flags': ('--memory-usage',),
                         'group': 'memory',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
        },
        'memory_alloc': {
            'type': 'boolean',
            'default': False,
            'description': 'record memory allocation and deallocation events',
            'argparse': {'flags': ('--memory-alloc',),
                         'group': 'memory',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
        },
        'metrics': {
            'type': 'array',
            'default': ['TIME'],
            'description': 'performance metrics to gather, e.g. TIME, PAPI_FP_INS',
            'argparse': {'flags': ('--metrics',),
                         'group': 'data',
                         'metavar': '<METRIC>',
                         'nargs': '+'},
            'compat': {lambda metrics: bool(len([met for met in metrics if 'PAPI' in met])): 
                       Target.exclude('papi_source', None)}
        },
        'keep_inst_files': {
            'type': 'boolean',
            'default': False,
            'description': "don't remove instrumented files after compilation",
            'argparse': {'flags': ('--keep-inst-files',),
                         'group': 'instrumentation',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
            'compat': {True: Measurement.exclude('source_inst', 'never')}
        },
        'reuse_inst_files': {
            'type': 'boolean',
            'default': False,
            'description': 'reuse and preserve instrumented files after compilation',
            'argparse': {'flags': ('--reuse-inst-files',),
                         'group': 'instrumentation',
                         'metavar': 'T/F',
                         'nargs': '?',
                         'const': True,
                         'action': ParseBooleanAction},
            'compat': {True: Measurement.exclude('source_inst', 'never')}
        }
    }