summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMario Melara <maamelara@gmail.com>2015-10-14 19:41:07 -0700
committerMario Melara <maamelara@gmail.com>2015-10-14 19:41:07 -0700
commit4f21344e87da327b4166fff1fd2ce32afaa07dbc (patch)
treefe3644cc3b5db2e54ce45b8f3b1b5d2d449500c6 /lib
parentb6d2a12ceb090692aa2be363b46d7f25486c0245 (diff)
downloadspack-4f21344e87da327b4166fff1fd2ce32afaa07dbc.tar.gz
spack-4f21344e87da327b4166fff1fd2ce32afaa07dbc.tar.bz2
spack-4f21344e87da327b4166fff1fd2ce32afaa07dbc.tar.xz
spack-4f21344e87da327b4166fff1fd2ce32afaa07dbc.zip
Started created the Architecture class for Spack to use
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/architecture.py73
1 files changed, 57 insertions, 16 deletions
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py
index 0c4b605e91..829aaa4c1c 100644
--- a/lib/spack/spack/architecture.py
+++ b/lib/spack/spack/architecture.py
@@ -30,7 +30,7 @@ from llnl.util.lang import memoized
import spack
import spack.error as serr
from spack.version import Version
-
+from external import yaml
class InvalidSysTypeError(serr.SpackError):
def __init__(self, sys_type):
@@ -43,41 +43,81 @@ class NoSysTypeError(serr.SpackError):
super(NoSysTypeError, self).__init__(
"Could not determine sys_type for this machine.")
+class Architecture(object):
+ def __init__(self, *arch_name):
+
+ """ Constructor for the architecture class. Should return a dictionary of name (grabbed from uname) and a strategy for
+ searching for that architecture's compiler. The target passed to it should be a dictionary of names and strategies.
+ """
+ self.arch_dict = {}
+ self.arch_name = arch_name
+
+ def add_arch_strategy(self):
+ """ Create a dictionary using the tuples of arch_names"""
+ for n in self.arch_name:
+ if 'cray' in n.lower():
+ self.arch_dict[n] = "MODULES"
+ if 'linux' in n.lower() or 'x86_64' in n.lower():
+ self.arch_dict[n] = "PATH"
+ else:
+ self.arch_dict[n] = None
def get_sys_type_from_spack_globals():
- """Return the SYS_TYPE from spack globals, or None if it isn't set."""
+ """Return the SYS_TYPE from spack globals, or None if it isn't set. Front-end"""
if not hasattr(spack, "sys_type"):
- return None
+ return None
elif hasattr(spack.sys_type, "__call__"):
- return spack.sys_type()
+ return Architecture(spack.sys_type())
else:
- return spack.sys_type
-
-
-def get_sys_type_from_environment():
- """Return $SYS_TYPE or None if it's not defined."""
- return os.environ.get('SYS_TYPE')
+ return Architecture(spack.sys_type)
+# This is livermore dependent. Hard coded for livermore
+#def get_sys_type_from_environment():
+# """Return $SYS_TYPE or None if it's not defined."""
+# return os.environ.get('SYS_TYPE')
def get_mac_sys_type():
- """Return a Mac OS SYS_TYPE or None if this isn't a mac."""
+ """Return a Mac OS SYS_TYPE or None if this isn't a mac.
+ Front-end config
+ """
+
mac_ver = py_platform.mac_ver()[0]
if not mac_ver:
return None
- return "macosx_%s_%s" % (
- Version(mac_ver).up_to(2), py_platform.machine())
-
+ return Architecture("macosx_%s_%s" % (Version(mac_ver).up_to(2), py_platform.machine()))
+
+def get_sys_type_from_uname():
+ """ Returns a sys_type from the uname argument
+ Front-end config
+ """
+ return Architecture(os.uname()[0] + " " + os.uname()[-1])
+
+def get_sys_type_from_config_file():
+ """ Should read in a sys_type from the config yaml file. This should be the first thing looked at since
+ The user can specify that the architecture is a cray-xc40
+ """
+
+ home_dir = os.environ["HOME"]
+ yaml_file = os.path.join(home_dir, ".spack/architecture.yaml")
+ if os.path.isfile(yaml_file):
+ with open(yaml_file) as config:
+ config_dict = config['architecture']
+ front_end = config_dict['front']
+ back_end = config_dict['back']
+ return Architecture(front_end)
@memoized
def sys_type():
- """Returns a SysType for the current machine."""
+ """Returns a SysType for the current machine. Should return output to an
+ Architecture class
+ """
methods = [get_sys_type_from_spack_globals,
get_sys_type_from_environment,
get_mac_sys_type]
# search for a method that doesn't return None
- sys_type = None
+ sys_type = (None,None)
for method in methods:
sys_type = method()
if sys_type: break
@@ -90,3 +130,4 @@ def sys_type():
raise InvalidSysTypeError(sys_type)
return sys_type
+