def _create_project(self, argv, args):
        def _safe_execute(cmd, argv):
            retval = cmd.main(argv)
            if retval != EXIT_SUCCESS:
                raise InternalError("return code %s: %s %s" % (retval, cmd, ' '.join(argv)))

        if host.operating_system() is DARWIN_OS:
            self.logger.info("Darwin OS detected: disabling GNU binutils, compiler-based instrumentation, and sampling.")
            binutils = False
            sample = False
            comp_inst = 'never'
        else:
            binutils = True
            sample = True
            comp_inst = 'fallback'

        project_name = args.project_name
        target_name = args.target_name
        application_name = args.application_name
        
        project_create_cmd.main([project_name])
        select_cmd.main(['--project', project_name])

        target_argv = [target_name] + argv
        _, unknown = target_create_cmd.parser.parse_known_args(args=target_argv)
        target_argv = [target_name] + [arg for arg in argv if arg not in unknown]
        if not binutils:
            target_argv.append('--binutils=False')
        _safe_execute(target_create_cmd, target_argv)
        
        application_argv = [application_name] + argv
        application_args, unknown = application_create_cmd.parser.parse_known_args(args=application_argv)
        application_argv = [application_name] + [arg for arg in argv if arg not in unknown]
        _safe_execute(application_create_cmd, application_argv)

        measurement_names = []
        measurement_args = ['--%s=True' % attr 
                            for attr in 'cuda', 'mpi', 'opencl' if getattr(application_args, attr, False)]
        
        if args.sample and sample:
            _safe_execute(measurement_create_cmd, 
                          ['profile-sample', '--profile=True', '--trace=False', '--sample=True',
                           '--source-inst=never', '--compiler-inst=%s' % comp_inst, 
                           '--link-only=False'] + measurement_args)
            measurement_names.extend(['profile-sample'])
        if args.profile:
            _safe_execute(measurement_create_cmd, 
                          ['profile-automatic', '--profile=True', '--trace=False', '--sample=False',
                           '--source-inst=automatic', '--compiler-inst=%s' % comp_inst, 
                           '--link-only=False'] + measurement_args)
            _safe_execute(measurement_create_cmd, 
                          ['profile-manual', '--profile=True', '--trace=False', '--sample=False',
                           '--source-inst=never', '--compiler-inst=never', 
                           '--link-only=True'] + measurement_args)
            measurement_names.extend(['profile-automatic', 'profile-manual'])
        if args.trace:
            _safe_execute(measurement_create_cmd, 
                          ['trace-automatic', '--profile=False', '--trace=True', '--sample=False', 
                           '--source-inst=automatic', '--compiler-inst=%s' % comp_inst, 
                           '--link-only=False'] + measurement_args)
            _safe_execute(measurement_create_cmd, 
                          ['trace-manual', '--profile=False', '--trace=True', '--sample=False',
                           '--source-inst=never', '--compiler-inst=never', 
                           '--link-only=True'] + measurement_args)
            measurement_names.extend(['trace-automatic', 'trace-manual'])

        select_cmd.main(['--project', project_name, '--target', target_name, 
                         '--application', application_name, '--measurement', measurement_names[0]])
