diff options
author | Josh Blum | 2012-04-15 19:11:52 -0700 |
---|---|---|
committer | Josh Blum | 2012-04-19 18:12:55 -0700 |
commit | 37f9a62fd45ece1e6a92769fbb1798403c86ba9b (patch) | |
tree | 5593d79e550e30ff8fce9a5c39d49238bd196979 /volk | |
parent | 95e91b44d2ef3535129c0a402c51bc56cfd74d06 (diff) | |
download | gnuradio-37f9a62fd45ece1e6a92769fbb1798403c86ba9b.tar.gz gnuradio-37f9a62fd45ece1e6a92769fbb1798403c86ba9b.tar.bz2 gnuradio-37f9a62fd45ece1e6a92769fbb1798403c86ba9b.zip |
volk: working build w/ cmakelists
Diffstat (limited to 'volk')
-rw-r--r-- | volk/gen/volk_arch_defs.py | 2 | ||||
-rw-r--r-- | volk/gen/volk_kernel_defs.py | 14 | ||||
-rw-r--r-- | volk/gen/volk_tmpl_utils.py | 3 | ||||
-rw-r--r-- | volk/gen/volk_xml_utils.py | 103 | ||||
-rw-r--r-- | volk/lib/CMakeLists.txt | 50 | ||||
-rw-r--r-- | volk/tmpl/volk.tmpl.c | 6 | ||||
-rw-r--r-- | volk/tmpl/volk_cpu.tmpl.c | 3 | ||||
-rw-r--r-- | volk/tmpl/volk_machine_xxx.tmpl.c | 23 | ||||
-rw-r--r-- | volk/tmpl/volk_typedefs.tmpl.h | 2 |
9 files changed, 60 insertions, 146 deletions
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), diff --git a/volk/gen/volk_kernel_defs.py b/volk/gen/volk_kernel_defs.py index a5c7cb710..52cdb684c 100644 --- a/volk/gen/volk_kernel_defs.py +++ b/volk/gen/volk_kernel_defs.py @@ -202,8 +202,18 @@ class kernel_class: self.arglist_defs = my_argtypelist[index] self.arglist_namedefs = arched_arglist[index] self.arglist_names = my_arglist[index] - self.tagdeps = fcountlist[index] - self.taglist = taglist[index] + self._tagdeps = fcountlist[index] + self._taglist = taglist[index] + + def get_tags(self, archs): + def is_in(x): return x.lower() in archs + taglist = list() + tagdeps = list() + for i in range(len(self._tagdeps)): + if all(map(is_in, self._tagdeps[i])): + taglist.append(self._taglist[i]) + tagdeps.append(self._tagdeps[i]) + return taglist, tagdeps def __repr__(self): return self.name diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py index 92b7fb1a4..9d7a0d0e5 100644 --- a/volk/gen/volk_tmpl_utils.py +++ b/volk/gen/volk_tmpl_utils.py @@ -63,7 +63,8 @@ def __parse_tmpl(_tmpl, **kwargs): if __name__ == '__main__': input_file = sys.argv[1] output_file = sys.argv[2] - which = sys.argv[3] + try: which = sys.argv[3] + except: which = '' output = __parse_tmpl(open(input_file).read(), which=which) if output_file: open(output_file, 'w').write(output) else: print output diff --git a/volk/gen/volk_xml_utils.py b/volk/gen/volk_xml_utils.py deleted file mode 100644 index 05c0e1193..000000000 --- a/volk/gen/volk_xml_utils.py +++ /dev/null @@ -1,103 +0,0 @@ -# -# 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 <http://www.gnu.org/licenses/>. -# - -#this would not be necessary if we just skipped the xml part and stored the data in python - -import os -from xml.dom import minidom -import copy - -gendir = os.path.dirname(__file__) -archs_xml = minidom.parse(os.path.join(gendir, 'archs.xml')).getElementsByTagName('arch') -machines_xml = minidom.parse(os.path.join(gendir, 'machines.xml')).getElementsByTagName('machine') -compilers_xml = minidom.parse(os.path.join(gendir, 'compilers.xml')).getElementsByTagName('compiler') - -class arch_class: - def __init__(self, arch_xml): - self.name = arch_xml.attributes['name'].value - self.type = arch_xml.attributes['type'].value - for key in ('val', 'op', 'reg', 'shift', 'flag', 'environment', 'include', 'alignment'): - try: setattr(self, key, arch_xml.getElementsByTagName(key)[0].firstChild.data) - except: setattr(self, key, None) - if self.alignment is None: self.alignment = 1 - - def __repr__(self): return self.name - -def get_archs(): - adict = dict([(a.name, a) for a in map(arch_class, archs_xml)]) - udict = dict() - for name, arch in adict.iteritems(): - if arch.alignment == 1: continue - uarch = copy.deepcopy(arch) - uarch.name = arch.name + '_u' - uarch.alignment = 1 - udict[uarch.name] = uarch - adict.update(udict) - return adict - -volk_archs = get_archs() - -class machine_class: - def __init__(self, name, archlist): - self.name = name - self.archs = list() - for arch_name in archlist: - if not arch_name: continue - self.archs.append(volk_archs[arch_name]) - if volk_archs.has_key(arch_name + '_u'): - self.archs.append(volk_archs[arch_name + '_u']) - - def __repr__(self): return self.name - -def yield_machines(name, archlist): - for i, arch_name in enumerate(archlist): - if '|' in arch_name: - for arch_sub in arch_name.split('|'): - for m in yield_machines(name, archlist[:i] + [arch_sub] + archlist[i+1:]): - yield m - return - yield machine_class(name, archlist) - -def get_machines(): - mdict = dict() - for machine_xml in machines_xml: - name = machine_xml.attributes['name'].value - archlist = machine_xml.getElementsByTagName('archs')[0].firstChild.data.split() - for machine in yield_machines(name, archlist): - mdict[machine.name] = machine - return mdict - -volk_machines = get_machines() - -class compiler_class: - def __init__(self, compiler_xml): - self.name = compiler_xml.attributes['name'].value - self.prefix = compiler_xml.getElementsByTagName('prefix')[0].firstChild.data - self._remap = dict() - for remap_xml in compiler_xml.getElementsByTagName('remap'): - self._remap[remap_xml.attributes['name'].value] = remap_xml.firstChild.data - - def remap(self, option): - if not self._remap.has_key(option): return option - return self._remap[option] - - def __repr__(self): return self.name - -def get_compilers(): - return dict([(c.name, c) for c in map(compiler_class, compilers_xml)]) - -volk_compilers = get_compilers() diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt index b491f94bb..c6187f35d 100644 --- a/volk/lib/CMakeLists.txt +++ b/volk/lib/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011-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 @@ -224,34 +224,36 @@ message(STATUS "Available machines: ${available_machines}") ######################################################################## # Create rules to run the volk generator ######################################################################## -#list of the generated sources -set(volk_gen_sources - ${CMAKE_BINARY_DIR}/include/volk/volk.h - ${CMAKE_BINARY_DIR}/lib/volk.c - ${CMAKE_BINARY_DIR}/lib/volk_init.h - ${CMAKE_BINARY_DIR}/include/volk/volk_typedefs.h - ${CMAKE_BINARY_DIR}/include/volk/volk_cpu.h - ${CMAKE_BINARY_DIR}/lib/volk_cpu.c - ${CMAKE_BINARY_DIR}/include/volk/volk_config_fixed.h - ${CMAKE_BINARY_DIR}/lib/volk_environment_init.c - ${CMAKE_BINARY_DIR}/lib/volk_environment_init.h - ${CMAKE_BINARY_DIR}/lib/volk_machines.h - ${CMAKE_BINARY_DIR}/lib/volk_machines.c - ${machine_sources} -) - #dependencies are all python, xml, and header implementation files file(GLOB xml_files ${CMAKE_SOURCE_DIR}/gen/*.xml) file(GLOB py_files ${CMAKE_SOURCE_DIR}/gen/*.py) file(GLOB h_files ${CMAKE_SOURCE_DIR}/include/volk/*.h) -add_custom_command( - OUTPUT ${volk_gen_sources} - DEPENDS ${xml_files} ${py_files} ${h_files} - COMMAND ${PYTHON_EXECUTABLE} -B - ${CMAKE_SOURCE_DIR}/gen/volk_register.py - ${CMAKE_BINARY_DIR} -) +macro(gen_template tmpl output) + list(APPEND volk_gen_sources ${output}) + add_custom_command( + OUTPUT ${output} + DEPENDS ${xml_files} ${py_files} ${h_files} ${tmpl} + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/gen/volk_tmpl_utils.py ${tmpl} ${output} ${ARGN} + ) +endmacro(gen_template) + +gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk.tmpl.h ${CMAKE_BINARY_DIR}/include/volk/volk.h) +gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk.tmpl.c ${CMAKE_BINARY_DIR}/lib/volk.c) +gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_typedefs.tmpl.h ${CMAKE_BINARY_DIR}/include/volk/volk_typedefs.h) +gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_cpu.tmpl.h ${CMAKE_BINARY_DIR}/include/volk/volk_cpu.h) +gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_cpu.tmpl.c ${CMAKE_BINARY_DIR}/lib/volk_cpu.c) +gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_config_fixed.tmpl.h ${CMAKE_BINARY_DIR}/include/volk/volk_config_fixed.h) +gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_machines.tmpl.h ${CMAKE_BINARY_DIR}/lib/volk_machines.h) +gen_template(${CMAKE_SOURCE_DIR}/tmpl/volk_machines.tmpl.c ${CMAKE_BINARY_DIR}/lib/volk_machines.c) + +foreach(name ${available_machines}) + gen_template( + ${CMAKE_SOURCE_DIR}/tmpl/volk_machine_xxx.tmpl.c + ${CMAKE_CURRENT_BINARY_DIR}/volk_machine_${name}.c + ${name} + ) +endforeach(name) ######################################################################## # Set local include directories first diff --git a/volk/tmpl/volk.tmpl.c b/volk/tmpl/volk.tmpl.c index 161f49a43..c3a1544ff 100644 --- a/volk/tmpl/volk.tmpl.c +++ b/volk/tmpl/volk.tmpl.c @@ -56,7 +56,7 @@ unsigned int volk_get_alignment(void) { #for $kern in $kernels -void get_$(kern.name)($kern.arglist_defs) { +void get_$(kern.name)($kern.arglist_namedefs) { $kern.name = get_machine()->$(kern.name)_archs[volk_rank_archs( get_machine()->$(kern.name)_indices, get_machine()->$(kern.name)_arch_defs, @@ -69,7 +69,7 @@ void get_$(kern.name)($kern.arglist_defs) { $kern.pname $kern.name = &get_$(kern.name); -void $(kern.name)_manual($kern.arglist_defs, const char* arch) { +void $(kern.name)_manual($kern.arglist_namedefs, const char* arch) { const size_t index = get_index( get_machine()->$(kern.name)_indices, get_machine()->$(kern.name)_n_archs, @@ -80,7 +80,7 @@ void $(kern.name)_manual($kern.arglist_defs, const char* arch) { ); } -struct volk_func_desc volk_32f_x2_add_32f_a_get_func_desc(void) { +struct volk_func_desc $(kern.name)_get_func_desc(void) { struct volk_func_desc desc = { get_machine()->$(kern.name)_indices, get_machine()->$(kern.name)_arch_defs, diff --git a/volk/tmpl/volk_cpu.tmpl.c b/volk/tmpl/volk_cpu.tmpl.c index dc24309f7..c278afc2e 100644 --- a/volk/tmpl/volk_cpu.tmpl.c +++ b/volk/tmpl/volk_cpu.tmpl.c @@ -77,7 +77,7 @@ static inline unsigned int cpuid_edx(unsigned int op) { #endif static int has_neon(void){ -#ifdef LOOK_FOR_NEON +#if defined(LOOK_FOR_NEON) FILE *auxvec_f; unsigned long auxvec[2]; unsigned int found_neon = 0; @@ -97,6 +97,7 @@ static int has_neon(void){ #else return 0; +#endif } static int has_ppc(void){ diff --git a/volk/tmpl/volk_machine_xxx.tmpl.c b/volk/tmpl/volk_machine_xxx.tmpl.c index 57e652e4c..87204ee99 100644 --- a/volk/tmpl/volk_machine_xxx.tmpl.c +++ b/volk/tmpl/volk_machine_xxx.tmpl.c @@ -20,6 +20,7 @@ */ #set $this_machine = $machine_dict[$which] +#set $arch_names = map(lambda a: a.name, $this_machine.archs) #for $arch in $this_machine.archs #define LV_HAVE_$(arch.name.upper()) 1 @@ -58,30 +59,32 @@ $(' | '.join(['(1 << LV_%s)'%a.name.upper() for a in $archs]))#slurp #end def #ifdef LV_HAVE_ORC -struct volk_machine volk_machine_generic = { +struct volk_machine volk_machine_$(this_machine.name) = { $make_arch_have_list($this_machine.archs) | (1 << LV_ORC), "$this_machine.name", $this_machine.alignment, #for $kern in $kernels + #set $taglist, $tagdeps = $kern.get_tags($arch_names + ["orc"]) "$kern.name", - $make_tag_str_list($kern.taglist), - $make_tag_have_list($kern.tagdeps), - $make_tag_kern_list($kern.name, $kern.taglist), - $(len($kern.taglist)), + $make_tag_str_list($taglist), + $make_tag_have_list($tagdeps), + $make_tag_kern_list($kern.name, $taglist), + $(len($taglist)), #end for }; #else -struct volk_machine volk_machine_generic = { +struct volk_machine volk_machine_$(this_machine.name) = { $make_arch_have_list($this_machine.archs), "$this_machine.name", $this_machine.alignment, #for $kern in $kernels + #set $taglist, $tagdeps = $kern.get_tags($arch_names) "$kern.name", - $make_tag_str_list($kern.taglist), - $make_tag_have_list($kern.tagdeps), - $make_tag_kern_list($kern.name, $kern.taglist), - $(len($kern.taglist)), + $make_tag_str_list($taglist), + $make_tag_have_list($tagdeps), + $make_tag_kern_list($kern.name, $taglist), + $(len($taglist)), #end for }; diff --git a/volk/tmpl/volk_typedefs.tmpl.h b/volk/tmpl/volk_typedefs.tmpl.h index 2577df14e..52a87242f 100644 --- a/volk/tmpl/volk_typedefs.tmpl.h +++ b/volk/tmpl/volk_typedefs.tmpl.h @@ -26,7 +26,7 @@ #include <volk/volk_complex.h> #for $kern in $kernels -typedef $kern.rettype (*$(kern.pname))($kern.arglist); +typedef $kern.rettype (*$(kern.pname))($kern.arglist_defs); #end for #endif /*INCLUDED_VOLK_TYPEDEFS*/ |