fixed errors caused by crayport on linux and added a darwin architecture

This commit is contained in:
Gregory Becker 2016-01-05 13:39:53 -08:00
parent a2d8a8b469
commit b62d22a1b3
6 changed files with 62 additions and 24 deletions

View File

@ -96,11 +96,13 @@ def __repr__(self):
return self.__str__() return self.__str__()
def __str__(self): def __str__(self):
if self.module_name:
return self.name + ' module: ' + self.module_name
return self.name return self.name
@key_ordering @key_ordering
class Architecture(object): class Architecture(object):
""" Abstract class that each type of Architecture will subclass. """ Abstract class that each type of Architecture will subclass.
Will return a instance of it once it Will return a instance of it once it
is returned is returned
""" """
@ -150,7 +152,7 @@ def __repr__(self):
def __str__(self): def __str__(self):
return self.name return self.name
def _cmp_key(self): def _cmp_key(self):
return (self.name, (_cmp_key(t) for t in self.targets.values())) return (self.name, (_cmp_key(t) for t in self.targets.values()))

View File

@ -4,27 +4,30 @@
class Cray(Architecture): class Cray(Architecture):
priority = 20 priority = 20
front_end = 'sandybridge' front_end = 'sandybridge'
back_end = 'ivybridge' back_end = 'ivybridge'
default = os.environ['CRAY_CPU_TARGET'] default = 'ivybridge'
#default = 'ivybridge'
def __init__(self): def __init__(self):
''' Since cori doesn't have ivybridge as a front end it's better ''' Since cori doesn't have ivybridge as a front end it's better
if we use CRAY_CPU_TARGET as the default. This will ensure if we use CRAY_CPU_TARGET as the default. This will ensure
that if we're on a XC-40 or XC-30 then we can detect the target that if we're on a XC-40 or XC-30 then we can detect the target
''' '''
super(Cray, self).__init__('cray') super(Cray, self).__init__('cray')
# Handle the default here so we can check for a key error
if 'CRAY_CPU_TARGET' in os.environ:
default = os.environ['CRAY_CPU_TARGET']
# Back End compiler needs the proper target module loaded. # Back End compiler needs the proper target module loaded.
self.add_target(self.front_end, Target(self.front_end,'craype-' + self.front_end)) self.add_target(self.back_end, Target(self.front_end,'craype-'+ self.back_end))
self.add_target(self.default, Target(self.default,'craype-' + self.default)) self.add_target(self.default, Target(self.default,'craype-' + self.default))
# Could switch to use modules and fe targets for front end # Could switch to use modules and fe targets for front end
# Currently using compilers by path for front end. # Currently using compilers by path for front end.
self.add_target(self.back_end, Target('craype-' + self.back_end)) self.add_target(self.front_end, Target(self.front_end))
@classmethod @classmethod
def detect(self): def detect(self):
return os.path.exists('/opt/cray/craype') return os.path.exists('/opt/cray/craype')

View File

@ -0,0 +1,18 @@
import subprocess
from spack.architecture import Architecture, Target
class Darwin(Architecture):
priority = 89
front_end = 'x86_64'
back_end = 'x86_64'
default = 'x86_64'
def __init__(self):
super(Darwin, self).__init__('darwin')
self.add_target(self.default, Target(self.default))
@classmethod
def detect(self):
arch = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE)
arch, _ = arch.communicate()
return 'darwin' in arch.strip().lower()

View File

@ -2,7 +2,7 @@
from spack.architecture import Architecture, Target from spack.architecture import Architecture, Target
class Linux(Architecture): class Linux(Architecture):
priority = 60 priority = 90
front_end = 'x86_64' front_end = 'x86_64'
back_end = 'x86_64' back_end = 'x86_64'
default = 'x86_64' default = 'x86_64'
@ -13,6 +13,6 @@ def __init__(self):
@classmethod @classmethod
def detect(self): def detect(self):
arch = subprocess.Popen(['uname', '-i'], stdout = subprocess.PIPE) arch = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE)
arch, _ = arch.communicate() arch, _ = arch.communicate()
return 'linux' in arch.strip().lower() return 'linux' in arch.strip().lower()

View File

@ -31,7 +31,7 @@
import spack import spack
"""Names of tests to be included in Spack's test suite""" """Names of tests to be included in Spack's test suite"""
"""test_names = ['architecture', test_names = ['architecture',
'versions', 'versions',
'url_parse', 'url_parse',
'url_substitution', 'url_substitution',
@ -58,8 +58,7 @@
'optional_deps', 'optional_deps',
'make_executable', 'make_executable',
'configure_guess'] 'configure_guess']
"""
test_names = ['architecture']
def list_tests(): def list_tests():
"""Return names of all tests that can be run for Spack.""" """Return names of all tests that can be run for Spack."""

View File

@ -2,18 +2,34 @@
the functions are looking for the correct architecture name the functions are looking for the correct architecture name
""" """
import unittest import unittest
import os
import platform
import spack import spack
from spack.architecture import * from spack.architecture import *
from spack.architectures.cray import Cray
from spack.architectures.linux import Linux
from spack.architectures.bgq import Bgq
class ArchitectureTest(unittest.TestCase): class ArchitectureTest(unittest.TestCase):
def test_Architecture_class(self): def test_Architecture_class_and_compiler_strategies(self):
a = Architecture('Cray-XC40') a = Cray()
a.add_arch_strategy() t = a.target('default')
self.assertEquals(a.get_arch_dict(), {'Cray-XC40': 'MODULES'}) self.assertEquals(t.compiler_strategy, 'MODULES')
b = Linux()
s = b.target('default')
self.assertEquals(s.compiler_strategy, 'PATH')
def test_get_sys_type_from_config_file(self): def test_sys_type(self):
output_arch_class = get_sys_type_from_config_file() output_arch_class = sys_type()
my_arch_class = Architecture('Linux x86_64','Cray-xc40') my_arch_class = None
if os.path.exists('/opt/cray/craype'):
my_arch_class = Cray()
elif os.path.exists('/bgsys'):
my_arch_class = Bgq()
elif 'Linux' in platform.system():
my_arch_class = Linux()
# elif 'Darwin' in platform.system():
# my_arch_class = Darwin()
self.assertEqual(output_arch_class, my_arch_class) self.assertEqual(str(output_arch_class), str(my_arch_class))