Example #1
0
def operating_system():
    """Detect the host's operating system.
    
    Mostly relies on Python's platform module but may also probe 
    environment variables and file systems in cases where the arch
    isn't immediately known to Python.  These tests may be expensive
    so the detected value is cached to improve performance.
    
    Returns:
        OperatingSystem: The matching operating system description.
        
    Raises:
        ConfigurationError: Host operating system not supported.
    """
    try:
        inst = operating_system.inst
    except AttributeError:
        arch = architecture()
        if 'CRAYOS_VERSION' in os.environ or 'PE_ENV' in os.environ:
            inst = CRAY_CNL_OS
        elif arch in [IBM_BGP_ARCH, IBM_BGQ_ARCH]:
            inst = IBM_CNK_OS
        else:
            python_os = platform.system()
            try:
                inst = OperatingSystem.find(python_os)
            except KeyError:
                raise ConfigurationError("Host operating system '%s' is not yet supported" % python_os)
        operating_system.inst = inst
    return inst
Example #2
0
 def uses_libunwind(self):
     populated = self.populate()
     host_os = OperatingSystem.find(populated['target']['host_os'])
     return (host_os is not DARWIN_OS and
             (populated['measurement']['sample'] or 
              populated['measurement']['compiler_inst'] != 'never' or 
              populated['application']['openmp']))
Example #3
0
 def __init__(self, name, prefix, src, dst, target_arch, target_os, compilers, 
              sources, commands, libraries):
     """Initializes the installation object.
     
     To set up a new installation, pass `src` as a URL, file path, or the special keyword 'download'.
     Attributes `src` and `src_prefix` will be set to the appropriate paths.
     
     To set up an interface to an existing installation, pass ``src=/path/to/existing/installation``. 
     Attributes `src` and `src_prefix` will be set to None.
     
     Args:
         name (str): Human readable name of the software package, e.g. 'TAU'.
         prefix (str): Path to a directory to contain subdirectories for 
                       installation files, source file, and compilation files.
         src (str): Path to a directory where the software has already been 
                    installed, or a path to a source archive file, or the special
                    keyword 'download'.
         dst (str): Installation destination to be created below `prefix`.
         target_arch (str): Target architecture name.
         target_os (str): Target operating system name.
         compilers (InstalledCompilerSet): Compilers to use if software must be compiled.
         sources (dict): Dictionary of URLs for source code archives indexed by architecture and OS.  
                         `None` specifies the default (i.e. universal) source.
         commands (dict): Dictionary of commands that must be installed indexed by architecture and OS.
                          `None` specifies the universal commands.
         libraries (dict): Dictionary of libraries that must be installed indexed by architecture and OS.
                           `None` specifies the universal libraries.
     """
     self.name = name
     self.prefix = prefix
     self.target_arch = Architecture.find(target_arch)
     self.target_os = OperatingSystem.find(target_os)
     self.compilers = compilers
     self.archive_prefix = os.path.join(prefix, 'src')
     self.src_prefix = None
     if os.path.isdir(src):
         self.src = None
         self.install_prefix = src
     else:
         if src.lower() == 'download':
             self.src = self._lookup_target_os_list(sources)
         else:
             self.src = src
         md5sum = hashlib.md5()
         md5sum.update(self.src)
         self.install_prefix = os.path.join(prefix, dst, name, md5sum.hexdigest())
     self.commands = self._lookup_target_os_list(commands)
     self.libraries = self._lookup_target_os_list(libraries)
     self.include_path = os.path.join(self.install_prefix, 'include')
     self.bin_path = os.path.join(self.install_prefix, 'bin')
     self.lib_path = os.path.join(self.install_prefix, 'lib')
     self._lockfile = LockFile(os.path.join(self.install_prefix, '.tau_lock'))
     LOGGER.debug("%s installation prefix is %s", self.name, self.install_prefix)
Example #4
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,
            },
        },
    }