From e91983371498cfd87d3f4673d6e5874c9ba03ab9 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 15 Apr 2012 13:56:10 -0700
Subject: volk: work on template stuff
---
volk/gen/volk_arch_defs.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100644 volk/gen/volk_arch_defs.py
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
new file mode 100644
index 000000000..271fc90c7
--- /dev/null
+++ b/volk/gen/volk_arch_defs.py
@@ -0,0 +1,70 @@
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+import os
+import copy
+
+archs = list()
+
+class arch_class:
+ def __init__(self, **kwargs):
+ for key, cast, failval in (
+ ('name', str, None),
+ ('type', str, None),
+ ('no_test', bool, False),
+ ('val', int, None),
+ ('op', eval, None),
+ ('reg', int, None),
+ ('shift', int, None),
+ ('flag', str, None),
+ ('environment', str, None),
+ ('include', str, None),
+ ('alignment', int, 1),
+ ):
+ try: setattr(self, key, cast(kwargs[key]))
+ except: setattr(self, key, failval)
+ assert(self.name)
+ assert(self.type)
+
+ def __repr__(self): return self.name
+
+def register_arch(**kwargs):
+ arch = arch_class(**kwargs)
+ archs.append(arch)
+ if arch.alignment > 1:
+ kwargs['name'] += '_u'
+ kwargs['alignment'] = 1
+ register_arch(**kwargs)
+
+########################################################################
+# register the arches
+########################################################################
+#TODO skip the XML and put it here
+from xml.dom import minidom
+gendir = os.path.dirname(__file__)
+archs_xml = minidom.parse(os.path.join(gendir, 'archs.xml')).getElementsByTagName('arch')
+for arch_xml in archs_xml:
+ kwargs = dict()
+ for attr in arch_xml.attributes.keys():
+ kwargs[attr] = arch_xml.attributes[attr].value
+ for node in arch_xml.childNodes:
+ try:
+ name = node.tagName
+ val = arch_xml.getElementsByTagName(name)[0].firstChild.data
+ kwargs[name] = val
+ except: pass
+ register_arch(**kwargs)
--
cgit
From eccc86fbb8aa0392307bfdf1bd802e4394868334 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 15 Apr 2012 15:38:14 -0700
Subject: volk: added kernel defs and typedefs
---
volk/gen/volk_arch_defs.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 271fc90c7..6869ef7a9 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -15,10 +15,8 @@
# along with this program. If not, see .
#
-import os
-import copy
-
archs = list()
+arch_dict = dict()
class arch_class:
def __init__(self, **kwargs):
@@ -45,6 +43,7 @@ class arch_class:
def register_arch(**kwargs):
arch = arch_class(**kwargs)
archs.append(arch)
+ arch_dict[arch.name] = arch
if arch.alignment > 1:
kwargs['name'] += '_u'
kwargs['alignment'] = 1
@@ -55,6 +54,7 @@ def register_arch(**kwargs):
########################################################################
#TODO skip the XML and put it here
from xml.dom import minidom
+import os
gendir = os.path.dirname(__file__)
archs_xml = minidom.parse(os.path.join(gendir, 'archs.xml')).getElementsByTagName('arch')
for arch_xml in archs_xml:
@@ -68,3 +68,6 @@ for arch_xml in archs_xml:
kwargs[name] = val
except: pass
register_arch(**kwargs)
+
+if __name__ == '__main__':
+ print archs
--
cgit
From 95e91b44d2ef3535129c0a402c51bc56cfd74d06 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 15 Apr 2012 17:32:38 -0700
Subject: volk: created other templates for runtime + machines
---
volk/gen/volk_arch_defs.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 6869ef7a9..c6115d64e 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -18,6 +18,9 @@
archs = list()
arch_dict = dict()
+#TODO enable this when we are ready
+create_unaligned_archs = False
+
class arch_class:
def __init__(self, **kwargs):
for key, cast, failval in (
@@ -44,7 +47,7 @@ def register_arch(**kwargs):
arch = arch_class(**kwargs)
archs.append(arch)
arch_dict[arch.name] = arch
- if arch.alignment > 1:
+ if arch.alignment > 1 and create_unaligned_archs:
kwargs['name'] += '_u'
kwargs['alignment'] = 1
register_arch(**kwargs)
--
cgit
From 37f9a62fd45ece1e6a92769fbb1798403c86ba9b Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 15 Apr 2012 19:11:52 -0700
Subject: volk: working build w/ cmakelists
---
volk/gen/volk_arch_defs.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index c6115d64e..d29a951eb 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -29,7 +29,7 @@ class arch_class:
('no_test', bool, False),
('val', int, None),
('op', eval, None),
- ('reg', int, None),
+ ('reg', str, None),
('shift', int, None),
('flag', str, None),
('environment', str, None),
--
cgit
From 3af0f815ae3442dacdac78acf238b277f472c404 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 00:29:26 -0700
Subject: volk: added compile utils and cleanup cmakelists
---
volk/gen/volk_arch_defs.py | 3 +++
1 file changed, 3 insertions(+)
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index d29a951eb..4f4796840 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -40,6 +40,9 @@ class arch_class:
except: setattr(self, key, failval)
assert(self.name)
assert(self.type)
+ if self.flag == 'none': self.flag = None
+ self.flags = list()
+ if self.flag: self.flags = map(str.strip, self.flag.split(','))
def __repr__(self): return self.name
--
cgit
From 0faf0107e38e93bc3fddf8296449a1439978bec1 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 13:38:44 -0700
Subject: volk: updated build system for avx checking support
updated copy of cpuid.h with the latest from gcc 4.6
---
volk/gen/volk_arch_defs.py | 1 +
1 file changed, 1 insertion(+)
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 4f4796840..fd81eed8c 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -35,6 +35,7 @@ class arch_class:
('environment', str, None),
('include', str, None),
('alignment', int, 1),
+ ('check', str, None),
):
try: setattr(self, key, cast(kwargs[key]))
except: setattr(self, key, failval)
--
cgit
From 0595b7f2283e0aa1cdebefdac2d3a2702324727d Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Mon, 16 Apr 2012 17:18:36 -0700
Subject: Volk: redo the archs.xml language to make checks generic. no more
"type", no more piles of #if crap in the template.
---
volk/gen/volk_arch_defs.py | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index fd81eed8c..d64f8def2 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -22,28 +22,18 @@ arch_dict = dict()
create_unaligned_archs = False
class arch_class:
- def __init__(self, **kwargs):
+ def __init__(self, flags, checks, **kwargs):
for key, cast, failval in (
('name', str, None),
- ('type', str, None),
- ('no_test', bool, False),
- ('val', int, None),
- ('op', eval, None),
- ('reg', str, None),
- ('shift', int, None),
- ('flag', str, None),
('environment', str, None),
('include', str, None),
- ('alignment', int, 1),
- ('check', str, None),
+ ('alignment', int, 1)
):
try: setattr(self, key, cast(kwargs[key]))
except: setattr(self, key, failval)
+ self.checks = checks
assert(self.name)
- assert(self.type)
- if self.flag == 'none': self.flag = None
- self.flags = list()
- if self.flag: self.flags = map(str.strip, self.flag.split(','))
+ self.flags = flags
def __repr__(self): return self.name
@@ -74,7 +64,18 @@ for arch_xml in archs_xml:
val = arch_xml.getElementsByTagName(name)[0].firstChild.data
kwargs[name] = val
except: pass
- register_arch(**kwargs)
+ checks = []
+ for check_xml in arch_xml.getElementsByTagName("check"):
+ name = check_xml.attributes["name"].value
+ params = list()
+ for param_xml in check_xml.getElementsByTagName("param"):
+ params.append(param_xml.firstChild.data)
+ checks.append([name, params])
+ flags = []
+ for flag_xml in arch_xml.getElementsByTagName("flag"):
+ flags.append(flag_xml.firstChild.data)
+
+ register_arch(flags=flags, checks=checks, **kwargs)
if __name__ == '__main__':
print archs
--
cgit
From f70cb7901a43c201242399225d31eed83e7d41ce Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 21:56:01 -0700
Subject: volk: use archs.xml to specify compiler flags + support
---
volk/gen/volk_arch_defs.py | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index d64f8def2..8ac99b338 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -33,7 +33,15 @@ class arch_class:
except: setattr(self, key, failval)
self.checks = checks
assert(self.name)
- self.flags = flags
+ self._flags = flags
+
+ def is_supported(self, compiler):
+ if not self._flags.keys(): return True
+ return compiler in self._flags.keys()
+
+ def get_flags(self, compiler):
+ try: return self._flags[compiler]
+ except KeyError: return list()
def __repr__(self): return self.name
@@ -64,17 +72,18 @@ for arch_xml in archs_xml:
val = arch_xml.getElementsByTagName(name)[0].firstChild.data
kwargs[name] = val
except: pass
- checks = []
+ checks = list()
for check_xml in arch_xml.getElementsByTagName("check"):
name = check_xml.attributes["name"].value
params = list()
for param_xml in check_xml.getElementsByTagName("param"):
params.append(param_xml.firstChild.data)
checks.append([name, params])
- flags = []
+ flags = dict()
for flag_xml in arch_xml.getElementsByTagName("flag"):
- flags.append(flag_xml.firstChild.data)
-
+ name = flag_xml.attributes["compiler"].value
+ if not flags.has_key(name): flags[name] = list()
+ flags[name].append(flag_xml.firstChild.data)
register_arch(flags=flags, checks=checks, **kwargs)
if __name__ == '__main__':
--
cgit
From 954ee16a180e16fbd232f18b0a69eaed55bd7fdd Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 23 Apr 2012 14:07:08 -0700
Subject: volk: force kwargs keys to be of type str, not unicode for py25
---
volk/gen/volk_arch_defs.py | 2 ++
1 file changed, 2 insertions(+)
(limited to 'volk/gen/volk_arch_defs.py')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 8ac99b338..41154d5a7 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -84,6 +84,8 @@ for arch_xml in archs_xml:
name = flag_xml.attributes["compiler"].value
if not flags.has_key(name): flags[name] = list()
flags[name].append(flag_xml.firstChild.data)
+ #force kwargs keys to be of type str, not unicode for py25
+ kwargs = dict((str(k), v) for k, v in kwargs.iteritems())
register_arch(flags=flags, checks=checks, **kwargs)
if __name__ == '__main__':
--
cgit