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/archs.xml | 45 +++++++++++++++++++++++++----------------- volk/gen/volk_arch_defs.py | 19 +++++++++++++----- volk/gen/volk_compile_utils.py | 17 +++------------- 3 files changed, 44 insertions(+), 37 deletions(-) (limited to 'volk/gen') diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml index ac4dd9f7f..2c9ab41a5 100644 --- a/volk/gen/archs.xml +++ b/volk/gen/archs.xml @@ -5,21 +5,21 @@ - maltivec + -maltivec 16 - mfpu=neon - mfloat-abi=softfp - funsafe-math-optimizations + -mfpu=neon + -mfloat-abi=softfp + -funsafe-math-optimizations 16 - m32 + -m32 @@ -31,7 +31,7 @@ 0x80000001 29 - m64 + -m64 @@ -40,7 +40,7 @@ 0x80000001 31 - m3dnow + -m3dnow 8 @@ -50,7 +50,7 @@ 0x80000001 5 - msse4.2 + -msse4.2 16 @@ -60,7 +60,8 @@ 0x00000001 23 - mpopcnt + -mpopcnt + /arch:AVX @@ -69,7 +70,8 @@ 0x00000001 23 - mmmx + -mmmx + /arch:SSE 8 @@ -79,7 +81,8 @@ 0x00000001 25 - msse + -msse + /arch:SSE _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); xmmintrin.h 16 @@ -91,7 +94,8 @@ 0x00000001 26 - msse2 + -msse2 + /arch:SSE2 16 @@ -108,7 +112,8 @@ 0x00000001 0 - msse3 + -msse3 + /arch:AVX _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); pmmintrin.h 16 @@ -120,7 +125,8 @@ 0x00000001 9 - mssse3 + -mssse3 + /arch:AVX 16 @@ -130,7 +136,7 @@ 0x80000001 6 - msse4a + -msse4a 16 @@ -140,7 +146,8 @@ 0x00000001 19 - msse4.1 + -msse4.1 + /arch:AVX 16 @@ -150,7 +157,8 @@ 0x00000001 20 - msse4.2 + -msse4.2 + /arch:AVX 16 @@ -168,7 +176,8 @@ - mavx + -mavx + /arch:AVX 32 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__': diff --git a/volk/gen/volk_compile_utils.py b/volk/gen/volk_compile_utils.py index a62c5657e..cd9f9f0a9 100644 --- a/volk/gen/volk_compile_utils.py +++ b/volk/gen/volk_compile_utils.py @@ -19,21 +19,11 @@ import optparse import volk_arch_defs import volk_machine_defs -def format_flag(flag, compiler): - if compiler == 'msvc' and flag in ('mmmx', 'msse'): - return '/arch:SSE' - if compiler == 'msvc' and flag in ('msse2',): - return '/arch:SSE2' - if compiler == 'msvc' and flag in ('msse3', 'mssse3', 'msse4.1', 'msse4.2', 'mpopcnt', 'mavx'): - return '/arch:AVX' - #otherwise its a gcc compiler - return '-' + flag - def do_arch_flags_list(compiler): output = list() for arch in volk_arch_defs.archs: - fields = [arch.name] - fields += list(map(lambda f: format_flag(f, compiler), arch.flags)) + if not arch.is_supported(compiler): continue + fields = [arch.name] + arch.get_flags(compiler) output.append(','.join(fields)) print ';'.join(output) @@ -49,8 +39,7 @@ def do_machine_flags_list(compiler, machine_name): output = list() machine = volk_machine_defs.machine_dict[machine_name] for arch in machine.archs: - for flag in arch.flags: - output.append(format_flag(flag, compiler)) + output.extend(arch.get_flags(compiler)) print ' '.join(output) def main(): -- cgit