From a5e2d9e5baf869ae961fbb5820447290d6d9c7c8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 26 Apr 2011 21:55:48 -0700 Subject: volk: reorganization of generation sources and generated files All generation sources have been moved to the gen/ subdirectory. Bootstrap and volk_register.py generate the files into to gen/ subdirectory in an effort to cleanly separate the static/generated parts of the build tree. Define top_gendir in Makefile.common, all generated sources listed in Makefile.ams are prefixed with $(top_gendir) to differentiate them from static in-tree sources. --- volk/Makefile.am | 4 +- volk/Makefile.common | 2 + volk/bootstrap | 6 +- volk/config/Makefile.am | 2 +- volk/gen/.gitignore | 3 + volk/gen/archs.xml | 137 ++++++++++++ volk/gen/emit_omnilog.py | 13 ++ volk/gen/machines.xml | 49 +++++ volk/gen/make_c.py | 100 +++++++++ volk/gen/make_config_fixed.py | 21 ++ volk/gen/make_config_in.py | 13 ++ volk/gen/make_cpuid_c.py | 184 ++++++++++++++++ volk/gen/make_cpuid_h.py | 48 +++++ volk/gen/make_each_machine_c.py | 82 +++++++ volk/gen/make_environment_init_c.py | 32 +++ volk/gen/make_environment_init_h.py | 18 ++ volk/gen/make_h.py | 39 ++++ volk/gen/make_machines_c.py | 57 +++++ volk/gen/make_machines_h.py | 50 +++++ volk/gen/make_makefile_am.py | 119 +++++++++++ volk/gen/make_proccpu_sim.py | 47 +++++ volk/gen/make_registry.py | 85 ++++++++ volk/gen/make_set_simd.py | 166 +++++++++++++++ volk/gen/make_typedefs.py | 23 ++ volk/gen/volk_regexp.py | 14 ++ volk/gen/volk_register.py | 305 +++++++++++++++++++++++++++ volk/include/volk/.gitignore | 15 -- volk/include/volk/Makefile.am | 28 +-- volk/include/volk/archs.xml | 137 ------------ volk/include/volk/emit_omnilog.py | 13 -- volk/include/volk/machines.xml | 49 ----- volk/include/volk/make_c.py | 100 --------- volk/include/volk/make_config_fixed.py | 21 -- volk/include/volk/make_config_in.py | 13 -- volk/include/volk/make_cpuid_c.py | 184 ---------------- volk/include/volk/make_cpuid_h.py | 48 ----- volk/include/volk/make_each_machine_c.py | 82 ------- volk/include/volk/make_environment_init_c.py | 32 --- volk/include/volk/make_environment_init_h.py | 18 -- volk/include/volk/make_h.py | 39 ---- volk/include/volk/make_machines_c.py | 57 ----- volk/include/volk/make_machines_h.py | 50 ----- volk/include/volk/make_makefile_am.py | 131 ------------ volk/include/volk/make_proccpu_sim.py | 47 ----- volk/include/volk/make_registry.py | 85 -------- volk/include/volk/make_set_simd.py | 166 --------------- volk/include/volk/make_typedefs.py | 23 -- volk/include/volk/volk_regexp.py | 14 -- volk/include/volk/volk_register.py | 291 ------------------------- volk/lib/.gitignore | 14 -- 50 files changed, 1622 insertions(+), 1654 deletions(-) create mode 100644 volk/gen/.gitignore create mode 100644 volk/gen/archs.xml create mode 100644 volk/gen/emit_omnilog.py create mode 100644 volk/gen/machines.xml create mode 100644 volk/gen/make_c.py create mode 100644 volk/gen/make_config_fixed.py create mode 100644 volk/gen/make_config_in.py create mode 100644 volk/gen/make_cpuid_c.py create mode 100644 volk/gen/make_cpuid_h.py create mode 100644 volk/gen/make_each_machine_c.py create mode 100644 volk/gen/make_environment_init_c.py create mode 100644 volk/gen/make_environment_init_h.py create mode 100644 volk/gen/make_h.py create mode 100644 volk/gen/make_machines_c.py create mode 100644 volk/gen/make_machines_h.py create mode 100644 volk/gen/make_makefile_am.py create mode 100644 volk/gen/make_proccpu_sim.py create mode 100644 volk/gen/make_registry.py create mode 100644 volk/gen/make_set_simd.py create mode 100644 volk/gen/make_typedefs.py create mode 100644 volk/gen/volk_regexp.py create mode 100755 volk/gen/volk_register.py delete mode 100644 volk/include/volk/archs.xml delete mode 100644 volk/include/volk/emit_omnilog.py delete mode 100644 volk/include/volk/machines.xml delete mode 100644 volk/include/volk/make_c.py delete mode 100644 volk/include/volk/make_config_fixed.py delete mode 100644 volk/include/volk/make_config_in.py delete mode 100644 volk/include/volk/make_cpuid_c.py delete mode 100644 volk/include/volk/make_cpuid_h.py delete mode 100644 volk/include/volk/make_each_machine_c.py delete mode 100644 volk/include/volk/make_environment_init_c.py delete mode 100644 volk/include/volk/make_environment_init_h.py delete mode 100644 volk/include/volk/make_h.py delete mode 100644 volk/include/volk/make_machines_c.py delete mode 100644 volk/include/volk/make_machines_h.py delete mode 100644 volk/include/volk/make_makefile_am.py delete mode 100644 volk/include/volk/make_proccpu_sim.py delete mode 100644 volk/include/volk/make_registry.py delete mode 100644 volk/include/volk/make_set_simd.py delete mode 100644 volk/include/volk/make_typedefs.py delete mode 100644 volk/include/volk/volk_regexp.py delete mode 100755 volk/include/volk/volk_register.py (limited to 'volk') diff --git a/volk/Makefile.am b/volk/Makefile.am index cf55c76fa..829c37b78 100644 --- a/volk/Makefile.am +++ b/volk/Makefile.am @@ -38,7 +38,6 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = volk.pc distclean-local: - -rm -f config/lv_set_simd_flags.m4 -rm -rf autom4te.cache -rm -f config.* -rm -f depcomp @@ -61,3 +60,6 @@ distclean-local: -rm -f configure -rm -f orc/Makefile.in -rm -f orc/*.c + -rm -rf gen/config + -rm -rf gen/include + -rm -rf gen/lib diff --git a/volk/Makefile.common b/volk/Makefile.common index 2184f3375..b9949cb33 100644 --- a/volk/Makefile.common +++ b/volk/Makefile.common @@ -20,6 +20,8 @@ # Boston, MA 02110-1301, USA. # +#define gendir for files generated during bootstrap +top_gendir = $(top_srcdir)/gen ourincludedir = $(includedir)/volk diff --git a/volk/bootstrap b/volk/bootstrap index ff239c88c..a7fb78ac5 100755 --- a/volk/bootstrap +++ b/volk/bootstrap @@ -20,8 +20,10 @@ # Boston, MA 02110-1301, USA. rm -fr config.cache autom4te*.cache -cd include/volk && chmod +x volk_register.py && ./volk_register.py && cd ../.. -aclocal -I config +python -B gen/volk_register.py +mv gen/lib/Makefile.am lib/ + +aclocal -I config -I gen/config autoconf autoheader libtoolize --automake diff --git a/volk/config/Makefile.am b/volk/config/Makefile.am index e5b7281e6..d4786f83a 100644 --- a/volk/config/Makefile.am +++ b/volk/config/Makefile.am @@ -42,7 +42,7 @@ m4macros = \ lf_cxx.m4 \ lf_warnings.m4 \ lf_x11.m4 \ - lv_set_simd_flags.m4 \ + $(top_gendir)/config/lv_set_simd_flags.m4 \ mkstemp.m4 \ onceonly.m4 \ pkg.m4 \ diff --git a/volk/gen/.gitignore b/volk/gen/.gitignore new file mode 100644 index 000000000..a1c468f93 --- /dev/null +++ b/volk/gen/.gitignore @@ -0,0 +1,3 @@ +/config +/include +/lib diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml new file mode 100644 index 000000000..977cc7924 --- /dev/null +++ b/volk/gen/archs.xml @@ -0,0 +1,137 @@ + + + + + none + + + + maltivec + + + + m32 + MD_SUBCPU + x86_64 + + + + 0x80000001 + d + 29 + m64 + 1 + MD_SUBCPU + x86 + + + + 0x80000001 + d + 31 + m3dnow + 1 + + + + 1 + 0x80000001 + d + 5 + sse4.2 + + + + 1 + 1 + c + 23 + mpopcnt + + + + 1 + 1 + d + 23 + mmmx + + + + + 1 + 1 + d + 25 + msse + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); + xmmintrin.h + + + + + 1 + 1 + d + 26 + msse2 + + + + lorc-0.4 + LV_HAVE_ORC + no + + + + 1 + 1 + c + 0 + msse3 + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); + pmmintrin.h + + + + 1 + 1 + c + 9 + mssse3 + + + + 1 + 0x80000001 + c + 6 + msse4a + + + + + 1 + 1 + c + 19 + msse4.1 + + + + 1 + 1 + c + 20 + msse4.2 + + + + 1 + 1 + c + 28 + mavx + + + diff --git a/volk/gen/emit_omnilog.py b/volk/gen/emit_omnilog.py new file mode 100644 index 000000000..309d7e578 --- /dev/null +++ b/volk/gen/emit_omnilog.py @@ -0,0 +1,13 @@ +def emit_prolog(): + tempstring = ""; + tempstring = tempstring + '#ifdef __cplusplus\n'; + tempstring = tempstring + 'extern "C" {\n'; + tempstring = tempstring + '#endif\n'; + return tempstring; +def emit_epilog(): + tempstring = ""; + tempstring = tempstring + '#ifdef __cplusplus\n'; + tempstring = tempstring + '}\n'; + tempstring = tempstring + '#endif\n'; + return tempstring; + diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml new file mode 100644 index 000000000..ad71da177 --- /dev/null +++ b/volk/gen/machines.xml @@ -0,0 +1,49 @@ + + + +generic + + + + + +generic 32|64 mmx sse sse2 + + + +generic 32|64 mmx sse sse2 sse3 + + + +generic 32|64 mmx sse sse2 sse3 ssse3 + + + +generic 32|64 mmx sse sse2 sse3 sse4_a popcount + + + +generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 + + + +generic 32|64 mmx sse sse2 sse3 ssse3 sse4_2 popcount + + + +generic 32|64 mmx sse sse2 sse3 ssse3 sse4_2 popcount avx + + + +generic altivec + + + diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py new file mode 100644 index 000000000..591e8b64c --- /dev/null +++ b/volk/gen/make_c.py @@ -0,0 +1,100 @@ +# +# Copyright 2010 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 . +# + +from volk_regexp import * +import string +from emit_omnilog import * + +#ok todo list: +#put n_archs into the info struct so it doesn't have to be arch_defs[0]. + +def make_c(machines, archs, functions, arched_arglist, my_arglist): + tempstring = r""" +// This file is automatically generated by make_c.py. +// Do not edit this file. +""" + tempstring += """ +#include +#include +#include +#include +#include +#include "volk_rank_archs.h" +#include +#include +#include + +""" + tempstring += emit_prolog(); + +#OK here's the deal. the .h prototypes the functions. the .c impls them as fptrs, can use p_whatever. +#also .c impls the get_machine call +#also .c impls the default call for each fn + +#here do static fn get arch + tempstring += r""" +struct volk_machine *get_machine(void) { + extern struct volk_machine volk_machines[]; + extern unsigned int n_volk_machines; + static struct volk_machine *machine = NULL; + + if(machine != NULL) return machine; + else { + unsigned int max_score = 0; + int i; + for(i=0; i max_score) { + max_score = volk_machines[i].caps; + machine = &(volk_machines[i]); + } + } + } + printf("Using Volk machine: %s\n", machine->name); + return machine; + } +} + +static unsigned int get_index(const char *indices[], unsigned int n_archs, const char *arch_name) { + int i; + for(i=0; i +#include + +struct VOLK_CPU volk_cpu; + +#if defined(__i386__) || (__x86_64__) +#include +#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3) + +static inline unsigned int cpuid_eax(unsigned int op) { + unsigned int regs[4]; + cpuid_x86 (op, regs); + return regs[0]; +} + +static inline unsigned int cpuid_ebx(unsigned int op) { + unsigned int regs[4]; + cpuid_x86 (op, regs); + return regs[1]; +} + +static inline unsigned int cpuid_ecx(unsigned int op) { + unsigned int regs[4]; + cpuid_x86 (op, regs); + return regs[2]; +} + +static inline unsigned int cpuid_edx(unsigned int op) { + unsigned int regs[4]; + cpuid_x86 (op, regs); + return regs[3]; +} +#endif + +""" + +def make_cpuid_c(dom) : + tempstring = HEADER_TEMPL; + + for domarch in dom: + if str(domarch.attributes["type"].value) == "x86": + if "no_test" in domarch.attributes.keys(): + no_test = str(domarch.attributes["no_test"].value); + if no_test == "true": + no_test = True; + else: + no_test = False; + else: + no_test = False; + arch = str(domarch.attributes["name"].value); + op = domarch.getElementsByTagName("op"); + if op: + op = str(op[0].firstChild.data); + reg = domarch.getElementsByTagName("reg"); + if reg: + reg = str(reg[0].firstChild.data); + shift = domarch.getElementsByTagName("shift"); + if shift: + shift = str(shift[0].firstChild.data); + val = domarch.getElementsByTagName("val"); + if val: + val = str(val[0].firstChild.data); + + if no_test: + tempstring = tempstring + """\ +int i_can_has_%s () { +#if defined(__i386__) || (__x86_64__) + return 1; +#else + return 0; +#endif +} + +""" % (arch) + + elif op == "1": + tempstring = tempstring + """\ +int i_can_has_%s () { +#if defined(__i386__) || (__x86_64__) + unsigned int e%sx = cpuid_e%sx (%s); + return ((e%sx >> %s) & 1) == %s; +#else + return 0; +#endif +} + +""" % (arch, reg, reg, op, reg, shift, val) + + elif op == "0x80000001": + tempstring = tempstring + """\ +int i_can_has_%s () { +#if defined(__i386__) || (__x86_64__) + unsigned int extended_fct_count = cpuid_eax(0x80000000); + if (extended_fct_count < 0x80000001) + return %s^1; + unsigned int extended_features = cpuid_e%sx (%s); + return ((extended_features >> %s) & 1) == %s; +#else + return 0; +#endif +} + +""" % (arch, val, reg, op, shift, val) + + elif str(domarch.attributes["type"].value) == "powerpc": + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + """\ +int i_can_has_%s () { +#ifdef __PPC__ + return 1; +#else + return 0; +#endif +} + +""" % (arch) + + elif str(domarch.attributes["type"].value) == "all": + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + """\ +int i_can_has_%s () { + return 1; +} + +""" % (arch) + else: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + """\ +int i_can_has_%s () { + return 0; +} + +""" % (arch) + + tempstring = tempstring + "void volk_cpu_init() {\n"; + for domarch in dom: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + " volk_cpu.has_" + arch + " = &i_can_has_" + arch + ";\n" + tempstring = tempstring + "}\n\n" + + tempstring = tempstring + "unsigned int volk_get_lvarch() {\n"; + tempstring = tempstring + " unsigned int retval = 0;\n" + tempstring = tempstring + " volk_cpu_init();\n" + for domarch in dom: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + " retval += volk_cpu.has_" + arch + "() << LV_" + arch.swapcase() + ";\n" + tempstring = tempstring + " return retval;\n" + tempstring = tempstring + "}\n\n" + + return tempstring; + + + + + + + diff --git a/volk/gen/make_cpuid_h.py b/volk/gen/make_cpuid_h.py new file mode 100644 index 000000000..cd3da2455 --- /dev/null +++ b/volk/gen/make_cpuid_h.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from xml.dom import minidom +from emit_omnilog import * + +def make_cpuid_h(dom) : + tempstring = ""; + tempstring = tempstring +'/*this file is auto generated by volk_register.py*/'; + tempstring = tempstring +'\n#ifndef INCLUDED_VOLK_CPU_H'; + tempstring = tempstring +'\n#define INCLUDED_VOLK_CPU_H\n\n'; + tempstring = tempstring + emit_prolog(); + tempstring = tempstring + '\n' + + tempstring = tempstring + "struct VOLK_CPU {\n" + for domarch in dom: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + " int (*has_" + arch + ") ();\n"; + tempstring = tempstring + "};\n\n"; + tempstring = tempstring + "extern struct VOLK_CPU volk_cpu;\n\n"; + + tempstring = tempstring + "void volk_cpu_init ();\n" + tempstring = tempstring + "unsigned int volk_get_lvarch ();\n" + + tempstring = tempstring + "\n"; + tempstring = tempstring + emit_epilog(); + tempstring = tempstring + "#endif /*INCLUDED_VOLK_CPU_H*/\n" + + return tempstring; diff --git a/volk/gen/make_each_machine_c.py b/volk/gen/make_each_machine_c.py new file mode 100644 index 000000000..94d6d7789 --- /dev/null +++ b/volk/gen/make_each_machine_c.py @@ -0,0 +1,82 @@ +# +# Copyright 2010 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 . +# + +from volk_regexp import * +import string +from emit_omnilog import * + +#ok todo list: +#put n_archs into the info struct so it doesn't have to be arch_defs[0]. + +def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist): + tempstring = r""" +// This file is automatically generated by make_each_machine_c.py. +// Do not edit this file. +""" + for arch in archs: + tempstring += "#define LV_HAVE_" + arch.swapcase() + " 1\n" + + tempstring += """ +#include +#include +#include + +""" + tempstring += emit_prolog(); + for func in functions: + tempstring += "#include \n" + tempstring += "\n\n" + + for i in range(len(functions)): + tempstring += "static const " + replace_volk.sub("p", functions[i]) + " " + functions[i] + "_archs[] = {\n" + + tags_counter = 0 + for arch_list in fcountlist[i]: + tempstring += "#if " + for arch in arch_list: + tempstring += "defined(LV_HAVE_" + arch + ") && " + tempstring = strip_trailing(tempstring, " && ") + tempstring += "\n " + functions[i] + "_" + str(taglist[i][tags_counter]) + ",\n" + tempstring += "#endif\n" + tags_counter += 1 + + tempstring = strip_trailing(tempstring, ",") + tempstring += "};\n\n" + + + tempstring += "static unsigned int caps = " + for arch in archs: + tempstring += "(1 << LV_" + arch.swapcase() + ") + " + tempstring = strip_trailing(tempstring, " + ") + tempstring += ";\n" + + tempstring += "static const char* name = \"" + machine_name + "\";\n" + tempstring += "struct volk_machine volk_machine_" + machine_name + " = {\n" + tempstring += " caps,\n" + tempstring += " name,\n" + + for i in range(len(functions)): + tempstring += " { " + functions[i] + "_indices, " + functions[i] + "_arch_defs, " + functions[i] + "_n_archs },\n" + tempstring += " " + functions[i] + "_archs,\n" + + tempstring = strip_trailing(tempstring, ",") + tempstring += "};\n" + tempstring += emit_epilog(); + + return tempstring + + diff --git a/volk/gen/make_environment_init_c.py b/volk/gen/make_environment_init_c.py new file mode 100644 index 000000000..263d5bcd1 --- /dev/null +++ b/volk/gen/make_environment_init_c.py @@ -0,0 +1,32 @@ +from xml.dom import minidom + +def make_environment_init_c(dom) : + tempstring = ""; + tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n"; + tempstring = tempstring + "#include\n" + for domarch in dom: + arch = str(domarch.attributes["name"].value); + incs = domarch.getElementsByTagName("include"); + for inc in incs: + my_inc = str(inc.firstChild.data); + tempstring = tempstring + "#ifdef LV_HAVE_" + arch.swapcase() + "\n"; + tempstring = tempstring + "#include<" + my_inc + ">\n"; + tempstring = tempstring + "#endif\n" + tempstring = tempstring + '\n\n'; + tempstring = tempstring + "void volk_environment_init(){\n" + + for domarch in dom: + arch = str(domarch.attributes["name"].value); + envs = domarch.getElementsByTagName("environment"); + for env in envs: + cmd = str(env.firstChild.data); + tempstring = tempstring + "#ifdef LV_HAVE_" + arch.swapcase() + "\n"; + tempstring = tempstring + " " + cmd + "\n"; + tempstring = tempstring + "#endif\n" + + tempstring = tempstring + "}\n"; + return tempstring; + + + + diff --git a/volk/gen/make_environment_init_h.py b/volk/gen/make_environment_init_h.py new file mode 100644 index 000000000..77a841a24 --- /dev/null +++ b/volk/gen/make_environment_init_h.py @@ -0,0 +1,18 @@ +from xml.dom import minidom +from emit_omnilog import * + +def make_environment_init_h() : + tempstring = ""; + tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n"; + tempstring = tempstring + "#ifndef INCLUDE_LIBVECTOR_ENVIRONMENT_INIT_H\n"; + tempstring = tempstring + "#define INCLUDE_LIBVECTOR_ENVIRONMENT_INIT_H\n"; + tempstring = tempstring + "\n"; + tempstring = tempstring + emit_prolog(); + tempstring = tempstring + "void volk_environment_init();\n"; + tempstring = tempstring + emit_epilog(); + tempstring = tempstring + "#endif\n" + return tempstring; + + + + diff --git a/volk/gen/make_h.py b/volk/gen/make_h.py new file mode 100644 index 000000000..07e62939b --- /dev/null +++ b/volk/gen/make_h.py @@ -0,0 +1,39 @@ +from xml.dom import minidom +from emit_omnilog import * +from volk_regexp import * + +# http://gcc.gnu.org/wiki/Visibility +volk_api_defines = """ +#ifdef volk_EXPORTS +# define VOLK_API __VOLK_ATTR_EXPORT +#else +# define VOLK_API __VOLK_ATTR_IMPORT +#endif +""" + +def make_h(funclist, arched_arglist) : + tempstring = ""; + tempstring = tempstring + '/*this file is auto generated by make_h.py*/\n'; + + tempstring = tempstring + '\n#ifndef INCLUDED_VOLK_RUNTIME'; + tempstring = tempstring + '\n#define INCLUDED_VOLK_RUNTIME'; + tempstring = tempstring + '\n\n#include\n'; + tempstring = tempstring + '#include\n'; + tempstring = tempstring + '#include\n'; + tempstring = tempstring + '#include\n'; + tempstring = tempstring + volk_api_defines + tempstring = tempstring + emit_prolog(); + + tempstring = tempstring + '\n'; + + for i in range(len(funclist)): + tempstring += "extern " + replace_volk.sub("p", funclist[i]) + " " + funclist[i] + ";\n" + tempstring += "extern VOLK_API void %s_manual%s;\n" % (funclist[i], arched_arglist[i]) + tempstring = strip_trailing(tempstring, " {") + tempstring += "extern VOLK_API struct volk_func_desc %s_get_func_desc(void);\n" % (funclist[i]) + + tempstring = tempstring + emit_epilog(); + tempstring = tempstring + "#endif /*INCLUDED_VOLK_RUNTIME*/\n"; + + return tempstring; + diff --git a/volk/gen/make_machines_c.py b/volk/gen/make_machines_c.py new file mode 100644 index 000000000..9ad56fb62 --- /dev/null +++ b/volk/gen/make_machines_c.py @@ -0,0 +1,57 @@ +# +# Copyright 2010 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 . +# + +from volk_regexp import * + +def make_machines_c(machines): + tempstring = r""" +// This file is automatically generated by make_machines_c.py. +// Do not edit this file. + +#include +#include +#include + +struct volk_machine volk_machines[] = { +""" + for machine in machines: + tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n" + tempstring += "volk_machine_" + machine + tempstring += "," + tempstring += "\n#endif\n" + + tempstring += r""" +}; + +""" + + for machine in machines: + tempstring += "#if LV_MACHINE_" + machine.swapcase() + "\n" + tempstring += "#define LV_MACHINE_" + machine.swapcase() + "_CNT 1\n" + tempstring += "#else\n" + tempstring += "#define LV_MACHINE_" + machine.swapcase() + "_CNT 0\n" + tempstring += "#endif\n" + + tempstring += """unsigned int n_volk_machines = +""" + for machine in machines: + tempstring += "(LV_MACHINE_" + machine.swapcase() + "_CNT) " + tempstring += "+ " + tempstring = tempstring[:-2] + tempstring += ";\n" + + return tempstring diff --git a/volk/gen/make_machines_h.py b/volk/gen/make_machines_h.py new file mode 100644 index 000000000..674ee12cd --- /dev/null +++ b/volk/gen/make_machines_h.py @@ -0,0 +1,50 @@ +# +# Copyright 2010 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 . +# + +from volk_regexp import * + +def make_machines_h(functions, machines): + tempstring = r""" +// This file is automatically generated by make_machines_h.py. +// Do not edit this file. + +#ifndef INCLUDED_LIBVOLK_MACHINES_H +#define INCLUDED_LIBVOLK_MACHINES_H + +#include +#include + +struct volk_machine { + const unsigned int caps; //capabilities (i.e., archs compiled into this machine, in the volk_get_lvarch format) + const char *name; +""" + for function in functions: + tempstring += "\n const struct volk_func_desc " + function + "_desc;\n" + tempstring += " const " + replace_volk.sub("p", function) + " *" + function + "_archs;\n" + + tempstring += r"""}; + +""" + for machine in machines: + tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n" + tempstring += "extern const struct volk_machine volk_machine_" + machine + ";\n" + tempstring += """#endif\n""" + + tempstring += r""" +#endif //INCLUDED_LIBVOLK_MACHINES_H""" + + return tempstring diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py new file mode 100644 index 000000000..0d746ca28 --- /dev/null +++ b/volk/gen/make_makefile_am.py @@ -0,0 +1,119 @@ +# +# Copyright 2010 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 . +# + +from xml.dom import minidom + +def make_makefile_am(dom, machines, archflags_dict): + tempstring = r""" +# This file is automatically generated by make_makefile_am.py. +# Do not edit this file. + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) \ + -I$(top_gendir)/include \ + -Dvolk_EXPORTS \ + -fvisibility=hidden \ + $(WITH_INCLUDES) + +lib_LTLIBRARIES = \ + libvolk.la + +EXTRA_DIST = \ + volk_rank_archs.h \ + gcc_x86_cpuid.h + +# ---------------------------------------------------------------- +# The main library +# ---------------------------------------------------------------- + +libvolk_la_SOURCES = \ + $(platform_CODE) \ + $(top_gendir)/lib/volk.cc \ + $(top_gendir)/lib/volk_cpu.c \ + volk_rank_archs.c \ + $(top_gendir)/lib/volk_machines.cc + +if LV_HAVE_ORC +volk_orc_CFLAGS = -DLV_HAVE_ORC=1 +volk_orc_LDFLAGS = $(ORC_LDFLAGS) -lorc-0.4 +volk_orc_LIBADD = ../orc/libvolk_orc.la +else +volk_orc_CFLAGS = +volk_orc_LDFLAGS = +volk_orc_LIBADD = +endif + +libvolk_la_CPPFLAGS = $(AM_CPPFLAGS) $(volk_orc_CFLAGS) +libvolk_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 $(volk_orc_LDFLAGS) +libvolk_la_LIBADD = $(volk_orc_LIBADD) + +noinst_LTLIBRARIES = + +""" + + #here be dragons + for machine_name in machines: + tempstring += "if LV_MACHINE_" + machine_name.swapcase() + "\n" + tempstring += "libvolk_" + machine_name + "_la_SOURCES = $(top_gendir)/lib/volk_machine_" + machine_name + ".cc\n" + tempstring += "libvolk_" + machine_name + "_la_CPPFLAGS = -I$(top_srcdir)/include -I$(top_gendir)/include $(volk_orc_CFLAGS) " + for arch in machines[machine_name]: + if archflags_dict[arch] != "none": + tempstring += "-" + archflags_dict[arch] + " " + + tempstring += "\nnoinst_LTLIBRARIES += libvolk_" + machine_name + ".la " + tempstring += "\nlibvolk_la_LIBADD += libvolk_" + machine_name + ".la\n" + tempstring += "libvolk_la_CPPFLAGS += -DLV_MACHINE_" + machine_name.swapcase() + " \n" + tempstring += "endif\n" + + + tempstring += r""" + +# ---------------------------------------------------------------- +# The QA library. Note libvolk.la in LIBADD +# ---------------------------------------------------------------- +#libvolk_qa_la_SOURCES = \ +# qa_utils.cc + +#libvolk_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 -lboost + +#libvolk_qa_la_LIBADD = \ +# libvolk.la \ +# libvolk_runtime.la + +# ---------------------------------------------------------------- +# headers that don't get installed +# ---------------------------------------------------------------- +noinst_HEADERS = \ + $(top_gendir)/lib/volk_init.h \ + qa_utils.h + +# ---------------------------------------------------------------- +# Our test program +# ---------------------------------------------------------------- +noinst_PROGRAMS = \ + testqa + +testqa_SOURCES = testqa.cc qa_utils.cc +testqa_CPPFLAGS = -DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN $(AM_CPPFLAGS) +testqa_LDFLAGS = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) +testqa_LDADD = \ + libvolk.la +""" + + + return tempstring diff --git a/volk/gen/make_proccpu_sim.py b/volk/gen/make_proccpu_sim.py new file mode 100644 index 000000000..029dacfcc --- /dev/null +++ b/volk/gen/make_proccpu_sim.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from xml.dom import minidom + +def make_proccpu_sim(dom) : + tempstring = ""; + tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n"; + tempstring = tempstring + "#include \n" + tempstring = tempstring + "#include \n" + tempstring = tempstring + "\n\n" + + tempstring = tempstring + "void test_append(char* buf, int val, char* newkey){\n"; + tempstring = tempstring + " if(val==1){\n"; + tempstring = tempstring + " sprintf(buf, \"%s %s\", buf, newkey);\n"; + tempstring = tempstring + " }\n"; + tempstring = tempstring + "}\n"; + tempstring = tempstring + "\n\n"; + + tempstring = tempstring + "int main() {\n"; + tempstring = tempstring + " volk_cpu_init();\n"; + tempstring = tempstring + " char buf[2048];\n"; + for domarch in dom: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + " test_append(buf, volk_cpu.has_" + arch + "(), \"" + arch + "\");\n" + tempstring = tempstring + " printf(\"%s\\n\", buf);\n" + tempstring = tempstring + "}\n" + return tempstring; diff --git a/volk/gen/make_registry.py b/volk/gen/make_registry.py new file mode 100644 index 000000000..de1f46aa6 --- /dev/null +++ b/volk/gen/make_registry.py @@ -0,0 +1,85 @@ +from xml.dom import minidom +from emit_omnilog import * +from volk_regexp import * +import string + +def make_registry(dom, funclist, fcountlist, taglist) : + tempstring = ""; + tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n"; + tempstring = tempstring +'\n#ifndef INCLUDED_VOLK_REGISTRY_H'; + tempstring = tempstring +'\n#define INCLUDED_VOLK_REGISTRY_H\n\n'; + tempstring = tempstring +'#include\n'; + tempstring = tempstring + emit_prolog(); + tempstring = tempstring + '\n' + + + + + for domarch in dom: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring +"#ifdef LV_HAVE_" + arch.swapcase() + "\n"; + tempstring = tempstring +"#define LV_" + arch.swapcase() + "_CNT 1\n"; + tempstring = tempstring +"#else\n"; + tempstring = tempstring +"#define LV_" + arch.swapcase() + "_CNT 0\n"; + tempstring = tempstring +"#endif /*LV_HAVE_" + arch.swapcase() + "*/\n\n"; + + counter = 0; + + for i in range(len(funclist)): + tempstring = tempstring + "static const char* " + funclist[i] + "_indices[] = {\n"; + + tags_counter = 0; + for arch_list in fcountlist[i]: + tempstring = tempstring + "#if defined(LV_HAVE_" + for ind in range(len(arch_list)): + + tempstring = tempstring + arch_list[ind] + ")"; + if ind < len(arch_list) - 1: + tempstring = tempstring + " && defined(LV_HAVE_"; + + tempstring = tempstring + "\n \"" + str(taglist[i][tags_counter]) + "\",\n#endif\n"; + tags_counter = tags_counter + 1; + + tempstring = strip_trailing(tempstring, ",") + tempstring = tempstring + "};\n\n"; + + + for fcount in fcountlist: + tempstring = tempstring + "static const int " + funclist[counter] + "_arch_defs[] = {\n"; + counter += 1; + for arch_list in fcount: + tempstring = tempstring + "#if defined(LV_HAVE_" + for ind in range(len(arch_list)): + tempstring = tempstring + arch_list[ind] + ")"; + if ind < len(arch_list) - 1: + tempstring = tempstring + " && defined(LV_HAVE_"; + tempstring = tempstring + "\n" + tempstring = tempstring + " (1 << LV_" + for ind in range(len(arch_list)): + tempstring = tempstring + arch_list[ind]; + if ind < len(arch_list) - 1: + tempstring = tempstring + ") + (1 << LV_" + tempstring = tempstring + "),\n#endif\n" + tempstring = strip_trailing(tempstring, ",") + tempstring = tempstring + "};\n\n" + + counter = 0; + for fcount in fcountlist: + tempstring += "static const int " + funclist[counter] + "_n_archs = " + counter += 1; + for arch_list in fcount: + tempstring = tempstring + " (LV_" + for ind in range(len(arch_list)): + tempstring = tempstring + arch_list[ind] + "_CNT"; + if ind < len(arch_list) - 1: + tempstring = tempstring + " * LV_"; + tempstring = tempstring + ") + "; + tempstring = strip_trailing(tempstring, " + "); + tempstring = tempstring + ";\n" + + + tempstring = tempstring + emit_epilog(); + tempstring = tempstring +"#endif /*INCLUDED_VOLK_REGISTRY_H*/\n"; + + return tempstring; + diff --git a/volk/gen/make_set_simd.py b/volk/gen/make_set_simd.py new file mode 100644 index 000000000..5a848e59e --- /dev/null +++ b/volk/gen/make_set_simd.py @@ -0,0 +1,166 @@ +# +# Copyright 2010 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 . +# + +from xml.dom import minidom + +def make_set_simd(dom, machines) : + tempstring = ""; + tempstring = tempstring +'dnl this file is auto generated by volk_register.py\n\n'; + + tempstring = tempstring +'\ndnl define arch checks\n'; + for domarch in dom: + if str(domarch.attributes["type"].value) != "all": + arch = str(domarch.attributes["name"].value); + flag = domarch.getElementsByTagName("flag"); + flag = str(flag[0].firstChild.data); + tempstring = tempstring + "AC_DEFUN([_TRY_ADD_" + arch.swapcase() + "],\n"; + tempstring = tempstring + "[\n"; + tempstring = tempstring + " LF_CHECK_CC_FLAG([-" + flag + "])\n"; + tempstring = tempstring + " LF_CHECK_CXX_FLAG([-" + flag + "])\n"; + tempstring = tempstring + "])\n"; + + tempstring = tempstring +'\ndnl main set_simd_flags\n'; + tempstring = tempstring + "AC_DEFUN([LV_SET_SIMD_FLAGS],\n"; + tempstring = tempstring + "[\n"; + #tempstring = tempstring + " AC_REQUIRE([GR_SET_MD_CPU])\n"; + tempstring = tempstring + " AC_SUBST(LV_CXXFLAGS)\n"; + tempstring = tempstring + " indCC=no\n"; + tempstring = tempstring + " indCXX=no\n"; + tempstring = tempstring + " indLV_ARCH=no\n"; + tempstring = tempstring + " AC_ARG_WITH(lv_arch,\n"; + tempstring = tempstring + " AC_HELP_STRING([--with-lv_arch=ARCH],[set volk hardware speedups as space separated string with elements from the following list("; + + for domarch in dom: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + arch + ", " + tempstring = tempstring[0:len(tempstring) - 2]; + + tempstring = tempstring + ")]),\n"; + tempstring = tempstring + " [cf_with_lv_arch=\"$withval\"],\n"; + tempstring = tempstring + " [cf_with_lv_arch=\"\"])\n"; + if str(domarch.attributes["type"].value) == "all": + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + " AC_DEFINE(LV_MAKE_" + arch.swapcase() + ", 1, [always set "+ arch + "!])\n"; + tempstring = tempstring + " ADDONS=\"\"\n"; + tempstring = tempstring + " BUILT_ARCHS=\"\"\n"; + #tempstring = tempstring + " _MAKE_FAKE_PROCCPU\n"; + tempstring = tempstring + " OVERRULE_FLAG=\"no\"\n"; + tempstring = tempstring + " if test -z \"$cf_with_lv_arch\"; then\n"; + tempstring = tempstring + " cf_with_lv_arch=\""; + for domarch in dom: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + arch + " "; + tempstring = tempstring[0:-1] + "\"\n"; + tempstring = tempstring + " OVERRULE_FLAG=\"yes\"\n"; + tempstring = tempstring + " fi\n"; + + tempstring = tempstring +'\ndnl init LV_MAKE_XXX and then try to add archs\n'; + for domarch in dom: + if str(domarch.attributes["type"].value) != "all": + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + " LV_MAKE_" + arch.swapcase() + "=no\n"; + + for domarch in dom: + arch = str(domarch.attributes["name"].value); + atype = str(domarch.attributes["type"].value); + if atype != "all": + tempstring = tempstring + " _TRY_ADD_" + arch.swapcase() + "\n"; + + for domarch in dom: + arch = str(domarch.attributes["name"].value); + atype = str(domarch.attributes["type"].value); + tempstring = tempstring +'\ndnl add in flags for arch ' + arch + '\n'; + overrule = domarch.getElementsByTagName("overrule"); + if overrule: + overrule = str(overrule[0].firstChild.data); + else: + overrule = ""; + overrule_val = domarch.getElementsByTagName("overrule_val"); + if overrule_val: + overrule_val = str(overrule_val[0].firstChild.data); + else: + overrule_val = ""; + flag = domarch.getElementsByTagName("flag"); + flag = str(flag[0].firstChild.data); + if atype != "all": + tempstring = tempstring + " for i in $lf_CXXFLAGS\n" + tempstring = tempstring + " do\n" + tempstring = tempstring + " if test \"X$i\" = X-" + flag +"; then\n"; + tempstring = tempstring + " indCXX=yes\n"; + tempstring = tempstring + " fi\n" + tempstring = tempstring + " done\n" + tempstring = tempstring + " for i in $lf_CFLAGS\n" + tempstring = tempstring + " do\n" + tempstring = tempstring + " if test \"X$i\" = X-" + flag +"; then\n"; + tempstring = tempstring + " indCC=yes\n"; + tempstring = tempstring + " fi\n" + tempstring = tempstring + " done\n" + tempstring = tempstring + " for i in $cf_with_lv_arch\n" + tempstring = tempstring + " do\n" + tempstring = tempstring + " if test \"X$i\" = X" + arch + "; then\n"; + tempstring = tempstring + " indLV_ARCH=yes\n" + tempstring = tempstring + " fi\n" + tempstring = tempstring + " done\n" + tempstring = tempstring + " if test -n \"" + overrule + "\" && test \"$" + overrule + "\" == \"" + overrule_val + "\" && test \"$OVERRULE_FLAG\" == \"yes\" && test \"$indLV_ARCH\" == \"yes\"; then\n" + tempstring = tempstring + " indLV_ARCH=no\n" + tempstring = tempstring + " fi\n" + + tempstring = tempstring + " if test \"$indCC\" == \"yes\" && test \"$indCXX\" == \"yes\" && test \"$indLV_ARCH\" == \"yes\"; then\n" + + #tempstring = tempstring + " ADDONS=\"${ADDONS} -" + flag + "\"\n"; + tempstring = tempstring + " BUILT_ARCHS=\"${BUILT_ARCHS} " + arch + "\"\n"; + tempstring = tempstring + " LV_MAKE_" + arch.swapcase() + "=yes\n"; + tempstring = tempstring + " fi\n" + tempstring = tempstring + " indCC=no\n" + tempstring = tempstring + " indCXX=no\n" + tempstring = tempstring + " indLV_ARCH=no\n" + else: + tempstring = tempstring + " for i in $cf_with_lv_arch\n" + tempstring = tempstring + " do\n" + tempstring = tempstring + " if test \"X$i\" = X" + arch + "; then\n"; + tempstring = tempstring + " indLV_ARCH=yes\n" + tempstring = tempstring + " fi\n" + tempstring = tempstring + " done\n" + tempstring = tempstring + " if test -n \"" + overrule + "\" && test \"$" + overrule + "\" == \"" + overrule_val + "\" && test \"$OVERRULE_FLAG\" == \"yes\" && test \"$indLV_ARCH\" == \"yes\"; then\n" + tempstring = tempstring + " indLV_ARCH=no\n" + tempstring = tempstring + " fi\n" + tempstring = tempstring + " if test \"$indLV_ARCH\" == \"yes\"; then\n" + tempstring = tempstring + " LV_MAKE_" + arch.swapcase() + "=yes\n"; + tempstring = tempstring + " BUILT_ARCHS=\"${BUILT_ARCHS} " + arch + "\"\n"; + tempstring = tempstring + " fi\n" + tempstring = tempstring + " indLV_ARCH=no\n" + + + for domarch in dom: + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + " AM_CONDITIONAL(LV_MAKE_" + arch.swapcase() + ", test \"$LV_MAKE_" + arch.swapcase() + "\" == \"yes\")\n"; + + tempstring += "\n" + #now we can define the machines we're compiling + for machine_name in machines: + tempstring += " AM_CONDITIONAL(LV_MACHINE_" + machine_name.swapcase() + ", " + marchlist = machines[machine_name] + for march in marchlist: + tempstring += "test \"$LV_MAKE_" + march.swapcase() + "\" == \"yes\" && " + + tempstring += "test true)\n" #just so we don't have to detect the last one in the group, i know + tempstring = tempstring + " LV_CXXFLAGS=\"${LV_CXXFLAGS} ${ADDONS}\"\n" + tempstring = tempstring + "])\n" + + return tempstring; + + diff --git a/volk/gen/make_typedefs.py b/volk/gen/make_typedefs.py new file mode 100644 index 000000000..8f9f2b55e --- /dev/null +++ b/volk/gen/make_typedefs.py @@ -0,0 +1,23 @@ +from xml.dom import minidom +import string +from volk_regexp import * + + + +def make_typedefs(funclist, retlist, my_argtypelist) : + tempstring = ""; + tempstring = tempstring + '/*this file is auto generated by volk_register.py*/'; + tempstring = tempstring + '/*this file is auto generated by volk_register.py*/'; + tempstring = tempstring + '\n#ifndef INCLUDED_VOLK_TYPEDEFS'; + tempstring = tempstring + '\n#define INCLUDED_VOLK_TYPEDEFS\n'; + tempstring = tempstring + '\n\n#include\n'; + tempstring = tempstring + '#include\n'; + + tempstring = tempstring + '\n'; + + for i in range(len(funclist)): + tempstring = tempstring + "typedef " + retlist[i] +" (*" + replace_volk.sub("p", funclist[i]) + ")(" + my_argtypelist[i] + ");\n"; + + tempstring = tempstring + "#endif /*INCLUDED_VOLK_TYPEDEFS*/\n"; + + return tempstring; diff --git a/volk/gen/volk_regexp.py b/volk/gen/volk_regexp.py new file mode 100644 index 000000000..b83ce5206 --- /dev/null +++ b/volk/gen/volk_regexp.py @@ -0,0 +1,14 @@ +import re +import string + +remove_after_underscore = re.compile("_.*"); +space_remove = re.compile(" "); +leading_space_remove = re.compile("^ *"); +replace_arch = re.compile(", const char\* arch"); +replace_bracket = re.compile(" {"); +replace_volk = re.compile("volk"); + +def strip_trailing(tostrip, stripstr): + lindex = tostrip.rfind(stripstr) + tostrip = tostrip[0:lindex] + string.replace(tostrip[lindex:len(tostrip)], stripstr, ""); + return tostrip diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py new file mode 100755 index 000000000..19fc61c15 --- /dev/null +++ b/volk/gen/volk_register.py @@ -0,0 +1,305 @@ +#! /usr/bin/env python + +import sys +import os +import re +import string +from xml.dom import minidom +from volk_regexp import * +from make_cpuid_c import make_cpuid_c +from make_cpuid_h import make_cpuid_h +from make_set_simd import make_set_simd +from make_registry import make_registry +from make_config_fixed import make_config_fixed +from make_typedefs import make_typedefs +from make_environment_init_c import make_environment_init_c +from make_environment_init_h import make_environment_init_h +from make_makefile_am import make_makefile_am +from make_machines_h import make_machines_h +from make_machines_c import make_machines_c +from make_each_machine_c import make_each_machine_c +from make_c import make_c +from make_h import make_h +import copy + +#set srcdir and gendir +srcdir = os.path.dirname(os.path.dirname(__file__)) +try: gendir = sys.argv[1] +except: gendir = os.path.dirname(__file__) + +#ensure directories exist +for dir in ( + (os.path.join(gendir, 'include', 'volk')), + (os.path.join(gendir, 'lib')), + (os.path.join(gendir, 'config')) +): + if not os.path.exists(dir): os.makedirs(dir) + +outfile_set_simd = open(os.path.join(gendir, "config/lv_set_simd_flags.m4"), "w") +outfile_reg = open(os.path.join(gendir, "include/volk/volk_registry.h"), "w") +outfile_h = open(os.path.join(gendir, "include/volk/volk.h"), "w") +outfile_c = open(os.path.join(gendir, "lib/volk.cc"), "w") +outfile_typedefs = open(os.path.join(gendir, "include/volk/volk_typedefs.h"), "w") +outfile_init_h = open(os.path.join(gendir, "lib/volk_init.h"), "w") +outfile_cpu_h = open(os.path.join(gendir, "include/volk/volk_cpu.h"), "w") +outfile_cpu_c = open(os.path.join(gendir, "lib/volk_cpu.c"), "w") +#outfile_config_in = open(os.path.join(gendir, "include/volk/volk_config.h.in"), "w") +outfile_config_fixed = open(os.path.join(gendir, "include/volk/volk_config_fixed.h"), "w") +#outfile_mktables = open(os.path.join(gendir, "lib/volk_mktables.c"), "w") +outfile_environment_c = open(os.path.join(gendir, "lib/volk_environment_init.c"), "w") +outfile_environment_h = open(os.path.join(gendir, "include/volk/volk_environment_init.h"), "w") +outfile_makefile_am = open(os.path.join(gendir, "lib/Makefile.am"), "w") +outfile_machines_h = open(os.path.join(gendir, "include/volk/volk_machines.h"), "w") +outfile_machines_c = open(os.path.join(gendir, "lib/volk_machines.cc"), "w") +infile = open(os.path.join(srcdir, "include/volk/Makefile.am"), "r") + + +mfile = infile.readlines(); + +datatypes = []; +functions = []; + + + +for line in mfile: + subline = re.search(".*_(a16|u)\.h.*", line); + if subline: + subsubline = re.search("(?<=volk_).*", subline.group(0)); + if subsubline: + dtype = remove_after_underscore.sub("", subsubline.group(0)); + subdtype = re.search("[0-9]+[A-z]+", dtype); + if subdtype: + datatypes.append(subdtype.group(0)); + + +datatypes = set(datatypes); + +for line in mfile: + for dt in datatypes: + if dt in line: + subline = re.search("(volk_" + dt +"_.*(a16|u).*\.h)", line); + if subline: + + subsubline = re.search(".+(?=\.h)", subline.group(0)); + functions.append(subsubline.group(0)); + +archs = []; +afile = minidom.parse(os.path.join(srcdir, "gen/archs.xml")) +filearchs = afile.getElementsByTagName("arch"); +for filearch in filearchs: + archs.append(str(filearch.attributes["name"].value)); + +for arch in archs: + a_var = re.search("^\$", arch); + if a_var: + archs.remove(arch); + + + +archflags_dict = {} +for filearch in filearchs: + archflags_dict[str(filearch.attributes["name"].value)] = str(filearch.getElementsByTagName("flag")[0].firstChild.data) + +archs_or = "(" +for arch in archs: + archs_or = archs_or + string.upper(arch) + "|"; +archs_or = archs_or[0:len(archs_or)-1]; +archs_or = archs_or + ")"; + +#get machine list and parse to a list of machines, each with a list of archs (none of this DOM crap) +machine_str_dict = {} +mfile = minidom.parse(os.path.join(srcdir, "gen/machines.xml")) +filemachines = mfile.getElementsByTagName("machine") + +for filemachine in filemachines: + machine_str_dict[str(filemachine.attributes["name"].value)] = str(filemachine.getElementsByTagName("archs")[0].firstChild.data).split() + +#all right now you have a dict of arch lists +#next we expand it +#this is an expanded list accounting for the OR syntax +#TODO: make this work for multiple "|" machines +machines = {} +already_done = False +for machine_name in machine_str_dict: + already_done = False + marchlist = machine_str_dict[machine_name] + for march in marchlist: + or_marchs = march.split("|") + if len(or_marchs) > 1: + marchlist.remove(march) + for or_march in or_marchs: + tempmarchlist = copy.deepcopy(marchlist) + tempmarchlist.append(or_march) + machines[machine_name + "_" + or_march] = tempmarchlist + already_done = True + + if not already_done: + machines[machine_name] = marchlist + +#for machine_name in machines: +# print machine_name + ": " + str(machines[machine_name]) + +#ok, now we have all the machines we're going to build. next step is to generate a Makefile.am where they're all laid out and compiled + +taglist = []; +fcountlist = []; +arched_arglist = []; +retlist = []; +my_arglist = []; +my_argtypelist = []; +for func in functions: + tags = []; + fcount = []; + infile_source = open(os.path.join(srcdir, 'include', 'volk', func + ".h")) + begun_name = 0; + begun_paren = 0; + sourcefile = infile_source.readlines(); + infile_source.close(); + for line in sourcefile: +#FIXME: make it work for multiple #if define()s + archline = re.search("^\#if.*?LV_HAVE_" + archs_or + ".*", line); + if archline: + arch = archline.group(0); + archline = re.findall(archs_or + "(?=( |\n|&))", line); + if archline: + archsublist = []; + for tup in archline: + archsublist.append(tup[0]); + fcount.append(archsublist); + testline = re.search("static inline.*?" + func, line); + if (not testline): + continue + tagline = re.search(func + "_.+", line); + if tagline: + tag = re.search("(?<=" + func + "_)\w+(?= *\()",line); + if tag: + tag = re.search("\w+", tag.group(0)); + if tag: + tags.append(tag.group(0)); + + + if begun_name == 0: + retline = re.search(".+(?=" + func + ")", line); + if retline: + ret = retline.group(0); + + + + + subline = re.search(func + ".*", line); + if subline: + subsubline = re.search("\(.*?\)", subline.group(0)); + if subsubline: + args = subsubline.group(0); + + else: + begun_name = 1; + subsubline = re.search("\(.*", subline.group(0)); + if subsubline: + args = subsubline.group(0); + begun_paren = 1; + else: + if begun_paren == 1: + subline = re.search(".*?\)", line); + if subline: + args = args + subline.group(0); + begun_name = 0; + begun_paren = 0; + else: + subline = re.search(".*", line); + args = args + subline.group(0); + else: + subline = re.search("\(.*?\)", line); + if subline: + args = subline.group(0); + begun_name = 0; + else: + subline = re.search("\(.*", line); + if subline: + args = subline.group(0); + begun_paren = 1; + + replace = re.compile("static "); + ret = replace.sub("", ret); + replace = re.compile("inline "); + ret = replace.sub("", ret); + replace = re.compile("\)"); + arched_args = replace.sub(", const char* arch) {", args); + + remove = re.compile('\)|\(|{'); + rargs = remove.sub("", args); + sargs = rargs.split(','); + + + + margs = []; + atypes = []; + for arg in sargs: + temp = arg.split(" "); + margs.append(temp[-1]); + replace = re.compile(" " + temp[-1]); + atypes.append(replace.sub("", arg)); + + + my_args = "" + arg_types = "" + for arg in range(0, len(margs) - 1): + this_arg = leading_space_remove.sub("", margs[arg]); + my_args = my_args + this_arg + ", "; + this_type = leading_space_remove.sub("", atypes[arg]); + arg_types = arg_types + this_type + ", "; + + this_arg = leading_space_remove.sub("", margs[-1]); + my_args = my_args + this_arg; + this_type = leading_space_remove.sub("", atypes[-1]); + arg_types = arg_types + this_type; + my_argtypelist.append(arg_types); + + if(ret[-1] != ' '): + ret = ret + ' '; + + arched_arglist.append(arched_args); #!!!!!!!!!!! + my_arglist.append(my_args) #!!!!!!!!!!!!!!!!! + retlist.append(ret); + fcountlist.append(fcount); + taglist.append(tags); + + +outfile_cpu_h.write(make_cpuid_h(filearchs)); +outfile_cpu_h.close(); + +outfile_cpu_c.write(make_cpuid_c(filearchs)); +outfile_cpu_c.close(); + +outfile_set_simd.write(make_set_simd(filearchs, machines)); +outfile_set_simd.close(); + +outfile_reg.write(make_registry(filearchs, functions, fcountlist, taglist)); +outfile_reg.close(); + +outfile_config_fixed.write(make_config_fixed(filearchs)); +outfile_config_fixed.close(); + +outfile_typedefs.write(make_typedefs(functions, retlist, my_argtypelist)); +outfile_typedefs.close(); + +outfile_makefile_am.write(make_makefile_am(filearchs, machines, archflags_dict)) +outfile_makefile_am.close() + +outfile_machines_h.write(make_machines_h(functions, machines)) +outfile_machines_h.close() + +outfile_machines_c.write(make_machines_c(machines)) +outfile_machines_c.close() + +outfile_c.write(make_c(machines, archs, functions, arched_arglist, my_arglist)) +outfile_c.close() + +outfile_h.write(make_h(functions, arched_arglist)) +outfile_h.close() + +for machine in machines: + machine_c_filename = os.path.join(gendir, "lib/volk_machine_" + machine + ".cc") + outfile_machine_c = open(machine_c_filename, "w") + outfile_machine_c.write(make_each_machine_c(machine, machines[machine], functions, fcountlist, taglist)) + outfile_machine_c.close() diff --git a/volk/include/volk/.gitignore b/volk/include/volk/.gitignore index 1afe439ba..b336cc7ce 100644 --- a/volk/include/volk/.gitignore +++ b/volk/include/volk/.gitignore @@ -1,17 +1,2 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo /Makefile /Makefile.in -/volk.h -/volk_config_fixed.h -/volk_cpu.h -/volk_environment_init.h -/volk_registry.h -/volk_typedefs.h -/volk_machines.h diff --git a/volk/include/volk/Makefile.am b/volk/include/volk/Makefile.am index b36d96c5d..ea60d201a 100644 --- a/volk/include/volk/Makefile.am +++ b/volk/include/volk/Makefile.am @@ -29,13 +29,13 @@ volkinclude_HEADERS = \ volk_attributes.h \ volk_complex.h \ volk_common.h \ - volk_config_fixed.h \ - volk_typedefs.h \ - volk_registry.h \ - volk.h \ - volk_cpu.h \ - volk_machines.h \ - volk_environment_init.h \ + $(top_gendir)/include/volk/volk_config_fixed.h \ + $(top_gendir)/include/volk/volk_typedefs.h \ + $(top_gendir)/include/volk/volk_registry.h \ + $(top_gendir)/include/volk/volk.h \ + $(top_gendir)/include/volk/volk_cpu.h \ + $(top_gendir)/include/volk/volk_machines.h \ + $(top_gendir)/include/volk/volk_environment_init.h \ volk_16i_x5_add_quad_16i_x4_a16.h \ volk_16i_branch_4_state_8_a16.h \ volk_16ic_deinterleave_16i_x2_a16.h \ @@ -124,17 +124,3 @@ volkinclude_HEADERS = \ volk_8i_convert_16i_u.h \ volk_8i_s32f_convert_32f_a16.h \ volk_8i_s32f_convert_32f_u.h - -distclean-local: - rm -f volk_config_fixed.h - rm -f volk_cpu.h - rm -f volk.h - rm -f volk_registry.h - rm -f volk_runtime.h - rm -f volk_typedefs.h - rm -f volk_tables.h - rm -f *.pyc - rm -f Makefile.in - rm -f volk_environment_init.h - rm -f volk_mktables - rm -f $(BUILT_SOURCES) diff --git a/volk/include/volk/archs.xml b/volk/include/volk/archs.xml deleted file mode 100644 index 977cc7924..000000000 --- a/volk/include/volk/archs.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - none - - - - maltivec - - - - m32 - MD_SUBCPU - x86_64 - - - - 0x80000001 - d - 29 - m64 - 1 - MD_SUBCPU - x86 - - - - 0x80000001 - d - 31 - m3dnow - 1 - - - - 1 - 0x80000001 - d - 5 - sse4.2 - - - - 1 - 1 - c - 23 - mpopcnt - - - - 1 - 1 - d - 23 - mmmx - - - - - 1 - 1 - d - 25 - msse - _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); - xmmintrin.h - - - - - 1 - 1 - d - 26 - msse2 - - - - lorc-0.4 - LV_HAVE_ORC - no - - - - 1 - 1 - c - 0 - msse3 - _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); - pmmintrin.h - - - - 1 - 1 - c - 9 - mssse3 - - - - 1 - 0x80000001 - c - 6 - msse4a - - - - - 1 - 1 - c - 19 - msse4.1 - - - - 1 - 1 - c - 20 - msse4.2 - - - - 1 - 1 - c - 28 - mavx - - - diff --git a/volk/include/volk/emit_omnilog.py b/volk/include/volk/emit_omnilog.py deleted file mode 100644 index 309d7e578..000000000 --- a/volk/include/volk/emit_omnilog.py +++ /dev/null @@ -1,13 +0,0 @@ -def emit_prolog(): - tempstring = ""; - tempstring = tempstring + '#ifdef __cplusplus\n'; - tempstring = tempstring + 'extern "C" {\n'; - tempstring = tempstring + '#endif\n'; - return tempstring; -def emit_epilog(): - tempstring = ""; - tempstring = tempstring + '#ifdef __cplusplus\n'; - tempstring = tempstring + '}\n'; - tempstring = tempstring + '#endif\n'; - return tempstring; - diff --git a/volk/include/volk/machines.xml b/volk/include/volk/machines.xml deleted file mode 100644 index ad71da177..000000000 --- a/volk/include/volk/machines.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - -generic - - - - - -generic 32|64 mmx sse sse2 - - - -generic 32|64 mmx sse sse2 sse3 - - - -generic 32|64 mmx sse sse2 sse3 ssse3 - - - -generic 32|64 mmx sse sse2 sse3 sse4_a popcount - - - -generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 - - - -generic 32|64 mmx sse sse2 sse3 ssse3 sse4_2 popcount - - - -generic 32|64 mmx sse sse2 sse3 ssse3 sse4_2 popcount avx - - - -generic altivec - - - diff --git a/volk/include/volk/make_c.py b/volk/include/volk/make_c.py deleted file mode 100644 index 591e8b64c..000000000 --- a/volk/include/volk/make_c.py +++ /dev/null @@ -1,100 +0,0 @@ -# -# Copyright 2010 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 . -# - -from volk_regexp import * -import string -from emit_omnilog import * - -#ok todo list: -#put n_archs into the info struct so it doesn't have to be arch_defs[0]. - -def make_c(machines, archs, functions, arched_arglist, my_arglist): - tempstring = r""" -// This file is automatically generated by make_c.py. -// Do not edit this file. -""" - tempstring += """ -#include -#include -#include -#include -#include -#include "volk_rank_archs.h" -#include -#include -#include - -""" - tempstring += emit_prolog(); - -#OK here's the deal. the .h prototypes the functions. the .c impls them as fptrs, can use p_whatever. -#also .c impls the get_machine call -#also .c impls the default call for each fn - -#here do static fn get arch - tempstring += r""" -struct volk_machine *get_machine(void) { - extern struct volk_machine volk_machines[]; - extern unsigned int n_volk_machines; - static struct volk_machine *machine = NULL; - - if(machine != NULL) return machine; - else { - unsigned int max_score = 0; - int i; - for(i=0; i max_score) { - max_score = volk_machines[i].caps; - machine = &(volk_machines[i]); - } - } - } - printf("Using Volk machine: %s\n", machine->name); - return machine; - } -} - -static unsigned int get_index(const char *indices[], unsigned int n_archs, const char *arch_name) { - int i; - for(i=0; i -#include - -struct VOLK_CPU volk_cpu; - -#if defined(__i386__) || (__x86_64__) -#include -#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3) - -static inline unsigned int cpuid_eax(unsigned int op) { - unsigned int regs[4]; - cpuid_x86 (op, regs); - return regs[0]; -} - -static inline unsigned int cpuid_ebx(unsigned int op) { - unsigned int regs[4]; - cpuid_x86 (op, regs); - return regs[1]; -} - -static inline unsigned int cpuid_ecx(unsigned int op) { - unsigned int regs[4]; - cpuid_x86 (op, regs); - return regs[2]; -} - -static inline unsigned int cpuid_edx(unsigned int op) { - unsigned int regs[4]; - cpuid_x86 (op, regs); - return regs[3]; -} -#endif - -""" - -def make_cpuid_c(dom) : - tempstring = HEADER_TEMPL; - - for domarch in dom: - if str(domarch.attributes["type"].value) == "x86": - if "no_test" in domarch.attributes.keys(): - no_test = str(domarch.attributes["no_test"].value); - if no_test == "true": - no_test = True; - else: - no_test = False; - else: - no_test = False; - arch = str(domarch.attributes["name"].value); - op = domarch.getElementsByTagName("op"); - if op: - op = str(op[0].firstChild.data); - reg = domarch.getElementsByTagName("reg"); - if reg: - reg = str(reg[0].firstChild.data); - shift = domarch.getElementsByTagName("shift"); - if shift: - shift = str(shift[0].firstChild.data); - val = domarch.getElementsByTagName("val"); - if val: - val = str(val[0].firstChild.data); - - if no_test: - tempstring = tempstring + """\ -int i_can_has_%s () { -#if defined(__i386__) || (__x86_64__) - return 1; -#else - return 0; -#endif -} - -""" % (arch) - - elif op == "1": - tempstring = tempstring + """\ -int i_can_has_%s () { -#if defined(__i386__) || (__x86_64__) - unsigned int e%sx = cpuid_e%sx (%s); - return ((e%sx >> %s) & 1) == %s; -#else - return 0; -#endif -} - -""" % (arch, reg, reg, op, reg, shift, val) - - elif op == "0x80000001": - tempstring = tempstring + """\ -int i_can_has_%s () { -#if defined(__i386__) || (__x86_64__) - unsigned int extended_fct_count = cpuid_eax(0x80000000); - if (extended_fct_count < 0x80000001) - return %s^1; - unsigned int extended_features = cpuid_e%sx (%s); - return ((extended_features >> %s) & 1) == %s; -#else - return 0; -#endif -} - -""" % (arch, val, reg, op, shift, val) - - elif str(domarch.attributes["type"].value) == "powerpc": - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + """\ -int i_can_has_%s () { -#ifdef __PPC__ - return 1; -#else - return 0; -#endif -} - -""" % (arch) - - elif str(domarch.attributes["type"].value) == "all": - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + """\ -int i_can_has_%s () { - return 1; -} - -""" % (arch) - else: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + """\ -int i_can_has_%s () { - return 0; -} - -""" % (arch) - - tempstring = tempstring + "void volk_cpu_init() {\n"; - for domarch in dom: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + " volk_cpu.has_" + arch + " = &i_can_has_" + arch + ";\n" - tempstring = tempstring + "}\n\n" - - tempstring = tempstring + "unsigned int volk_get_lvarch() {\n"; - tempstring = tempstring + " unsigned int retval = 0;\n" - tempstring = tempstring + " volk_cpu_init();\n" - for domarch in dom: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + " retval += volk_cpu.has_" + arch + "() << LV_" + arch.swapcase() + ";\n" - tempstring = tempstring + " return retval;\n" - tempstring = tempstring + "}\n\n" - - return tempstring; - - - - - - - diff --git a/volk/include/volk/make_cpuid_h.py b/volk/include/volk/make_cpuid_h.py deleted file mode 100644 index cd3da2455..000000000 --- a/volk/include/volk/make_cpuid_h.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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, or (at your option) -# any later version. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from xml.dom import minidom -from emit_omnilog import * - -def make_cpuid_h(dom) : - tempstring = ""; - tempstring = tempstring +'/*this file is auto generated by volk_register.py*/'; - tempstring = tempstring +'\n#ifndef INCLUDED_VOLK_CPU_H'; - tempstring = tempstring +'\n#define INCLUDED_VOLK_CPU_H\n\n'; - tempstring = tempstring + emit_prolog(); - tempstring = tempstring + '\n' - - tempstring = tempstring + "struct VOLK_CPU {\n" - for domarch in dom: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + " int (*has_" + arch + ") ();\n"; - tempstring = tempstring + "};\n\n"; - tempstring = tempstring + "extern struct VOLK_CPU volk_cpu;\n\n"; - - tempstring = tempstring + "void volk_cpu_init ();\n" - tempstring = tempstring + "unsigned int volk_get_lvarch ();\n" - - tempstring = tempstring + "\n"; - tempstring = tempstring + emit_epilog(); - tempstring = tempstring + "#endif /*INCLUDED_VOLK_CPU_H*/\n" - - return tempstring; diff --git a/volk/include/volk/make_each_machine_c.py b/volk/include/volk/make_each_machine_c.py deleted file mode 100644 index 94d6d7789..000000000 --- a/volk/include/volk/make_each_machine_c.py +++ /dev/null @@ -1,82 +0,0 @@ -# -# Copyright 2010 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 . -# - -from volk_regexp import * -import string -from emit_omnilog import * - -#ok todo list: -#put n_archs into the info struct so it doesn't have to be arch_defs[0]. - -def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist): - tempstring = r""" -// This file is automatically generated by make_each_machine_c.py. -// Do not edit this file. -""" - for arch in archs: - tempstring += "#define LV_HAVE_" + arch.swapcase() + " 1\n" - - tempstring += """ -#include -#include -#include - -""" - tempstring += emit_prolog(); - for func in functions: - tempstring += "#include \n" - tempstring += "\n\n" - - for i in range(len(functions)): - tempstring += "static const " + replace_volk.sub("p", functions[i]) + " " + functions[i] + "_archs[] = {\n" - - tags_counter = 0 - for arch_list in fcountlist[i]: - tempstring += "#if " - for arch in arch_list: - tempstring += "defined(LV_HAVE_" + arch + ") && " - tempstring = strip_trailing(tempstring, " && ") - tempstring += "\n " + functions[i] + "_" + str(taglist[i][tags_counter]) + ",\n" - tempstring += "#endif\n" - tags_counter += 1 - - tempstring = strip_trailing(tempstring, ",") - tempstring += "};\n\n" - - - tempstring += "static unsigned int caps = " - for arch in archs: - tempstring += "(1 << LV_" + arch.swapcase() + ") + " - tempstring = strip_trailing(tempstring, " + ") - tempstring += ";\n" - - tempstring += "static const char* name = \"" + machine_name + "\";\n" - tempstring += "struct volk_machine volk_machine_" + machine_name + " = {\n" - tempstring += " caps,\n" - tempstring += " name,\n" - - for i in range(len(functions)): - tempstring += " { " + functions[i] + "_indices, " + functions[i] + "_arch_defs, " + functions[i] + "_n_archs },\n" - tempstring += " " + functions[i] + "_archs,\n" - - tempstring = strip_trailing(tempstring, ",") - tempstring += "};\n" - tempstring += emit_epilog(); - - return tempstring - - diff --git a/volk/include/volk/make_environment_init_c.py b/volk/include/volk/make_environment_init_c.py deleted file mode 100644 index 263d5bcd1..000000000 --- a/volk/include/volk/make_environment_init_c.py +++ /dev/null @@ -1,32 +0,0 @@ -from xml.dom import minidom - -def make_environment_init_c(dom) : - tempstring = ""; - tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n"; - tempstring = tempstring + "#include\n" - for domarch in dom: - arch = str(domarch.attributes["name"].value); - incs = domarch.getElementsByTagName("include"); - for inc in incs: - my_inc = str(inc.firstChild.data); - tempstring = tempstring + "#ifdef LV_HAVE_" + arch.swapcase() + "\n"; - tempstring = tempstring + "#include<" + my_inc + ">\n"; - tempstring = tempstring + "#endif\n" - tempstring = tempstring + '\n\n'; - tempstring = tempstring + "void volk_environment_init(){\n" - - for domarch in dom: - arch = str(domarch.attributes["name"].value); - envs = domarch.getElementsByTagName("environment"); - for env in envs: - cmd = str(env.firstChild.data); - tempstring = tempstring + "#ifdef LV_HAVE_" + arch.swapcase() + "\n"; - tempstring = tempstring + " " + cmd + "\n"; - tempstring = tempstring + "#endif\n" - - tempstring = tempstring + "}\n"; - return tempstring; - - - - diff --git a/volk/include/volk/make_environment_init_h.py b/volk/include/volk/make_environment_init_h.py deleted file mode 100644 index 77a841a24..000000000 --- a/volk/include/volk/make_environment_init_h.py +++ /dev/null @@ -1,18 +0,0 @@ -from xml.dom import minidom -from emit_omnilog import * - -def make_environment_init_h() : - tempstring = ""; - tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n"; - tempstring = tempstring + "#ifndef INCLUDE_LIBVECTOR_ENVIRONMENT_INIT_H\n"; - tempstring = tempstring + "#define INCLUDE_LIBVECTOR_ENVIRONMENT_INIT_H\n"; - tempstring = tempstring + "\n"; - tempstring = tempstring + emit_prolog(); - tempstring = tempstring + "void volk_environment_init();\n"; - tempstring = tempstring + emit_epilog(); - tempstring = tempstring + "#endif\n" - return tempstring; - - - - diff --git a/volk/include/volk/make_h.py b/volk/include/volk/make_h.py deleted file mode 100644 index 07e62939b..000000000 --- a/volk/include/volk/make_h.py +++ /dev/null @@ -1,39 +0,0 @@ -from xml.dom import minidom -from emit_omnilog import * -from volk_regexp import * - -# http://gcc.gnu.org/wiki/Visibility -volk_api_defines = """ -#ifdef volk_EXPORTS -# define VOLK_API __VOLK_ATTR_EXPORT -#else -# define VOLK_API __VOLK_ATTR_IMPORT -#endif -""" - -def make_h(funclist, arched_arglist) : - tempstring = ""; - tempstring = tempstring + '/*this file is auto generated by make_h.py*/\n'; - - tempstring = tempstring + '\n#ifndef INCLUDED_VOLK_RUNTIME'; - tempstring = tempstring + '\n#define INCLUDED_VOLK_RUNTIME'; - tempstring = tempstring + '\n\n#include\n'; - tempstring = tempstring + '#include\n'; - tempstring = tempstring + '#include\n'; - tempstring = tempstring + '#include\n'; - tempstring = tempstring + volk_api_defines - tempstring = tempstring + emit_prolog(); - - tempstring = tempstring + '\n'; - - for i in range(len(funclist)): - tempstring += "extern " + replace_volk.sub("p", funclist[i]) + " " + funclist[i] + ";\n" - tempstring += "extern VOLK_API void %s_manual%s;\n" % (funclist[i], arched_arglist[i]) - tempstring = strip_trailing(tempstring, " {") - tempstring += "extern VOLK_API struct volk_func_desc %s_get_func_desc(void);\n" % (funclist[i]) - - tempstring = tempstring + emit_epilog(); - tempstring = tempstring + "#endif /*INCLUDED_VOLK_RUNTIME*/\n"; - - return tempstring; - diff --git a/volk/include/volk/make_machines_c.py b/volk/include/volk/make_machines_c.py deleted file mode 100644 index 9ad56fb62..000000000 --- a/volk/include/volk/make_machines_c.py +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright 2010 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 . -# - -from volk_regexp import * - -def make_machines_c(machines): - tempstring = r""" -// This file is automatically generated by make_machines_c.py. -// Do not edit this file. - -#include -#include -#include - -struct volk_machine volk_machines[] = { -""" - for machine in machines: - tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n" - tempstring += "volk_machine_" + machine - tempstring += "," - tempstring += "\n#endif\n" - - tempstring += r""" -}; - -""" - - for machine in machines: - tempstring += "#if LV_MACHINE_" + machine.swapcase() + "\n" - tempstring += "#define LV_MACHINE_" + machine.swapcase() + "_CNT 1\n" - tempstring += "#else\n" - tempstring += "#define LV_MACHINE_" + machine.swapcase() + "_CNT 0\n" - tempstring += "#endif\n" - - tempstring += """unsigned int n_volk_machines = -""" - for machine in machines: - tempstring += "(LV_MACHINE_" + machine.swapcase() + "_CNT) " - tempstring += "+ " - tempstring = tempstring[:-2] - tempstring += ";\n" - - return tempstring diff --git a/volk/include/volk/make_machines_h.py b/volk/include/volk/make_machines_h.py deleted file mode 100644 index 674ee12cd..000000000 --- a/volk/include/volk/make_machines_h.py +++ /dev/null @@ -1,50 +0,0 @@ -# -# Copyright 2010 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 . -# - -from volk_regexp import * - -def make_machines_h(functions, machines): - tempstring = r""" -// This file is automatically generated by make_machines_h.py. -// Do not edit this file. - -#ifndef INCLUDED_LIBVOLK_MACHINES_H -#define INCLUDED_LIBVOLK_MACHINES_H - -#include -#include - -struct volk_machine { - const unsigned int caps; //capabilities (i.e., archs compiled into this machine, in the volk_get_lvarch format) - const char *name; -""" - for function in functions: - tempstring += "\n const struct volk_func_desc " + function + "_desc;\n" - tempstring += " const " + replace_volk.sub("p", function) + " *" + function + "_archs;\n" - - tempstring += r"""}; - -""" - for machine in machines: - tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n" - tempstring += "extern const struct volk_machine volk_machine_" + machine + ";\n" - tempstring += """#endif\n""" - - tempstring += r""" -#endif //INCLUDED_LIBVOLK_MACHINES_H""" - - return tempstring diff --git a/volk/include/volk/make_makefile_am.py b/volk/include/volk/make_makefile_am.py deleted file mode 100644 index 2ff492b34..000000000 --- a/volk/include/volk/make_makefile_am.py +++ /dev/null @@ -1,131 +0,0 @@ -# -# Copyright 2010 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 . -# - -from xml.dom import minidom - -def make_makefile_am(dom, machines, archflags_dict): - tempstring = r""" -# This file is automatically generated by make_makefile_am.py. -# Do not edit this file. - -include $(top_srcdir)/Makefile.common - -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) \ - -I$(top_builddir)/include \ - -Dvolk_EXPORTS \ - -fvisibility=hidden \ - $(WITH_INCLUDES) - -lib_LTLIBRARIES = \ - libvolk.la - -EXTRA_DIST = \ - volk_rank_archs.h \ - gcc_x86_cpuid.h - -# ---------------------------------------------------------------- -# The main library -# ---------------------------------------------------------------- - -libvolk_la_SOURCES = \ - $(platform_CODE) \ - volk.cc \ - volk_cpu.c \ - volk_rank_archs.c \ - volk_machines.cc - -if LV_HAVE_ORC -volk_orc_CFLAGS = -DLV_HAVE_ORC=1 -volk_orc_LDFLAGS = $(ORC_LDFLAGS) -lorc-0.4 -volk_orc_LIBADD = ../orc/libvolk_orc.la -else -volk_orc_CFLAGS = -volk_orc_LDFLAGS = -volk_orc_LIBADD = -endif - -libvolk_la_CPPFLAGS = $(AM_CPPFLAGS) $(volk_orc_CFLAGS) -libvolk_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 $(volk_orc_LDFLAGS) -libvolk_la_LIBADD = $(volk_orc_LIBADD) - -noinst_LTLIBRARIES = - -""" - - #here be dragons - for machine_name in machines: - tempstring += "if LV_MACHINE_" + machine_name.swapcase() + "\n" - tempstring += "libvolk_" + machine_name + "_la_SOURCES = volk_machine_" + machine_name + ".cc\n" - tempstring += "libvolk_" + machine_name + "_la_CPPFLAGS = -I$(top_srcdir)/include $(volk_orc_CFLAGS) " - for arch in machines[machine_name]: - if archflags_dict[arch] != "none": - tempstring += "-" + archflags_dict[arch] + " " - - tempstring += "\nnoinst_LTLIBRARIES += libvolk_" + machine_name + ".la " - tempstring += "\nlibvolk_la_LIBADD += libvolk_" + machine_name + ".la\n" - tempstring += "libvolk_la_CPPFLAGS += -DLV_MACHINE_" + machine_name.swapcase() + " \n" - tempstring += "endif\n" - - - tempstring += r""" - -# ---------------------------------------------------------------- -# The QA library. Note libvolk.la in LIBADD -# ---------------------------------------------------------------- -#libvolk_qa_la_SOURCES = \ -# qa_utils.cc - -#libvolk_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 -lboost - -#libvolk_qa_la_LIBADD = \ -# libvolk.la \ -# libvolk_runtime.la - -# ---------------------------------------------------------------- -# headers that don't get installed -# ---------------------------------------------------------------- -noinst_HEADERS = \ - volk_init.h \ - qa_utils.h - -# ---------------------------------------------------------------- -# Our test program -# ---------------------------------------------------------------- -noinst_PROGRAMS = \ - testqa - -testqa_SOURCES = testqa.cc qa_utils.cc -testqa_CPPFLAGS = -DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN $(AM_CPPFLAGS) -testqa_LDFLAGS = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) -testqa_LDADD = \ - libvolk.la - -distclean-local: - rm -f volk.c - rm -f volk_cpu_generic.c - rm -f volk_cpu_powerpc.c - rm -f volk_cpu_x86.c - rm -f volk_init.c - rm -f volk_init.h - rm -f volk_mktables.c - rm -f volk_proccpu_sim.c - rm -f volk_tables.h - rm -f volk_environment_init.c -""" - - - return tempstring diff --git a/volk/include/volk/make_proccpu_sim.py b/volk/include/volk/make_proccpu_sim.py deleted file mode 100644 index 029dacfcc..000000000 --- a/volk/include/volk/make_proccpu_sim.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio 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, or (at your option) -# any later version. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from xml.dom import minidom - -def make_proccpu_sim(dom) : - tempstring = ""; - tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n"; - tempstring = tempstring + "#include \n" - tempstring = tempstring + "#include \n" - tempstring = tempstring + "\n\n" - - tempstring = tempstring + "void test_append(char* buf, int val, char* newkey){\n"; - tempstring = tempstring + " if(val==1){\n"; - tempstring = tempstring + " sprintf(buf, \"%s %s\", buf, newkey);\n"; - tempstring = tempstring + " }\n"; - tempstring = tempstring + "}\n"; - tempstring = tempstring + "\n\n"; - - tempstring = tempstring + "int main() {\n"; - tempstring = tempstring + " volk_cpu_init();\n"; - tempstring = tempstring + " char buf[2048];\n"; - for domarch in dom: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + " test_append(buf, volk_cpu.has_" + arch + "(), \"" + arch + "\");\n" - tempstring = tempstring + " printf(\"%s\\n\", buf);\n" - tempstring = tempstring + "}\n" - return tempstring; diff --git a/volk/include/volk/make_registry.py b/volk/include/volk/make_registry.py deleted file mode 100644 index de1f46aa6..000000000 --- a/volk/include/volk/make_registry.py +++ /dev/null @@ -1,85 +0,0 @@ -from xml.dom import minidom -from emit_omnilog import * -from volk_regexp import * -import string - -def make_registry(dom, funclist, fcountlist, taglist) : - tempstring = ""; - tempstring = tempstring + "/*this file is auto_generated by volk_register.py*/\n\n"; - tempstring = tempstring +'\n#ifndef INCLUDED_VOLK_REGISTRY_H'; - tempstring = tempstring +'\n#define INCLUDED_VOLK_REGISTRY_H\n\n'; - tempstring = tempstring +'#include\n'; - tempstring = tempstring + emit_prolog(); - tempstring = tempstring + '\n' - - - - - for domarch in dom: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring +"#ifdef LV_HAVE_" + arch.swapcase() + "\n"; - tempstring = tempstring +"#define LV_" + arch.swapcase() + "_CNT 1\n"; - tempstring = tempstring +"#else\n"; - tempstring = tempstring +"#define LV_" + arch.swapcase() + "_CNT 0\n"; - tempstring = tempstring +"#endif /*LV_HAVE_" + arch.swapcase() + "*/\n\n"; - - counter = 0; - - for i in range(len(funclist)): - tempstring = tempstring + "static const char* " + funclist[i] + "_indices[] = {\n"; - - tags_counter = 0; - for arch_list in fcountlist[i]: - tempstring = tempstring + "#if defined(LV_HAVE_" - for ind in range(len(arch_list)): - - tempstring = tempstring + arch_list[ind] + ")"; - if ind < len(arch_list) - 1: - tempstring = tempstring + " && defined(LV_HAVE_"; - - tempstring = tempstring + "\n \"" + str(taglist[i][tags_counter]) + "\",\n#endif\n"; - tags_counter = tags_counter + 1; - - tempstring = strip_trailing(tempstring, ",") - tempstring = tempstring + "};\n\n"; - - - for fcount in fcountlist: - tempstring = tempstring + "static const int " + funclist[counter] + "_arch_defs[] = {\n"; - counter += 1; - for arch_list in fcount: - tempstring = tempstring + "#if defined(LV_HAVE_" - for ind in range(len(arch_list)): - tempstring = tempstring + arch_list[ind] + ")"; - if ind < len(arch_list) - 1: - tempstring = tempstring + " && defined(LV_HAVE_"; - tempstring = tempstring + "\n" - tempstring = tempstring + " (1 << LV_" - for ind in range(len(arch_list)): - tempstring = tempstring + arch_list[ind]; - if ind < len(arch_list) - 1: - tempstring = tempstring + ") + (1 << LV_" - tempstring = tempstring + "),\n#endif\n" - tempstring = strip_trailing(tempstring, ",") - tempstring = tempstring + "};\n\n" - - counter = 0; - for fcount in fcountlist: - tempstring += "static const int " + funclist[counter] + "_n_archs = " - counter += 1; - for arch_list in fcount: - tempstring = tempstring + " (LV_" - for ind in range(len(arch_list)): - tempstring = tempstring + arch_list[ind] + "_CNT"; - if ind < len(arch_list) - 1: - tempstring = tempstring + " * LV_"; - tempstring = tempstring + ") + "; - tempstring = strip_trailing(tempstring, " + "); - tempstring = tempstring + ";\n" - - - tempstring = tempstring + emit_epilog(); - tempstring = tempstring +"#endif /*INCLUDED_VOLK_REGISTRY_H*/\n"; - - return tempstring; - diff --git a/volk/include/volk/make_set_simd.py b/volk/include/volk/make_set_simd.py deleted file mode 100644 index 5a848e59e..000000000 --- a/volk/include/volk/make_set_simd.py +++ /dev/null @@ -1,166 +0,0 @@ -# -# Copyright 2010 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 . -# - -from xml.dom import minidom - -def make_set_simd(dom, machines) : - tempstring = ""; - tempstring = tempstring +'dnl this file is auto generated by volk_register.py\n\n'; - - tempstring = tempstring +'\ndnl define arch checks\n'; - for domarch in dom: - if str(domarch.attributes["type"].value) != "all": - arch = str(domarch.attributes["name"].value); - flag = domarch.getElementsByTagName("flag"); - flag = str(flag[0].firstChild.data); - tempstring = tempstring + "AC_DEFUN([_TRY_ADD_" + arch.swapcase() + "],\n"; - tempstring = tempstring + "[\n"; - tempstring = tempstring + " LF_CHECK_CC_FLAG([-" + flag + "])\n"; - tempstring = tempstring + " LF_CHECK_CXX_FLAG([-" + flag + "])\n"; - tempstring = tempstring + "])\n"; - - tempstring = tempstring +'\ndnl main set_simd_flags\n'; - tempstring = tempstring + "AC_DEFUN([LV_SET_SIMD_FLAGS],\n"; - tempstring = tempstring + "[\n"; - #tempstring = tempstring + " AC_REQUIRE([GR_SET_MD_CPU])\n"; - tempstring = tempstring + " AC_SUBST(LV_CXXFLAGS)\n"; - tempstring = tempstring + " indCC=no\n"; - tempstring = tempstring + " indCXX=no\n"; - tempstring = tempstring + " indLV_ARCH=no\n"; - tempstring = tempstring + " AC_ARG_WITH(lv_arch,\n"; - tempstring = tempstring + " AC_HELP_STRING([--with-lv_arch=ARCH],[set volk hardware speedups as space separated string with elements from the following list("; - - for domarch in dom: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + arch + ", " - tempstring = tempstring[0:len(tempstring) - 2]; - - tempstring = tempstring + ")]),\n"; - tempstring = tempstring + " [cf_with_lv_arch=\"$withval\"],\n"; - tempstring = tempstring + " [cf_with_lv_arch=\"\"])\n"; - if str(domarch.attributes["type"].value) == "all": - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + " AC_DEFINE(LV_MAKE_" + arch.swapcase() + ", 1, [always set "+ arch + "!])\n"; - tempstring = tempstring + " ADDONS=\"\"\n"; - tempstring = tempstring + " BUILT_ARCHS=\"\"\n"; - #tempstring = tempstring + " _MAKE_FAKE_PROCCPU\n"; - tempstring = tempstring + " OVERRULE_FLAG=\"no\"\n"; - tempstring = tempstring + " if test -z \"$cf_with_lv_arch\"; then\n"; - tempstring = tempstring + " cf_with_lv_arch=\""; - for domarch in dom: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + arch + " "; - tempstring = tempstring[0:-1] + "\"\n"; - tempstring = tempstring + " OVERRULE_FLAG=\"yes\"\n"; - tempstring = tempstring + " fi\n"; - - tempstring = tempstring +'\ndnl init LV_MAKE_XXX and then try to add archs\n'; - for domarch in dom: - if str(domarch.attributes["type"].value) != "all": - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + " LV_MAKE_" + arch.swapcase() + "=no\n"; - - for domarch in dom: - arch = str(domarch.attributes["name"].value); - atype = str(domarch.attributes["type"].value); - if atype != "all": - tempstring = tempstring + " _TRY_ADD_" + arch.swapcase() + "\n"; - - for domarch in dom: - arch = str(domarch.attributes["name"].value); - atype = str(domarch.attributes["type"].value); - tempstring = tempstring +'\ndnl add in flags for arch ' + arch + '\n'; - overrule = domarch.getElementsByTagName("overrule"); - if overrule: - overrule = str(overrule[0].firstChild.data); - else: - overrule = ""; - overrule_val = domarch.getElementsByTagName("overrule_val"); - if overrule_val: - overrule_val = str(overrule_val[0].firstChild.data); - else: - overrule_val = ""; - flag = domarch.getElementsByTagName("flag"); - flag = str(flag[0].firstChild.data); - if atype != "all": - tempstring = tempstring + " for i in $lf_CXXFLAGS\n" - tempstring = tempstring + " do\n" - tempstring = tempstring + " if test \"X$i\" = X-" + flag +"; then\n"; - tempstring = tempstring + " indCXX=yes\n"; - tempstring = tempstring + " fi\n" - tempstring = tempstring + " done\n" - tempstring = tempstring + " for i in $lf_CFLAGS\n" - tempstring = tempstring + " do\n" - tempstring = tempstring + " if test \"X$i\" = X-" + flag +"; then\n"; - tempstring = tempstring + " indCC=yes\n"; - tempstring = tempstring + " fi\n" - tempstring = tempstring + " done\n" - tempstring = tempstring + " for i in $cf_with_lv_arch\n" - tempstring = tempstring + " do\n" - tempstring = tempstring + " if test \"X$i\" = X" + arch + "; then\n"; - tempstring = tempstring + " indLV_ARCH=yes\n" - tempstring = tempstring + " fi\n" - tempstring = tempstring + " done\n" - tempstring = tempstring + " if test -n \"" + overrule + "\" && test \"$" + overrule + "\" == \"" + overrule_val + "\" && test \"$OVERRULE_FLAG\" == \"yes\" && test \"$indLV_ARCH\" == \"yes\"; then\n" - tempstring = tempstring + " indLV_ARCH=no\n" - tempstring = tempstring + " fi\n" - - tempstring = tempstring + " if test \"$indCC\" == \"yes\" && test \"$indCXX\" == \"yes\" && test \"$indLV_ARCH\" == \"yes\"; then\n" - - #tempstring = tempstring + " ADDONS=\"${ADDONS} -" + flag + "\"\n"; - tempstring = tempstring + " BUILT_ARCHS=\"${BUILT_ARCHS} " + arch + "\"\n"; - tempstring = tempstring + " LV_MAKE_" + arch.swapcase() + "=yes\n"; - tempstring = tempstring + " fi\n" - tempstring = tempstring + " indCC=no\n" - tempstring = tempstring + " indCXX=no\n" - tempstring = tempstring + " indLV_ARCH=no\n" - else: - tempstring = tempstring + " for i in $cf_with_lv_arch\n" - tempstring = tempstring + " do\n" - tempstring = tempstring + " if test \"X$i\" = X" + arch + "; then\n"; - tempstring = tempstring + " indLV_ARCH=yes\n" - tempstring = tempstring + " fi\n" - tempstring = tempstring + " done\n" - tempstring = tempstring + " if test -n \"" + overrule + "\" && test \"$" + overrule + "\" == \"" + overrule_val + "\" && test \"$OVERRULE_FLAG\" == \"yes\" && test \"$indLV_ARCH\" == \"yes\"; then\n" - tempstring = tempstring + " indLV_ARCH=no\n" - tempstring = tempstring + " fi\n" - tempstring = tempstring + " if test \"$indLV_ARCH\" == \"yes\"; then\n" - tempstring = tempstring + " LV_MAKE_" + arch.swapcase() + "=yes\n"; - tempstring = tempstring + " BUILT_ARCHS=\"${BUILT_ARCHS} " + arch + "\"\n"; - tempstring = tempstring + " fi\n" - tempstring = tempstring + " indLV_ARCH=no\n" - - - for domarch in dom: - arch = str(domarch.attributes["name"].value); - tempstring = tempstring + " AM_CONDITIONAL(LV_MAKE_" + arch.swapcase() + ", test \"$LV_MAKE_" + arch.swapcase() + "\" == \"yes\")\n"; - - tempstring += "\n" - #now we can define the machines we're compiling - for machine_name in machines: - tempstring += " AM_CONDITIONAL(LV_MACHINE_" + machine_name.swapcase() + ", " - marchlist = machines[machine_name] - for march in marchlist: - tempstring += "test \"$LV_MAKE_" + march.swapcase() + "\" == \"yes\" && " - - tempstring += "test true)\n" #just so we don't have to detect the last one in the group, i know - tempstring = tempstring + " LV_CXXFLAGS=\"${LV_CXXFLAGS} ${ADDONS}\"\n" - tempstring = tempstring + "])\n" - - return tempstring; - - diff --git a/volk/include/volk/make_typedefs.py b/volk/include/volk/make_typedefs.py deleted file mode 100644 index 8f9f2b55e..000000000 --- a/volk/include/volk/make_typedefs.py +++ /dev/null @@ -1,23 +0,0 @@ -from xml.dom import minidom -import string -from volk_regexp import * - - - -def make_typedefs(funclist, retlist, my_argtypelist) : - tempstring = ""; - tempstring = tempstring + '/*this file is auto generated by volk_register.py*/'; - tempstring = tempstring + '/*this file is auto generated by volk_register.py*/'; - tempstring = tempstring + '\n#ifndef INCLUDED_VOLK_TYPEDEFS'; - tempstring = tempstring + '\n#define INCLUDED_VOLK_TYPEDEFS\n'; - tempstring = tempstring + '\n\n#include\n'; - tempstring = tempstring + '#include\n'; - - tempstring = tempstring + '\n'; - - for i in range(len(funclist)): - tempstring = tempstring + "typedef " + retlist[i] +" (*" + replace_volk.sub("p", funclist[i]) + ")(" + my_argtypelist[i] + ");\n"; - - tempstring = tempstring + "#endif /*INCLUDED_VOLK_TYPEDEFS*/\n"; - - return tempstring; diff --git a/volk/include/volk/volk_regexp.py b/volk/include/volk/volk_regexp.py deleted file mode 100644 index b83ce5206..000000000 --- a/volk/include/volk/volk_regexp.py +++ /dev/null @@ -1,14 +0,0 @@ -import re -import string - -remove_after_underscore = re.compile("_.*"); -space_remove = re.compile(" "); -leading_space_remove = re.compile("^ *"); -replace_arch = re.compile(", const char\* arch"); -replace_bracket = re.compile(" {"); -replace_volk = re.compile("volk"); - -def strip_trailing(tostrip, stripstr): - lindex = tostrip.rfind(stripstr) - tostrip = tostrip[0:lindex] + string.replace(tostrip[lindex:len(tostrip)], stripstr, ""); - return tostrip diff --git a/volk/include/volk/volk_register.py b/volk/include/volk/volk_register.py deleted file mode 100755 index 9b7ca73f9..000000000 --- a/volk/include/volk/volk_register.py +++ /dev/null @@ -1,291 +0,0 @@ -#! /usr/bin/env python - -import sys -import re -import string -from xml.dom import minidom -from volk_regexp import * -from make_cpuid_c import make_cpuid_c -from make_cpuid_h import make_cpuid_h -from make_set_simd import make_set_simd -from make_registry import make_registry -from make_config_fixed import make_config_fixed -from make_typedefs import make_typedefs -from make_environment_init_c import make_environment_init_c -from make_environment_init_h import make_environment_init_h -from make_makefile_am import make_makefile_am -from make_machines_h import make_machines_h -from make_machines_c import make_machines_c -from make_each_machine_c import make_each_machine_c -from make_c import make_c -from make_h import make_h -import copy - -outfile_set_simd = open("../../config/lv_set_simd_flags.m4", "w"); -outfile_reg = open("volk_registry.h", "w"); -outfile_h = open("volk.h", "w"); -outfile_c = open("../../lib/volk.cc", "w"); -outfile_typedefs = open("volk_typedefs.h", "w"); -outfile_init_h = open("../../lib/volk_init.h", "w"); -outfile_cpu_h = open("volk_cpu.h", "w"); -outfile_cpu_c = open("../../lib/volk_cpu.c", "w"); -#outfile_config_in = open("../../volk_config.h.in", "w"); -outfile_config_fixed = open("volk_config_fixed.h", "w"); -#outfile_mktables = open("../../lib/volk_mktables.c", "w"); -outfile_environment_c = open("../../lib/volk_environment_init.c", "w"); -outfile_environment_h = open("volk_environment_init.h", "w"); -outfile_makefile_am = open("../../lib/Makefile.am", "w"); -outfile_machines_h = open("volk_machines.h", "w"); -outfile_machines_c = open("../../lib/volk_machines.cc", "w"); -infile = open("Makefile.am", "r"); - - -mfile = infile.readlines(); - -datatypes = []; -functions = []; - - - -for line in mfile: - subline = re.search(".*_(a16|u)\.h.*", line); - if subline: - subsubline = re.search("(?<=volk_).*", subline.group(0)); - if subsubline: - dtype = remove_after_underscore.sub("", subsubline.group(0)); - subdtype = re.search("[0-9]+[A-z]+", dtype); - if subdtype: - datatypes.append(subdtype.group(0)); - - -datatypes = set(datatypes); - -for line in mfile: - for dt in datatypes: - if dt in line: - subline = re.search("(volk_" + dt +"_.*(a16|u).*\.h)", line); - if subline: - - subsubline = re.search(".+(?=\.h)", subline.group(0)); - functions.append(subsubline.group(0)); - -archs = []; -afile = minidom.parse("archs.xml"); -filearchs = afile.getElementsByTagName("arch"); -for filearch in filearchs: - archs.append(str(filearch.attributes["name"].value)); - -for arch in archs: - a_var = re.search("^\$", arch); - if a_var: - archs.remove(arch); - - - -archflags_dict = {} -for filearch in filearchs: - archflags_dict[str(filearch.attributes["name"].value)] = str(filearch.getElementsByTagName("flag")[0].firstChild.data) - -archs_or = "(" -for arch in archs: - archs_or = archs_or + string.upper(arch) + "|"; -archs_or = archs_or[0:len(archs_or)-1]; -archs_or = archs_or + ")"; - -#get machine list and parse to a list of machines, each with a list of archs (none of this DOM crap) -machine_str_dict = {} -mfile = minidom.parse("machines.xml"); -filemachines = mfile.getElementsByTagName("machine") - -for filemachine in filemachines: - machine_str_dict[str(filemachine.attributes["name"].value)] = str(filemachine.getElementsByTagName("archs")[0].firstChild.data).split() - -#all right now you have a dict of arch lists -#next we expand it -#this is an expanded list accounting for the OR syntax -#TODO: make this work for multiple "|" machines -machines = {} -already_done = False -for machine_name in machine_str_dict: - already_done = False - marchlist = machine_str_dict[machine_name] - for march in marchlist: - or_marchs = march.split("|") - if len(or_marchs) > 1: - marchlist.remove(march) - for or_march in or_marchs: - tempmarchlist = copy.deepcopy(marchlist) - tempmarchlist.append(or_march) - machines[machine_name + "_" + or_march] = tempmarchlist - already_done = True - - if not already_done: - machines[machine_name] = marchlist - -#for machine_name in machines: -# print machine_name + ": " + str(machines[machine_name]) - -#ok, now we have all the machines we're going to build. next step is to generate a Makefile.am where they're all laid out and compiled - -taglist = []; -fcountlist = []; -arched_arglist = []; -retlist = []; -my_arglist = []; -my_argtypelist = []; -for func in functions: - tags = []; - fcount = []; - infile_source = open(func + ".h"); - begun_name = 0; - begun_paren = 0; - sourcefile = infile_source.readlines(); - infile_source.close(); - for line in sourcefile: -#FIXME: make it work for multiple #if define()s - archline = re.search("^\#if.*?LV_HAVE_" + archs_or + ".*", line); - if archline: - arch = archline.group(0); - archline = re.findall(archs_or + "(?=( |\n|&))", line); - if archline: - archsublist = []; - for tup in archline: - archsublist.append(tup[0]); - fcount.append(archsublist); - testline = re.search("static inline.*?" + func, line); - if (not testline): - continue - tagline = re.search(func + "_.+", line); - if tagline: - tag = re.search("(?<=" + func + "_)\w+(?= *\()",line); - if tag: - tag = re.search("\w+", tag.group(0)); - if tag: - tags.append(tag.group(0)); - - - if begun_name == 0: - retline = re.search(".+(?=" + func + ")", line); - if retline: - ret = retline.group(0); - - - - - subline = re.search(func + ".*", line); - if subline: - subsubline = re.search("\(.*?\)", subline.group(0)); - if subsubline: - args = subsubline.group(0); - - else: - begun_name = 1; - subsubline = re.search("\(.*", subline.group(0)); - if subsubline: - args = subsubline.group(0); - begun_paren = 1; - else: - if begun_paren == 1: - subline = re.search(".*?\)", line); - if subline: - args = args + subline.group(0); - begun_name = 0; - begun_paren = 0; - else: - subline = re.search(".*", line); - args = args + subline.group(0); - else: - subline = re.search("\(.*?\)", line); - if subline: - args = subline.group(0); - begun_name = 0; - else: - subline = re.search("\(.*", line); - if subline: - args = subline.group(0); - begun_paren = 1; - - replace = re.compile("static "); - ret = replace.sub("", ret); - replace = re.compile("inline "); - ret = replace.sub("", ret); - replace = re.compile("\)"); - arched_args = replace.sub(", const char* arch) {", args); - - remove = re.compile('\)|\(|{'); - rargs = remove.sub("", args); - sargs = rargs.split(','); - - - - margs = []; - atypes = []; - for arg in sargs: - temp = arg.split(" "); - margs.append(temp[-1]); - replace = re.compile(" " + temp[-1]); - atypes.append(replace.sub("", arg)); - - - my_args = "" - arg_types = "" - for arg in range(0, len(margs) - 1): - this_arg = leading_space_remove.sub("", margs[arg]); - my_args = my_args + this_arg + ", "; - this_type = leading_space_remove.sub("", atypes[arg]); - arg_types = arg_types + this_type + ", "; - - this_arg = leading_space_remove.sub("", margs[-1]); - my_args = my_args + this_arg; - this_type = leading_space_remove.sub("", atypes[-1]); - arg_types = arg_types + this_type; - my_argtypelist.append(arg_types); - - if(ret[-1] != ' '): - ret = ret + ' '; - - arched_arglist.append(arched_args); #!!!!!!!!!!! - my_arglist.append(my_args) #!!!!!!!!!!!!!!!!! - retlist.append(ret); - fcountlist.append(fcount); - taglist.append(tags); - - -outfile_cpu_h.write(make_cpuid_h(filearchs)); -outfile_cpu_h.close(); - -outfile_cpu_c.write(make_cpuid_c(filearchs)); -outfile_cpu_c.close(); - -outfile_set_simd.write(make_set_simd(filearchs, machines)); -outfile_set_simd.close(); - -outfile_reg.write(make_registry(filearchs, functions, fcountlist, taglist)); -outfile_reg.close(); - -outfile_config_fixed.write(make_config_fixed(filearchs)); -outfile_config_fixed.close(); - -outfile_typedefs.write(make_typedefs(functions, retlist, my_argtypelist)); -outfile_typedefs.close(); - -outfile_makefile_am.write(make_makefile_am(filearchs, machines, archflags_dict)) -outfile_makefile_am.close() - -outfile_machines_h.write(make_machines_h(functions, machines)) -outfile_machines_h.close() - -outfile_machines_c.write(make_machines_c(machines)) -outfile_machines_c.close() - -outfile_c.write(make_c(machines, archs, functions, arched_arglist, my_arglist)) -outfile_c.close() - -outfile_h.write(make_h(functions, arched_arglist)) -outfile_h.close() - -for machine in machines: - machine_c_filename = "../../lib/volk_machine_" + machine + ".cc" - outfile_machine_c = open(machine_c_filename, "w") - outfile_machine_c.write(make_each_machine_c(machine, machines[machine], functions, fcountlist, taglist)) - outfile_machine_c.close() diff --git a/volk/lib/.gitignore b/volk/lib/.gitignore index c676a61df..28ec6ddaa 100644 --- a/volk/lib/.gitignore +++ b/volk/lib/.gitignore @@ -1,18 +1,4 @@ -/*.cache -/*.la -/*.lo -/*.pc -/.deps -/.la -/.libs -/.lo /Makefile /Makefile.in /Makefile.am -/volk_environment_init.c -/volk_init.h /testqa -/volk.cc -/volk_cpu.c -/volk_machine_*.cc -/volk_machines.cc -- cgit