Exemple #2
0
def attributes():
    from tau.model.project import Project
    from tau.cli.arguments import ParsePackagePathAction
    from tau.cf.target import host, Architecture, OperatingSystem

    return {
        "projects": {"collection": Project, "via": "targets", "description": "projects using this target"},
        "name": {
            "primary_key": True,
            "type": "string",
            "unique": True,
            "description": "target configuration name",
            "argparse": {"metavar": "<target_name>"},
        },
        "host_os": {
            "type": "string",
            "required": True,
            "description": "host operating system",
            "default": host.operating_system().name,
            "argparse": {
                "flags": ("--host-os",),
                "group": "host",
                "metavar": "<os>",
                "choices": OperatingSystem.keys(),
            },
        },
        "host_arch": {
            "type": "string",
            "required": True,
            "description": "host architecture",
            "default": host.architecture().name,
            "argparse": {
                "flags": ("--host-arch",),
                "group": "host",
                "metavar": "<arch>",
                "choices": Architecture.keys(),
            },
        },
        "CC": {
            "model": Compiler,
            "required": True,
            "description": "Host C compiler command",
            "argparse": {"flags": ("--cc",), "group": "host", "metavar": "<command>"},
        },
        "CXX": {
            "model": Compiler,
            "required": True,
            "description": "Host C++ compiler command",
            "argparse": {"flags": ("--cxx",), "group": "host", "metavar": "<command>"},
        },
        "FC": {
            "model": Compiler,
            "required": True,
            "description": "Host Fortran compiler command",
            "argparse": {"flags": ("--fc",), "group": "host", "metavar": "<command>"},
        },
        "UPC": {
            "model": Compiler,
            "required": False,
            "description": "Universal Parallel C compiler command",
            "argparse": {"flags": ("--upc",), "group": "Universal Parallel C", "metavar": "<command>"},
        },
        "MPI_CC": {
            "model": Compiler,
            "required": False,
            "description": "MPI C compiler command",
            "argparse": {"flags": ("--mpi-cc",), "group": "Message Passing Interface (MPI)", "metavar": "<command>"},
        },
        "MPI_CXX": {
            "model": Compiler,
            "required": False,
            "description": "MPI C++ compiler command",
            "argparse": {"flags": ("--mpi-cxx",), "group": "Message Passing Interface (MPI)", "metavar": "<command>"},
        },
        "MPI_FC": {
            "model": Compiler,
            "required": False,
            "description": "MPI Fortran compiler command",
            "argparse": {"flags": ("--mpi-fc",), "group": "Message Passing Interface (MPI)", "metavar": "<command>"},
        },
        "mpi_include_path": {
            "type": "array",
            "description": "paths to search for MPI header files when building MPI applications",
            "argparse": {
                "flags": ("--mpi-include-path",),
                "group": "Message Passing Interface (MPI)",
                "metavar": "<path>",
                "nargs": "+",
            },
            "compat": {bool: (Target.require("MPI_CC"), Target.require("MPI_CXX"), Target.require("MPI_FC"))},
        },
        "mpi_library_path": {
            "type": "array",
            "description": "paths to search for MPI library files when building MPI applications",
            "argparse": {
                "flags": ("--mpi-library-path",),
                "group": "Message Passing Interface (MPI)",
                "metavar": "<path>",
                "nargs": "+",
            },
            "compat": {bool: (Target.require("MPI_CC"), Target.require("MPI_CXX"), Target.require("MPI_FC"))},
        },
        "mpi_libraries": {
            "type": "array",
            "description": "libraries to link to when building MPI applications",
            "argparse": {
                "flags": ("--mpi-libraries",),
                "group": "Message Passing Interface (MPI)",
                "metavar": "<flag>",
                "nargs": "+",
            },
            "compat": {bool: (Target.require("MPI_CC"), Target.require("MPI_CXX"), Target.require("MPI_FC"))},
        },
        "SHMEM_CC": {
            "model": Compiler,
            "required": False,
            "description": "SHMEM C compiler command",
            "argparse": {
                "flags": ("--shmem-cc",),
                "group": "Symmetric Hierarchical Memory (SHMEM)",
                "metavar": "<command>",
            },
        },
        "SHMEM_CXX": {
            "model": Compiler,
            "required": False,
            "description": "SHMEM C++ compiler command",
            "argparse": {
                "flags": ("--shmem-cxx",),
                "group": "Symmetric Hierarchical Memory (SHMEM)",
                "metavar": "<command>",
            },
        },
        "SHMEM_FC": {
            "model": Compiler,
            "required": False,
            "description": "SHMEM Fortran compiler command",
            "argparse": {
                "flags": ("--shmem-fc",),
                "group": "Symmetric Hierarchical Memory (SHMEM)",
                "metavar": "<command>",
            },
        },
        "shmem_include_path": {
            "type": "array",
            "description": "paths to search for SHMEM header files when building SHMEM applications",
            "argparse": {
                "flags": ("--shmem-include-path",),
                "group": "Symmetric Hierarchical Memory (SHMEM)",
                "metavar": "<path>",
                "nargs": "+",
            },
        },
        "shmem_library_path": {
            "type": "array",
            "description": "paths to search for SHMEM library files when building SHMEM applications",
            "argparse": {
                "flags": ("--shmem-library-path",),
                "group": "Symmetric Hierarchical Memory (SHMEM)",
                "metavar": "<path>",
                "nargs": "+",
            },
        },
        "shmem_libraries": {
            "type": "array",
            "description": "libraries to link to when building SHMEM applications",
            "argparse": {
                "flags": ("--shmem-libraries",),
                "group": "Symmetric Hierarchical Memory (SHMEM)",
                "metavar": "<flag>",
                "nargs": "+",
            },
        },
        "cuda": {
            "type": "string",
            "description": "path to NVIDIA CUDA installation (enables OpenCL support)",
            "argparse": {
                "flags": ("--cuda",),
                "group": "software package",
                "metavar": "<path>",
                "action": ParsePackagePathAction,
            },
        },
        "opencl": {
            "type": "string",
            "description": "path to OpenCL libraries and headers",
            "argparse": {
                "flags": ("--opencl",),
                "group": "software package",
                "metavar": "<path>",
                "action": ParsePackagePathAction,
            },
        },
        "tau_source": {
            "type": "string",
            "description": "path or URL to a TAU installation or archive file",
            "default": "download",
            "argparse": {
                "flags": ("--tau",),
                "group": "software package",
                "metavar": "(<path>|<url>|download)",
                "action": ParsePackagePathAction,
            },
        },
        "pdt_source": {
            "type": "string",
            "description": "path or URL to a PDT installation or archive file",
            "default": "download",
            "argparse": {
                "flags": ("--pdt",),
                "group": "software package",
                "metavar": "(<path>|<url>|download|None)",
                "action": ParsePackagePathAction,
            },
        },
        "binutils_source": {
            "type": "string",
            "description": "path or URL to a GNU binutils installation or archive file",
            "default": "download",
            "argparse": {
                "flags": ("--binutils",),
                "group": "software package",
                "metavar": "(<path>|<url>|download|None)",
                "action": ParsePackagePathAction,
            },
            "compat": {(lambda x: x is not None): (Target.discourage("host_os", DARWIN_OS.name))},
        },
        "libunwind_source": {
            "type": "string",
            "description": "path or URL to a libunwind installation or archive file",
            "default": "download",
            "argparse": {
                "flags": ("--libunwind",),
                "group": "software package",
                "metavar": "(<path>|<url>|download|None)",
                "action": ParsePackagePathAction,
            },
        },
        "papi_source": {
            "type": "string",
            "description": "path or URL to a PAPI installation or archive file",
            "argparse": {
                "flags": ("--papi",),
                "group": "software package",
                "metavar": "(<path>|<url>|download|None)",
                "action": ParsePackagePathAction,
            },
        },
        "scorep_source": {
            "type": "string",
            "description": "path or URL to a Score-P installation or archive file",
            "argparse": {
                "flags": ("--score-p",),
                "group": "software package",
                "metavar": "(<path>|<url>|download|None)",
                "action": ParsePackagePathAction,
            },
        },
    }