def _default_target_from_env(self): '''Set and return the default CrayPE target loaded in a clean login session. A bash subshell is launched with a wiped environment and the list of loaded modules is parsed for the first acceptable CrayPE target. ''' # env -i /bin/bash -lc echo $CRAY_CPU_TARGET 2> /dev/null if getattr(self, 'default', None) is None: bash = Executable('/bin/bash') output = bash('--norc', '--noprofile', '-lc', 'echo $CRAY_CPU_TARGET', env={'TERM': os.environ.get('TERM', '')}, output=str, error=os.devnull) default_from_module = ''.join(output.split()) # rm all whitespace if default_from_module: tty.debug("Found default module:%s" % default_from_module) return default_from_module else: front_end = cpu.host().name if front_end in list( map(lambda x: _target_name_from_craype_target_name(x), self._avail_targets())): tty.debug("default to front-end architecture") return cpu.host().name else: return platform.machine()
def _default_make_compilers(cmp_id, paths): operating_system, compiler_name, version = cmp_id compiler_cls = spack.compilers.class_for_compiler_name(compiler_name) spec = spack.spec.CompilerSpec(compiler_cls.name, version) paths = [paths.get(x, None) for x in ('cc', 'cxx', 'f77', 'fc')] target = cpu.host() compiler = compiler_cls(spec, operating_system, str(target.family), paths) return [compiler]
def compatible_sys_types(): """Returns a list of all the systypes compatible with the current host.""" compatible_archs = [] current_host = cpu.host() compatible_targets = [current_host] + current_host.ancestors for target in compatible_targets: arch = Arch(platform(), 'default_os', target) compatible_archs.append(str(arch)) return compatible_archs
def __init__(self): super(Linux, self).__init__('linux') for name in cpu.targets: self.add_target(name, Target(name)) # Get specific default self.default = cpu.host().name self.front_end = self.default self.back_end = self.default linux_dist = LinuxDistro() self.default_os = str(linux_dist) self.front_os = self.default_os self.back_os = self.default_os self.add_operating_system(str(linux_dist), linux_dist)
def __init__(self): super(Darwin, self).__init__('darwin') for name in cpu.targets: self.add_target(name, Target(name)) self.default = cpu.host().name self.front_end = self.default self.back_end = self.default mac_os = MacOs() self.default_os = str(mac_os) self.front_os = str(mac_os) self.back_os = str(mac_os) self.add_operating_system(str(mac_os), mac_os)
def __init__(self): ''' Create a Cray system platform. Target names should use craype target names but not include the 'craype-' prefix. Uses first viable target from: self envars [SPACK_FRONT_END, SPACK_BACK_END] configuration file "targets.yaml" with keys 'front_end', 'back_end' scanning /etc/bash/bashrc.local for back_end only ''' super(Cray, self).__init__('cray') # Make all craype targets available. for target in self._avail_targets(): name = _target_name_from_craype_target_name(target) self.add_target(name, Target(name, 'craype-%s' % target)) self.back_end = os.environ.get('SPACK_BACK_END', self._default_target_from_env()) self.default = self.back_end if self.back_end not in self.targets: # We didn't find a target module for the backend raise NoPlatformError() # Setup frontend targets for name in cpu.targets: if name not in self.targets: self.add_target(name, Target(name)) self.front_end = os.environ.get('SPACK_FRONT_END', cpu.host().name) if self.front_end not in self.targets: self.add_target(self.front_end, Target(self.front_end)) front_distro = CrayFrontend() back_distro = CrayBackend() self.default_os = str(back_distro) self.back_os = self.default_os self.front_os = str(front_distro) self.add_operating_system(self.back_os, back_distro) if self.front_os != self.back_os: self.add_operating_system(self.front_os, front_distro)