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/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 ++++++++++++++++++++++++++++++++++++
22 files changed, 1605 insertions(+)
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
(limited to 'volk/gen')
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%s_archs[volk_rank_archs(get_machine()->%s_desc.arch_defs, get_machine()->%s_desc.n_archs, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i])
+ tempstring += " %s(%s);\n}\n\n" % (functions[i], my_arglist[i])
+ tempstring += replace_volk.sub("p", functions[i]) + " " + functions[i] + " = &get_" + functions[i] + ";\n\n"
+ tempstring += "void %s_manual%s\n" % (functions[i], arched_arglist[i])
+ tempstring += " get_machine()->%s_archs[get_index(get_machine()->%s_desc.indices, get_machine()->%s_desc.n_archs, arch)](%s);\n}\n" % (functions[i], functions[i], functions[i], my_arglist[i])
+ tempstring += "struct volk_func_desc %s_get_func_desc(void) {\n" % (functions[i])
+ tempstring += " return get_machine()->%s_desc;\n}\n" % (functions[i])
+
+ tempstring += emit_epilog();
+
+ return tempstring
+
+
diff --git a/volk/gen/make_config_fixed.py b/volk/gen/make_config_fixed.py
new file mode 100644
index 000000000..3fd1bdf0a
--- /dev/null
+++ b/volk/gen/make_config_fixed.py
@@ -0,0 +1,21 @@
+from xml.dom import minidom
+
+def make_config_fixed(dom) :
+ tempstring = "";
+ tempstring = tempstring +'/*this file is auto generated by volk_register.py*/';
+ tempstring = tempstring + '\n#ifndef INCLUDED_VOLK_CONFIG_FIXED_H';
+ tempstring = tempstring + '\n#define INCLUDED_VOLK_CONFIG_FIXED_H';
+ tempstring = tempstring + '\n\n';
+ enum_counter = 0;
+ for domarch in dom:
+ arch = str(domarch.attributes["name"].value);
+ tempstring = tempstring + '#define LV_' + arch.swapcase() + " " + str(enum_counter) + '\n';
+ enum_counter = enum_counter + 1;
+ tempstring = tempstring + '\n\n';
+
+ tempstring = tempstring + "#endif /*INCLUDED_VOLK_CONFIG_FIXED*/\n"
+
+ return tempstring;
+
+
+
diff --git a/volk/gen/make_config_in.py b/volk/gen/make_config_in.py
new file mode 100644
index 000000000..d29680af2
--- /dev/null
+++ b/volk/gen/make_config_in.py
@@ -0,0 +1,13 @@
+from xml.dom import minidom
+
+def make_config_in(dom) :
+ tempstring = "";
+ tempstring = tempstring +'/*this file is auto generated by volk_register.py*/';
+ tempstring = tempstring + '\n\n';
+
+ for domarch in dom:
+ arch = str(domarch.attributes["name"].value);
+ tempstring = tempstring + '#undef LV_HAVE_' + arch.swapcase() + '\n';
+ tempstring = tempstring + '\n';
+
+ return tempstring
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
new file mode 100644
index 000000000..20621769b
--- /dev/null
+++ b/volk/gen/make_cpuid_c.py
@@ -0,0 +1,184 @@
+#!/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
+
+HEADER_TEMPL = """\
+/*this file is auto_generated by volk_register.py*/
+
+#include
+#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()
--
cgit
From 701b1c520865388a4287c6a3f63afb3ce2626cf1 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Thu, 5 May 2011 19:02:03 -0700
Subject: volk: make volk_machines.cc c-safe
Initialize the list of machine structs w/ pointers,
this does not rely on C++ initialization and is smaller.
In addition, rename the file extension to .c so we know its C only.
Interesting note, this also fixes a bug when compiling under MSVC,
the machines list initialization seemed to have problems prior to this change.
---
volk/gen/make_c.py | 12 ++++++------
volk/gen/make_machines_c.py | 24 ++++--------------------
volk/gen/make_machines_h.py | 4 ++--
volk/gen/make_makefile_am.py | 4 ++--
volk/gen/volk_register.py | 2 +-
5 files changed, 15 insertions(+), 31 deletions(-)
mode change 100755 => 100644 volk/gen/volk_register.py
(limited to 'volk/gen')
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index 591e8b64c..5bad910ae 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2011 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
@@ -48,7 +48,7 @@ def make_c(machines, archs, functions, arched_arglist, my_arglist):
#here do static fn get arch
tempstring += r"""
struct volk_machine *get_machine(void) {
- extern struct volk_machine volk_machines[];
+ extern struct volk_machine *volk_machines[];
extern unsigned int n_volk_machines;
static struct volk_machine *machine = NULL;
@@ -57,10 +57,10 @@ struct volk_machine *get_machine(void) {
unsigned int max_score = 0;
int i;
for(i=0; i max_score) {
- max_score = volk_machines[i].caps;
- machine = &(volk_machines[i]);
+ if(!(volk_machines[i]->caps & (~volk_get_lvarch()))) {
+ if(volk_machines[i]->caps > max_score) {
+ max_score = volk_machines[i]->caps;
+ machine = volk_machines[i];
}
}
}
diff --git a/volk/gen/make_machines_c.py b/volk/gen/make_machines_c.py
index 9ad56fb62..ccac21131 100644
--- a/volk/gen/make_machines_c.py
+++ b/volk/gen/make_machines_c.py
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2011 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
@@ -26,32 +26,16 @@ def make_machines_c(machines):
#include
#include
-struct volk_machine volk_machines[] = {
+struct volk_machine *volk_machines[] = {
"""
for machine in machines:
tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n"
- tempstring += "volk_machine_" + machine
+ 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 =
+unsigned int n_volk_machines = sizeof(volk_machines)/sizeof(*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
index 674ee12cd..082ca1488 100644
--- a/volk/gen/make_machines_h.py
+++ b/volk/gen/make_machines_h.py
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2011 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
@@ -41,7 +41,7 @@ struct volk_machine {
"""
for machine in machines:
tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n"
- tempstring += "extern const struct volk_machine volk_machine_" + machine + ";\n"
+ tempstring += "extern struct volk_machine volk_machine_" + machine + ";\n"
tempstring += """#endif\n"""
tempstring += r"""
diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py
index 0d746ca28..929b6075d 100644
--- a/volk/gen/make_makefile_am.py
+++ b/volk/gen/make_makefile_am.py
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2011 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
@@ -46,7 +46,7 @@ libvolk_la_SOURCES = \
$(top_gendir)/lib/volk.cc \
$(top_gendir)/lib/volk_cpu.c \
volk_rank_archs.c \
- $(top_gendir)/lib/volk_machines.cc
+ $(top_gendir)/lib/volk_machines.c
if LV_HAVE_ORC
volk_orc_CFLAGS = -DLV_HAVE_ORC=1
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
old mode 100755
new mode 100644
index 19fc61c15..aae32c705
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -50,7 +50,7 @@ outfile_environment_c = open(os.path.join(gendir, "lib/volk_environment_init.c")
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")
+outfile_machines_c = open(os.path.join(gendir, "lib/volk_machines.c"), "w")
infile = open(os.path.join(srcdir, "include/volk/Makefile.am"), "r")
--
cgit
From f9f3509dabe429953afc30ca7672b167dc4b5523 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Fri, 6 May 2011 11:01:57 -0700
Subject: volk: make volk_machine_xxx.cc c-safe
Initialize each machine struct using C constants,
(rather than relying on C++ to copy objects).
Each machine file is far simpler,
because we know what archs are in a machine,
we can generate exactly the right code.
In addition, rename the file extensions to .c so we know its C only.
---
volk/gen/make_c.py | 7 +++--
volk/gen/make_each_machine_c.py | 61 ++++++++++++++++++-----------------------
volk/gen/make_machines_h.py | 8 ++++--
volk/gen/make_makefile_am.py | 2 +-
volk/gen/volk_register.py | 4 +--
5 files changed, 38 insertions(+), 44 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index 5bad910ae..65c42d89a 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -85,13 +85,14 @@ static unsigned int get_index(const char *indices[], unsigned int n_archs, const
for i in range(len(functions)):
tempstring += "void get_" + functions[i] + replace_arch.sub("", arched_arglist[i]) + "\n"
- tempstring += " %s = get_machine()->%s_archs[volk_rank_archs(get_machine()->%s_desc.arch_defs, get_machine()->%s_desc.n_archs, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i])
+ tempstring += " %s = get_machine()->%s_archs[volk_rank_archs(get_machine()->%s_arch_defs, get_machine()->%s_n_archs, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i])
tempstring += " %s(%s);\n}\n\n" % (functions[i], my_arglist[i])
tempstring += replace_volk.sub("p", functions[i]) + " " + functions[i] + " = &get_" + functions[i] + ";\n\n"
tempstring += "void %s_manual%s\n" % (functions[i], arched_arglist[i])
- tempstring += " get_machine()->%s_archs[get_index(get_machine()->%s_desc.indices, get_machine()->%s_desc.n_archs, arch)](%s);\n}\n" % (functions[i], functions[i], functions[i], my_arglist[i])
+ tempstring += " get_machine()->%s_archs[get_index(get_machine()->%s_indices, get_machine()->%s_n_archs, arch)](%s);\n}\n" % (functions[i], functions[i], functions[i], my_arglist[i])
tempstring += "struct volk_func_desc %s_get_func_desc(void) {\n" % (functions[i])
- tempstring += " return get_machine()->%s_desc;\n}\n" % (functions[i])
+ tempstring += " struct volk_func_desc desc = {get_machine()->%s_indices, get_machine()->%s_arch_defs, get_machine()->%s_n_archs};\n" % (functions[i], functions[i], functions[i])
+ tempstring += " return desc;\n}\n"
tempstring += emit_epilog();
diff --git a/volk/gen/make_each_machine_c.py b/volk/gen/make_each_machine_c.py
index 94d6d7789..4e6684745 100644
--- a/volk/gen/make_each_machine_c.py
+++ b/volk/gen/make_each_machine_c.py
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2011 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
@@ -19,10 +19,21 @@ 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):
+
+ #make the machine fcountlist and taglist a subset given the archs list
+ machine_fcountlists = list()
+ machine_taglists = list()
+ for i in range(len(fcountlist)):
+ machine_fcountlist = list()
+ machine_taglist = list()
+ for j in range(len(fcountlist[i])):
+ if len(set(archs).intersection(map(str.lower, fcountlist[i][j]))) == len(fcountlist[i][j]):
+ machine_fcountlist.append(fcountlist[i][j])
+ machine_taglist.append(taglist[i][j])
+ machine_fcountlists.append(machine_fcountlist)
+ machine_taglists.append(machine_taglist)
+
tempstring = r"""
// This file is automatically generated by make_each_machine_c.py.
// Do not edit this file.
@@ -33,46 +44,26 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
tempstring += """
#include
#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"
+ #create the volk machine struct for this machine file
tempstring += "struct volk_machine volk_machine_" + machine_name + " = {\n"
- tempstring += " caps,\n"
- tempstring += " name,\n"
-
+ tempstring += " " + ' | '.join(["(1 << LV_" + arch.swapcase() + ")" for arch in archs]) + ",\n"
+ tempstring += " \"%s\",\n"%machine_name
+
+ #fill in the description for each function
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 += " {%s},\n"%(', '.join(['"%s"'%tag for tag in machine_taglists[i]]))
+ tempstring += " {%s},\n"%(', '.join([' | '.join(['(1 << LV_%s)'%fc for fc in fcount]) for fcount in machine_fcountlists[i]]))
+ tempstring += " {%s},\n"%(', '.join(['%s_%s'%(functions[i], tag) for tag in machine_taglists[i]]))
+ tempstring += " %d,\n"%len(machine_taglists[i])
+
tempstring = strip_trailing(tempstring, ",")
tempstring += "};\n"
tempstring += emit_epilog();
diff --git a/volk/gen/make_machines_h.py b/volk/gen/make_machines_h.py
index 082ca1488..aa6daa6cc 100644
--- a/volk/gen/make_machines_h.py
+++ b/volk/gen/make_machines_h.py
@@ -17,7 +17,7 @@
from volk_regexp import *
-def make_machines_h(functions, machines):
+def make_machines_h(functions, machines, archs):
tempstring = r"""
// This file is automatically generated by make_machines_h.py.
// Do not edit this file.
@@ -33,8 +33,10 @@ struct volk_machine {
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 += " const char *%s_indices[%d];\n"%(function, len(archs))
+ tempstring += " const int %s_arch_defs[%d];\n"%(function, len(archs))
+ tempstring += " const %s %s_archs[%d];\n"%(replace_volk.sub("p", function), function, len(archs))
+ tempstring += " const int %s_n_archs;\n"%function
tempstring += r"""};
diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py
index 929b6075d..54017d2b3 100644
--- a/volk/gen/make_makefile_am.py
+++ b/volk/gen/make_makefile_am.py
@@ -69,7 +69,7 @@ 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_SOURCES = $(top_gendir)/lib/volk_machine_" + machine_name + ".c\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":
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index aae32c705..f67a8d17e 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -286,7 +286,7 @@ 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.write(make_machines_h(functions, machines, archs))
outfile_machines_h.close()
outfile_machines_c.write(make_machines_c(machines))
@@ -299,7 +299,7 @@ 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")
+ machine_c_filename = os.path.join(gendir, "lib/volk_machine_" + machine + ".c")
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()
--
cgit
From 12413747c90754482582e16c95b551e1b36c6074 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Fri, 6 May 2011 11:25:00 -0700
Subject: volk: removed volk_registry.h, it was superseded by the machines
---
volk/gen/make_c.py | 1 -
volk/gen/make_registry.py | 85 -----------------------------------------------
volk/gen/volk_register.py | 6 ----
3 files changed, 92 deletions(-)
delete mode 100644 volk/gen/make_registry.py
(limited to 'volk/gen')
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index 65c42d89a..3fe604f39 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -30,7 +30,6 @@ def make_c(machines, archs, functions, arched_arglist, my_arglist):
tempstring += """
#include
#include
-#include
#include
#include
#include "volk_rank_archs.h"
diff --git a/volk/gen/make_registry.py b/volk/gen/make_registry.py
deleted file mode 100644
index de1f46aa6..000000000
--- a/volk/gen/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/gen/volk_register.py b/volk/gen/volk_register.py
index f67a8d17e..a239811db 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -9,7 +9,6 @@ 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
@@ -36,7 +35,6 @@ for dir in (
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")
@@ -45,7 +43,6 @@ 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")
@@ -273,9 +270,6 @@ 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();
--
cgit
From 5b4c7d27e9d49ab58df1f1d9350dcaf64c60a1ce Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Fri, 6 May 2011 12:41:16 -0700
Subject: volk: top-level common header cleanup
Since we already have a volk_common.h,
moved the attributes, API declaration,
and c-linkage macros into volk_common.h
This change removes volk_attributes.h,
in favor of one common include header.
The implementation headers that require
attributes now include volk_common.h
This change removes the emit_omnilog.py script,
in favor of pre-processor macros in volk_common.h
In addition, extern C is only defined when in C++
and in GCC because non-GCC does not have complex.h
---
volk/gen/emit_omnilog.py | 13 -------------
volk/gen/make_c.py | 6 +-----
volk/gen/make_cpuid_h.py | 6 +++---
volk/gen/make_each_machine_c.py | 3 ---
volk/gen/make_environment_init_h.py | 6 +++---
volk/gen/make_h.py | 24 ++++++++++--------------
volk/gen/make_machines_h.py | 5 +++++
volk/gen/make_makefile_am.py | 3 ++-
volk/gen/volk_register.py | 2 +-
9 files changed, 25 insertions(+), 43 deletions(-)
delete mode 100644 volk/gen/emit_omnilog.py
(limited to 'volk/gen')
diff --git a/volk/gen/emit_omnilog.py b/volk/gen/emit_omnilog.py
deleted file mode 100644
index 309d7e578..000000000
--- a/volk/gen/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/gen/make_c.py b/volk/gen/make_c.py
index 3fe604f39..4e67f31ff 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -17,7 +17,6 @@
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].
@@ -38,8 +37,7 @@ def make_c(machines, archs, functions, arched_arglist, my_arglist):
#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
@@ -93,8 +91,6 @@ static unsigned int get_index(const char *indices[], unsigned int n_archs, const
tempstring += " struct volk_func_desc desc = {get_machine()->%s_indices, get_machine()->%s_arch_defs, get_machine()->%s_n_archs};\n" % (functions[i], functions[i], functions[i])
tempstring += " return desc;\n}\n"
- tempstring += emit_epilog();
-
return tempstring
diff --git a/volk/gen/make_cpuid_h.py b/volk/gen/make_cpuid_h.py
index cd3da2455..4fe5c4e07 100644
--- a/volk/gen/make_cpuid_h.py
+++ b/volk/gen/make_cpuid_h.py
@@ -21,14 +21,14 @@
#
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 + "#include \n\n";
+ tempstring = tempstring + '__VOLK_DECL_BEGIN\n';
tempstring = tempstring + '\n'
tempstring = tempstring + "struct VOLK_CPU {\n"
@@ -42,7 +42,7 @@ def make_cpuid_h(dom) :
tempstring = tempstring + "unsigned int volk_get_lvarch ();\n"
tempstring = tempstring + "\n";
- tempstring = tempstring + emit_epilog();
+ tempstring = tempstring + "__VOLK_DECL_END\n";
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
index 4e6684745..6d9b8c65f 100644
--- a/volk/gen/make_each_machine_c.py
+++ b/volk/gen/make_each_machine_c.py
@@ -17,7 +17,6 @@
from volk_regexp import *
import string
-from emit_omnilog import *
def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
@@ -47,7 +46,6 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
#include
"""
- tempstring += emit_prolog();
for func in functions:
tempstring += "#include \n"
tempstring += "\n\n"
@@ -66,7 +64,6 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
tempstring = strip_trailing(tempstring, ",")
tempstring += "};\n"
- tempstring += emit_epilog();
return tempstring
diff --git a/volk/gen/make_environment_init_h.py b/volk/gen/make_environment_init_h.py
index 77a841a24..655d73f54 100644
--- a/volk/gen/make_environment_init_h.py
+++ b/volk/gen/make_environment_init_h.py
@@ -1,5 +1,4 @@
from xml.dom import minidom
-from emit_omnilog import *
def make_environment_init_h() :
tempstring = "";
@@ -7,9 +6,10 @@ def make_environment_init_h() :
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 + "#include \n\n";
+ tempstring = tempstring + "__VOLK_DECL_BEGIN\n";
tempstring = tempstring + "void volk_environment_init();\n";
- tempstring = tempstring + emit_epilog();
+ tempstring = tempstring + "__VOLK_DECL_END\n";
tempstring = tempstring + "#endif\n"
return tempstring;
diff --git a/volk/gen/make_h.py b/volk/gen/make_h.py
index 07e62939b..3d5790de4 100644
--- a/volk/gen/make_h.py
+++ b/volk/gen/make_h.py
@@ -1,16 +1,6 @@
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';
@@ -19,20 +9,26 @@ def make_h(funclist, arched_arglist) :
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 + '#include\n';
- tempstring = tempstring + volk_api_defines
- tempstring = tempstring + emit_prolog();
+ tempstring = tempstring + '__VOLK_DECL_BEGIN\n';
tempstring = tempstring + '\n';
+ tempstring += """
+struct volk_func_desc {
+ const char **indices;
+ const int *arch_defs;
+ const int n_archs;
+};
+"""
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 + '__VOLK_DECL_END\n';
tempstring = tempstring + "#endif /*INCLUDED_VOLK_RUNTIME*/\n";
return tempstring;
diff --git a/volk/gen/make_machines_h.py b/volk/gen/make_machines_h.py
index aa6daa6cc..09ada3e0d 100644
--- a/volk/gen/make_machines_h.py
+++ b/volk/gen/make_machines_h.py
@@ -28,6 +28,8 @@ def make_machines_h(functions, machines, archs):
#include
#include
+__VOLK_DECL_BEGIN
+
struct volk_machine {
const unsigned int caps; //capabilities (i.e., archs compiled into this machine, in the volk_get_lvarch format)
const char *name;
@@ -47,6 +49,9 @@ struct volk_machine {
tempstring += """#endif\n"""
tempstring += r"""
+
+__VOLK_DECL_END
+
#endif //INCLUDED_LIBVOLK_MACHINES_H"""
return tempstring
diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py
index 54017d2b3..ff9749e17 100644
--- a/volk/gen/make_makefile_am.py
+++ b/volk/gen/make_makefile_am.py
@@ -25,6 +25,7 @@ def make_makefile_am(dom, machines, archflags_dict):
include $(top_srcdir)/Makefile.common
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) \
+ -I$(top_srcdir)/include \
-I$(top_gendir)/include \
-Dvolk_EXPORTS \
-fvisibility=hidden \
@@ -43,7 +44,7 @@ EXTRA_DIST = \
libvolk_la_SOURCES = \
$(platform_CODE) \
- $(top_gendir)/lib/volk.cc \
+ $(top_gendir)/lib/volk.c \
$(top_gendir)/lib/volk_cpu.c \
volk_rank_archs.c \
$(top_gendir)/lib/volk_machines.c
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index a239811db..dba364e01 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -36,7 +36,7 @@ for dir in (
outfile_set_simd = open(os.path.join(gendir, "config/lv_set_simd_flags.m4"), "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_c = open(os.path.join(gendir, "lib/volk.c"), "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")
--
cgit
From c40ef84defaeed0c9ec70e45a7e4019fa6d6e1b2 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Fri, 6 May 2011 14:27:48 -0700
Subject: volk: various backports from MSVC building
1) Added support for __cpuid intrinsic under MSVC
2) Fixed disambiguation for std::abs overload in qa code
3) Fixed bit128 union, the ifdefs were completely wrong
---
volk/gen/make_cpuid_c.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
(limited to 'volk/gen')
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 20621769b..2fdbaf304 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -31,9 +31,21 @@ HEADER_TEMPL = """\
struct VOLK_CPU volk_cpu;
#if defined(__i386__) || (__x86_64__)
+
+//implement get cpuid for gcc compilers using a copy of cpuid.h
+#if defined(__GNUC__)
#include
#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3)
+//implement get cpuid for MSVC compilers using __cpuid intrinsic
+#elif defined(_MSC_VER)
+#include
+#define cpuid(op, r) __cpuid(r, op)
+
+#else
+#error "A get cpuid for volk is not available on this compiler..."
+#endif
+
static inline unsigned int cpuid_eax(unsigned int op) {
unsigned int regs[4];
cpuid_x86 (op, regs);
--
cgit
From 3381729bb788e2d4f158d8efb6196a45e1620946 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Tue, 10 May 2011 12:31:09 -0700
Subject: volk: generate two machine structs which are conditional on
LV_HAVE_ORC
---
volk/gen/make_each_machine_c.py | 45 +++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 15 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_each_machine_c.py b/volk/gen/make_each_machine_c.py
index 6d9b8c65f..a7d3bb752 100644
--- a/volk/gen/make_each_machine_c.py
+++ b/volk/gen/make_each_machine_c.py
@@ -18,7 +18,7 @@
from volk_regexp import *
import string
-def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
+def _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglist):
#make the machine fcountlist and taglist a subset given the archs list
machine_fcountlists = list()
@@ -33,6 +33,25 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
machine_fcountlists.append(machine_fcountlist)
machine_taglists.append(machine_taglist)
+ #create the volk machine struct for this machine file
+ tempstring = ""
+ tempstring += "struct volk_machine volk_machine_" + machine_name + " = {\n"
+ tempstring += " " + ' | '.join(["(1 << LV_" + arch.swapcase() + ")" for arch in archs]) + ",\n"
+ tempstring += " \"%s\",\n"%machine_name
+
+ #fill in the description for each function
+ for i in range(len(functions)):
+ tempstring += " {%s},\n"%(', '.join(['"%s"'%tag for tag in machine_taglists[i]]))
+ tempstring += " {%s},\n"%(', '.join([' | '.join(['(1 << LV_%s)'%fc for fc in fcount]) for fcount in machine_fcountlists[i]]))
+ tempstring += " {%s},\n"%(', '.join(['%s_%s'%(functions[i], tag) for tag in machine_taglists[i]]))
+ tempstring += " %d,\n"%len(machine_taglists[i])
+
+ tempstring = strip_trailing(tempstring, ",")
+ tempstring += "};\n"
+ return tempstring
+
+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.
@@ -50,20 +69,16 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
tempstring += "#include \n"
tempstring += "\n\n"
- #create the volk machine struct for this machine file
- tempstring += "struct volk_machine volk_machine_" + machine_name + " = {\n"
- tempstring += " " + ' | '.join(["(1 << LV_" + arch.swapcase() + ")" for arch in archs]) + ",\n"
- tempstring += " \"%s\",\n"%machine_name
-
- #fill in the description for each function
- for i in range(len(functions)):
- tempstring += " {%s},\n"%(', '.join(['"%s"'%tag for tag in machine_taglists[i]]))
- tempstring += " {%s},\n"%(', '.join([' | '.join(['(1 << LV_%s)'%fc for fc in fcount]) for fcount in machine_fcountlists[i]]))
- tempstring += " {%s},\n"%(', '.join(['%s_%s'%(functions[i], tag) for tag in machine_taglists[i]]))
- tempstring += " %d,\n"%len(machine_taglists[i])
-
- tempstring = strip_trailing(tempstring, ",")
- tempstring += "};\n"
+ tempstring += """
+#ifdef LV_HAVE_ORC
+%s
+#else
+%s
+#endif
+"""%(
+ _make_each_machine_struct(machine_name, archs+["orc"], functions, fcountlist, taglist),
+ _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglist)
+)
return tempstring
--
cgit
From 21d6870a6ef5284a5941dce1484bcfff6684ffea Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 9 May 2011 20:31:56 -0700
Subject: volk: cmake support for volk (gcc + msvc)
---
volk/gen/machines.xml | 10 ++++++++++
1 file changed, 10 insertions(+)
(limited to 'volk/gen')
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index ad71da177..ce32aaadd 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -14,6 +14,16 @@
-->
+
+
+generic mmx sse sse2
+
+
generic 32|64 mmx sse sse2
--
cgit
From b50dbc4498842fecd7f0c6adc22f25726f8d27d3 Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Wed, 11 May 2011 21:45:03 -0700
Subject: Volk: Profiler is in apps/ now. Added name to function info. Going to
C++-ify the whole thing.
---
volk/gen/make_c.py | 2 +-
volk/gen/make_each_machine_c.py | 1 +
volk/gen/make_machines_h.py | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index 4e67f31ff..11b614644 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -82,7 +82,7 @@ static unsigned int get_index(const char *indices[], unsigned int n_archs, const
for i in range(len(functions)):
tempstring += "void get_" + functions[i] + replace_arch.sub("", arched_arglist[i]) + "\n"
- tempstring += " %s = get_machine()->%s_archs[volk_rank_archs(get_machine()->%s_arch_defs, get_machine()->%s_n_archs, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i])
+ tempstring += " %s = get_machine()->%s_archs[volk_rank_archs(get_machine()->%s_arch_defs, get_machine()->%s_n_archs, get_machine()->%s_name, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i], functions[i])
tempstring += " %s(%s);\n}\n\n" % (functions[i], my_arglist[i])
tempstring += replace_volk.sub("p", functions[i]) + " " + functions[i] + " = &get_" + functions[i] + ";\n\n"
tempstring += "void %s_manual%s\n" % (functions[i], arched_arglist[i])
diff --git a/volk/gen/make_each_machine_c.py b/volk/gen/make_each_machine_c.py
index a7d3bb752..dfb7011b4 100644
--- a/volk/gen/make_each_machine_c.py
+++ b/volk/gen/make_each_machine_c.py
@@ -41,6 +41,7 @@ def _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglis
#fill in the description for each function
for i in range(len(functions)):
+ tempstring += " \"%s\",\n"%functions[i]
tempstring += " {%s},\n"%(', '.join(['"%s"'%tag for tag in machine_taglists[i]]))
tempstring += " {%s},\n"%(', '.join([' | '.join(['(1 << LV_%s)'%fc for fc in fcount]) for fcount in machine_fcountlists[i]]))
tempstring += " {%s},\n"%(', '.join(['%s_%s'%(functions[i], tag) for tag in machine_taglists[i]]))
diff --git a/volk/gen/make_machines_h.py b/volk/gen/make_machines_h.py
index 09ada3e0d..563de18a6 100644
--- a/volk/gen/make_machines_h.py
+++ b/volk/gen/make_machines_h.py
@@ -35,6 +35,7 @@ struct volk_machine {
const char *name;
"""
for function in functions:
+ tempstring += " const char *%s_name;\n"%function
tempstring += " const char *%s_indices[%d];\n"%(function, len(archs))
tempstring += " const int %s_arch_defs[%d];\n"%(function, len(archs))
tempstring += " const %s %s_archs[%d];\n"%(replace_volk.sub("p", function), function, len(archs))
--
cgit
From 30fdc38d20d4e38908059b6e351c550de5741621 Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Thu, 12 May 2011 14:21:17 -0700
Subject: Volk: profiling works. loads prefs on init. volk_rank_archs looks in
prefs first.
---
volk/gen/make_c.py | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index 11b614644..fa08bbb0e 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -66,23 +66,11 @@ struct volk_machine *get_machine(void) {
}
}
-static unsigned int get_index(const char *indices[], unsigned int n_archs, const char *arch_name) {
- int i;
- for(i=0; i%s_archs[volk_rank_archs(get_machine()->%s_arch_defs, get_machine()->%s_n_archs, get_machine()->%s_name, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i], functions[i])
+ tempstring += " %s = get_machine()->%s_archs[volk_rank_archs(get_machine()->%s_indices, get_machine()->%s_arch_defs, get_machine()->%s_n_archs, get_machine()->%s_name, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i], functions[i], functions[i])
tempstring += " %s(%s);\n}\n\n" % (functions[i], my_arglist[i])
tempstring += replace_volk.sub("p", functions[i]) + " " + functions[i] + " = &get_" + functions[i] + ";\n\n"
tempstring += "void %s_manual%s\n" % (functions[i], arched_arglist[i])
--
cgit
From a346b0d610e2952e9ffc45363425e4f2becea109 Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Thu, 12 May 2011 16:04:32 -0700
Subject: Volk: Forgot to put sse4.1 support in sse4_2 and avx machines
---
volk/gen/machines.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index ce32aaadd..1f8b201ae 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -45,11 +45,11 @@ however it does not support the gcc style inline assembly.
-generic 32|64 mmx sse sse2 sse3 ssse3 sse4_2 popcount
+generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount
-generic 32|64 mmx sse sse2 sse3 ssse3 sse4_2 popcount avx
+generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx
--
cgit
From 9bfe75fd7c6a7069db2d2a98195faabf6ba248e2 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Fri, 13 May 2011 13:58:01 -0700
Subject: volk: do not install library-only headers
---
volk/gen/make_c.py | 2 +-
volk/gen/make_each_machine_c.py | 2 +-
volk/gen/make_machines_c.py | 2 +-
volk/gen/make_makefile_am.py | 3 +++
volk/gen/volk_register.py | 4 ++--
5 files changed, 8 insertions(+), 5 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index fa08bbb0e..e946152d0 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -28,7 +28,7 @@ def make_c(machines, archs, functions, arched_arglist, my_arglist):
"""
tempstring += """
#include
-#include
+#include "volk_machines.h"
#include
#include
#include "volk_rank_archs.h"
diff --git a/volk/gen/make_each_machine_c.py b/volk/gen/make_each_machine_c.py
index dfb7011b4..d4f5f01de 100644
--- a/volk/gen/make_each_machine_c.py
+++ b/volk/gen/make_each_machine_c.py
@@ -62,7 +62,7 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
tempstring += """
#include
-#include
+#include "volk_machines.h"
#include
"""
diff --git a/volk/gen/make_machines_c.py b/volk/gen/make_machines_c.py
index ccac21131..a7ab63d6e 100644
--- a/volk/gen/make_machines_c.py
+++ b/volk/gen/make_machines_c.py
@@ -24,7 +24,7 @@ def make_machines_c(machines):
#include
#include
-#include
+#include "volk_machines.h"
struct volk_machine *volk_machines[] = {
"""
diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py
index ff9749e17..d700626bb 100644
--- a/volk/gen/make_makefile_am.py
+++ b/volk/gen/make_makefile_am.py
@@ -47,6 +47,7 @@ libvolk_la_SOURCES = \
$(top_gendir)/lib/volk.c \
$(top_gendir)/lib/volk_cpu.c \
volk_rank_archs.c \
+ volk_prefs.c \
$(top_gendir)/lib/volk_machines.c
if LV_HAVE_ORC
@@ -101,6 +102,8 @@ noinst_LTLIBRARIES =
# ----------------------------------------------------------------
noinst_HEADERS = \
$(top_gendir)/lib/volk_init.h \
+ $(top_gendir)/lib/volk_machines.h \
+ $(top_gendir)/lib/volk_environment_init.h \
qa_utils.h
# ----------------------------------------------------------------
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index dba364e01..62ebba3c2 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -44,9 +44,9 @@ 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_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_environment_h = open(os.path.join(gendir, "lib/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_h = open(os.path.join(gendir, "lib/volk_machines.h"), "w")
outfile_machines_c = open(os.path.join(gendir, "lib/volk_machines.c"), "w")
infile = open(os.path.join(srcdir, "include/volk/Makefile.am"), "r")
--
cgit
From c80e7b00de836a388013a002008c7256481414cb Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Wed, 18 May 2011 13:39:57 -0700
Subject: Volk: renamed everything else to _a instead of _a16, makefiles
included
---
volk/gen/volk_register.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index 62ebba3c2..e87156fc8 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -59,7 +59,7 @@ functions = [];
for line in mfile:
- subline = re.search(".*_(a16|u)\.h.*", line);
+ subline = re.search(".*_(a|u)\.h.*", line);
if subline:
subsubline = re.search("(?<=volk_).*", subline.group(0));
if subsubline:
@@ -74,7 +74,7 @@ datatypes = set(datatypes);
for line in mfile:
for dt in datatypes:
if dt in line:
- subline = re.search("(volk_" + dt +"_.*(a16|u).*\.h)", line);
+ subline = re.search("(volk_" + dt +"_.*(a|u).*\.h)", line);
if subline:
subsubline = re.search(".+(?=\.h)", subline.group(0));
--
cgit
From 3a41b3208e222965e908c6a04e3ab05379c782c4 Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Wed, 18 May 2011 18:03:26 -0700
Subject: Volk: added alignment prop to each machine. call volk_get_alignment()
to get your machine's reqd alignment for malloc.
---
volk/gen/archs.xml | 12 ++++++++++++
volk/gen/make_c.py | 4 ++++
volk/gen/make_each_machine_c.py | 10 +++++-----
volk/gen/make_h.py | 3 +++
volk/gen/make_machines_h.py | 1 +
volk/gen/volk_register.py | 19 ++++++++++++++-----
6 files changed, 39 insertions(+), 10 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 977cc7924..0e8c22eea 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -7,6 +7,7 @@
maltivec
+ 16
@@ -31,6 +32,7 @@
31
m3dnow
1
+ 8
@@ -39,6 +41,7 @@
d
5
sse4.2
+ 16
@@ -55,6 +58,7 @@
d
23
mmmx
+ 8
@@ -66,6 +70,7 @@
msse
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
xmmintrin.h
+ 16
@@ -75,6 +80,7 @@
d
26
msse2
+ 16
@@ -91,6 +97,7 @@
msse3
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
pmmintrin.h
+ 16
@@ -99,6 +106,7 @@
c
9
mssse3
+ 16
@@ -107,6 +115,7 @@
c
6
msse4a
+ 16
@@ -116,6 +125,7 @@
c
19
msse4.1
+ 16
@@ -124,6 +134,7 @@
c
20
msse4.2
+ 16
@@ -132,6 +143,7 @@
c
28
mavx
+ 32
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index e946152d0..19d679e71 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -66,6 +66,10 @@ struct volk_machine *get_machine(void) {
}
}
+unsigned int volk_get_alignment(void) {
+ return get_machine()->alignment;
+}
+
"""
for i in range(len(functions)):
diff --git a/volk/gen/make_each_machine_c.py b/volk/gen/make_each_machine_c.py
index d4f5f01de..44e2ef3f2 100644
--- a/volk/gen/make_each_machine_c.py
+++ b/volk/gen/make_each_machine_c.py
@@ -18,7 +18,7 @@
from volk_regexp import *
import string
-def _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglist):
+def _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglist, alignment):
#make the machine fcountlist and taglist a subset given the archs list
machine_fcountlists = list()
@@ -38,6 +38,7 @@ def _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglis
tempstring += "struct volk_machine volk_machine_" + machine_name + " = {\n"
tempstring += " " + ' | '.join(["(1 << LV_" + arch.swapcase() + ")" for arch in archs]) + ",\n"
tempstring += " \"%s\",\n"%machine_name
+ tempstring += " %s,\n"%alignment
#fill in the description for each function
for i in range(len(functions)):
@@ -51,8 +52,7 @@ def _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglis
tempstring += "};\n"
return tempstring
-def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
-
+def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist, alignment):
tempstring = r"""
// This file is automatically generated by make_each_machine_c.py.
// Do not edit this file.
@@ -77,8 +77,8 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
%s
#endif
"""%(
- _make_each_machine_struct(machine_name, archs+["orc"], functions, fcountlist, taglist),
- _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglist)
+ _make_each_machine_struct(machine_name, archs+["orc"], functions, fcountlist, taglist, alignment),
+ _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglist, alignment)
)
return tempstring
diff --git a/volk/gen/make_h.py b/volk/gen/make_h.py
index 3d5790de4..76f5f8c69 100644
--- a/volk/gen/make_h.py
+++ b/volk/gen/make_h.py
@@ -21,6 +21,9 @@ struct volk_func_desc {
const int *arch_defs;
const int n_archs;
};
+
+VOLK_API unsigned int volk_get_alignment(void);
+
"""
for i in range(len(funclist)):
tempstring += "extern " + replace_volk.sub("p", funclist[i]) + " " + funclist[i] + ";\n"
diff --git a/volk/gen/make_machines_h.py b/volk/gen/make_machines_h.py
index 563de18a6..a48caa89c 100644
--- a/volk/gen/make_machines_h.py
+++ b/volk/gen/make_machines_h.py
@@ -33,6 +33,7 @@ __VOLK_DECL_BEGIN
struct volk_machine {
const unsigned int caps; //capabilities (i.e., archs compiled into this machine, in the volk_get_lvarch format)
const char *name;
+ const unsigned int alignment; //the maximum byte alignment required for functions in this library
"""
for function in functions:
tempstring += " const char *%s_name;\n"%function
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index e87156fc8..76f41205b 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -97,6 +97,12 @@ archflags_dict = {}
for filearch in filearchs:
archflags_dict[str(filearch.attributes["name"].value)] = str(filearch.getElementsByTagName("flag")[0].firstChild.data)
+archalign_dict = {}
+for filearch in filearchs:
+ alignelem = filearch.getElementsByTagName("alignment")
+ if(alignelem):
+ archalign_dict[str(filearch.attributes["name"].value)] = int(alignelem[0].firstChild.data)
+
archs_or = "("
for arch in archs:
archs_or = archs_or + string.upper(arch) + "|";
@@ -132,11 +138,14 @@ for machine_name in machine_str_dict:
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
+#get the maximum alignment for all archs in a machine
+machine_alignment_dict = {}
+for machine in machines:
+ machine_alignment_dict[machine] = max((archalign_dict.get(k, 1)) for k in machines[machine])
+
+for machine in machine_alignment_dict:
+ print machine + ": %d" % machine_alignment_dict[machine]
taglist = [];
fcountlist = [];
@@ -295,5 +304,5 @@ outfile_h.close()
for machine in machines:
machine_c_filename = os.path.join(gendir, "lib/volk_machine_" + machine + ".c")
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.write(make_each_machine_c(machine, machines[machine], functions, fcountlist, taglist, machine_alignment_dict[machine]))
outfile_machine_c.close()
--
cgit
From 95377fea8f83bfaf956704e961c15d687848cb5c Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Thu, 19 May 2011 15:05:18 -0700
Subject: Volk: first stab at NEON support. Using compile-time detection.
---
volk/gen/archs.xml | 5 +++++
volk/gen/machines.xml | 5 +++++
volk/gen/make_cpuid_c.py | 13 +++++++++++++
volk/gen/volk_register.py | 4 ++--
4 files changed, 25 insertions(+), 2 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 0e8c22eea..a976190da 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -10,6 +10,11 @@
16
+
+ mneon
+ 16
+
+
m32
MD_SUBCPU
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index 1f8b201ae..b872b9fb1 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -20,6 +20,11 @@ This machine is intended to support the MSVC compiler on x86/amd64.
The MSVC compiler has intrinsic support for SSE and SSE2,
however it does not support the gcc style inline assembly.
-->
+
+
+generic neon
+
+
generic mmx sse sse2
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 2fdbaf304..3b2f12d5c 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -152,6 +152,19 @@ int i_can_has_%s () {
#endif
}
+""" % (arch)
+
+ elif str(domarch.attributes["type"].value) == "arm":
+ arch = str(domarch.attributes["name"].value);
+ tempstring = tempstring + """\
+int i_can_has_%s () {
+#ifdef __NEON__
+ return 1;
+#else
+ return 0;
+#endif
+}
+
""" % (arch)
elif str(domarch.attributes["type"].value) == "all":
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index 76f41205b..75e5eeb87 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -144,8 +144,8 @@ machine_alignment_dict = {}
for machine in machines:
machine_alignment_dict[machine] = max((archalign_dict.get(k, 1)) for k in machines[machine])
-for machine in machine_alignment_dict:
- print machine + ": %d" % machine_alignment_dict[machine]
+#for machine in machine_alignment_dict:
+# print machine + ": %d" % machine_alignment_dict[machine]
taglist = [];
fcountlist = [];
--
cgit
From d9e32f2b36808dd98648a01b2d6fa0915df96573 Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Fri, 20 May 2011 15:48:05 -0700
Subject: Volk: modify NEON test flag
---
volk/gen/archs.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index a976190da..fa6a17700 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -11,7 +11,7 @@
- mneon
+ mfpu=neon
16
--
cgit
From 2e67e743c616ed557f7adda7de138adc06152584 Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Fri, 20 May 2011 16:01:20 -0700
Subject: Volk: Use "unsafe" math optimizations (read: NEON) in GCC on NEON
arch
---
volk/gen/archs.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index fa6a17700..661b3f890 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -11,7 +11,7 @@
- mfpu=neon
+ mfpu=neon -funsafe-math-optimizations
16
--
cgit
From 86ecca0758e0ad014e14d8e38f2e3ff989c6b04a Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Fri, 20 May 2011 21:47:55 +0100
Subject: Volk: runtime NEON detection based on /proc/self/auxv
---
volk/gen/archs.xml | 2 +-
volk/gen/make_cpuid_c.py | 30 ++++++++++++++++++++++++++++--
2 files changed, 29 insertions(+), 3 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 661b3f890..f6822871f 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -11,7 +11,7 @@
- mfpu=neon -funsafe-math-optimizations
+ mfpu=neon -mfloat-abi=softfp -funsafe-math-optimizations
16
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 3b2f12d5c..eb88dcd7f 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -157,9 +157,35 @@ int i_can_has_%s () {
elif str(domarch.attributes["type"].value) == "arm":
arch = str(domarch.attributes["name"].value);
tempstring = tempstring + """\
+#if defined(__arm__) && defined(__linux__)
+#include
+#include
+#include
+#define LOOK_FOR_NEON
+#endif
+
int i_can_has_%s () {
-#ifdef __NEON__
- return 1;
+//it's linux-specific, but if you're compiling libvolk for NEON
+//on Windows you have other problems
+
+#ifdef LOOK_FOR_NEON
+ FILE *auxvec_f;
+ unsigned long auxvec[2];
+ unsigned int found_neon = 0;
+ auxvec_f = fopen("/proc/self/auxv", "rb");
+ if(!auxvec_f) return 0;
+
+ //so auxv is basically 32b of ID and 32b of value
+ //so it goes like this
+ while(!found_neon && auxvec_f) {
+ fread(auxvec, sizeof(unsigned long), 2, auxvec_f);
+ if((auxvec[0] == AT_HWCAP) && (auxvec[1] & HWCAP_NEON))
+ found_neon = 1;
+ }
+
+ fclose(auxvec_f);
+ return found_neon;
+
#else
return 0;
#endif
--
cgit
From 85a8b62ff4b4382e216ea88661fc32c6f30b724f Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Mon, 30 May 2011 23:25:15 -0700
Subject: volk: make fptrs in volk.h visible
---
volk/gen/make_h.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_h.py b/volk/gen/make_h.py
index 76f5f8c69..354e57258 100644
--- a/volk/gen/make_h.py
+++ b/volk/gen/make_h.py
@@ -26,7 +26,7 @@ VOLK_API unsigned int volk_get_alignment(void);
"""
for i in range(len(funclist)):
- tempstring += "extern " + replace_volk.sub("p", funclist[i]) + " " + funclist[i] + ";\n"
+ tempstring += "extern VOLK_API " + 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])
--
cgit
From 7e2b45b89137a3cc2b1cdb066577c323545cfcb7 Mon Sep 17 00:00:00 2001
From: Moritz Fischer
Date: Tue, 19 Jul 2011 07:21:36 -0700
Subject: volk: fix whitespace in Python script
---
volk/gen/make_makefile_am.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py
index d700626bb..f843b4413 100644
--- a/volk/gen/make_makefile_am.py
+++ b/volk/gen/make_makefile_am.py
@@ -77,9 +77,9 @@ noinst_LTLIBRARIES =
if archflags_dict[arch] != "none":
tempstring += "-" + archflags_dict[arch] + " "
- tempstring += "\nnoinst_LTLIBRARIES += libvolk_" + machine_name + ".la "
+ 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 += "libvolk_la_CPPFLAGS += -DLV_MACHINE_" + machine_name.swapcase() + " \n"
tempstring += "endif\n"
--
cgit
From eb43a23b777d2438d22b67ae6dfd9b4d69406593 Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Wed, 20 Jul 2011 16:29:43 -0700
Subject: Volk: add in mutex capability to archs.xml. Turns out some compilers
can do both 32-bit and 64-bit compilations, and this breaks Volk. Only works
in CMake right now.
---
volk/gen/archs.xml | 1 +
volk/gen/volk_register.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index f6822871f..960558b7c 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -29,6 +29,7 @@
1
MD_SUBCPU
x86
+ 32
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index 75e5eeb87..f5854bbce 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -91,7 +91,7 @@ for arch in archs:
if a_var:
archs.remove(arch);
-
+#strip out mutex archs
archflags_dict = {}
for filearch in filearchs:
--
cgit
From 6b4fb9612f5ea460c79e80facba01c504a3d5049 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sat, 17 Sep 2011 15:00:33 -0400
Subject: volk: use glob rather than parsing makefile for kernels
---
volk/gen/volk_register.py | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index f5854bbce..cd874e470 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -3,6 +3,7 @@
import sys
import os
import re
+import glob
import string
from xml.dom import minidom
from volk_regexp import *
@@ -48,18 +49,13 @@ outfile_environment_h = open(os.path.join(gendir, "lib/volk_environment_init.h")
outfile_makefile_am = open(os.path.join(gendir, "lib/Makefile.am"), "w")
outfile_machines_h = open(os.path.join(gendir, "lib/volk_machines.h"), "w")
outfile_machines_c = open(os.path.join(gendir, "lib/volk_machines.c"), "w")
-infile = open(os.path.join(srcdir, "include/volk/Makefile.am"), "r")
-
-
-mfile = infile.readlines();
+hdr_files = glob.glob(os.path.join(srcdir, "include/volk/*.h"))
datatypes = [];
functions = [];
-
-
-for line in mfile:
- subline = re.search(".*_(a|u)\.h.*", line);
+for line in hdr_files:
+ subline = re.search(".*_(a|u)\.h.*", os.path.basename(line))
if subline:
subsubline = re.search("(?<=volk_).*", subline.group(0));
if subsubline:
@@ -71,7 +67,7 @@ for line in mfile:
datatypes = set(datatypes);
-for line in mfile:
+for line in hdr_files:
for dt in datatypes:
if dt in line:
subline = re.search("(volk_" + dt +"_.*(a|u).*\.h)", line);
--
cgit
From ccfac187cf86122be5760cb1e2a0bba3a58821c7 Mon Sep 17 00:00:00 2001
From: Tom Rondeau
Date: Thu, 20 Oct 2011 10:46:35 -0700
Subject: volk: fixed signed/unsigned comparison warnings.
---
volk/gen/make_c.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index 19d679e71..0f9bcde34 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -52,7 +52,7 @@ struct volk_machine *get_machine(void) {
if(machine != NULL) return machine;
else {
unsigned int max_score = 0;
- int i;
+ unsigned int i;
for(i=0; icaps & (~volk_get_lvarch()))) {
if(volk_machines[i]->caps > max_score) {
--
cgit
From dfe18fee44d1c03af186aeacd2adc97b6b129297 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Thu, 20 Oct 2011 14:15:25 -0700
Subject: volk: give priority to generated includes (helps with dirty tree)
---
volk/gen/make_makefile_am.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py
index f843b4413..0dc088a80 100644
--- a/volk/gen/make_makefile_am.py
+++ b/volk/gen/make_makefile_am.py
@@ -25,8 +25,8 @@ def make_makefile_am(dom, machines, archflags_dict):
include $(top_srcdir)/Makefile.common
AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) \
- -I$(top_srcdir)/include \
-I$(top_gendir)/include \
+ -I$(top_srcdir)/include \
-Dvolk_EXPORTS \
-fvisibility=hidden \
$(WITH_INCLUDES)
--
cgit
From a2894f6ad7d9cc79a343cc0b06e9fc23994c5c09 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sat, 5 Nov 2011 14:33:39 -0700
Subject: volk: work to improve compiler and multi-lib support
---
volk/gen/archs.xml | 9 ++++-----
volk/gen/compilers.xml | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 5 deletions(-)
create mode 100644 volk/gen/compilers.xml
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 960558b7c..effd90d33 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -1,8 +1,8 @@
-
- none
+
+ none
@@ -11,7 +11,7 @@
- mfpu=neon -mfloat-abi=softfp -funsafe-math-optimizations
+ mfpu=neon,mfloat-abi=softfp,funsafe-math-optimizations
16
@@ -29,7 +29,6 @@
1
MD_SUBCPU
x86
- 32
@@ -46,7 +45,7 @@
0x80000001
d
5
- sse4.2
+ msse4.2
16
diff --git a/volk/gen/compilers.xml b/volk/gen/compilers.xml
new file mode 100644
index 000000000..70c82e555
--- /dev/null
+++ b/volk/gen/compilers.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ arch:SSE
+ arch:SSE
+ arch:SSE2
+ /
+
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
--
cgit
From 1fe474ce91b5a4e6281e9ae1b78c87f1e2b72ccd Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sat, 5 Nov 2011 16:20:27 -0700
Subject: volk: building on msvc again with sse2 arch
---
volk/gen/make_cpuid_c.py | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index eb88dcd7f..7281f45a3 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -30,7 +30,11 @@ HEADER_TEMPL = """\
struct VOLK_CPU volk_cpu;
-#if defined(__i386__) || (__x86_64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
+# define VOLK_CPU_x86
+#endif
+
+#if defined(VOLK_CPU_x86)
//implement get cpuid for gcc compilers using a copy of cpuid.h
#if defined(__GNUC__)
@@ -40,32 +44,32 @@ struct VOLK_CPU volk_cpu;
//implement get cpuid for MSVC compilers using __cpuid intrinsic
#elif defined(_MSC_VER)
#include
-#define cpuid(op, r) __cpuid(r, op)
+#define cpuid_x86(op, r) __cpuid(r, op)
#else
#error "A get cpuid for volk is not available on this compiler..."
#endif
static inline unsigned int cpuid_eax(unsigned int op) {
- unsigned int regs[4];
+ int regs[4];
cpuid_x86 (op, regs);
return regs[0];
}
static inline unsigned int cpuid_ebx(unsigned int op) {
- unsigned int regs[4];
+ int regs[4];
cpuid_x86 (op, regs);
return regs[1];
}
static inline unsigned int cpuid_ecx(unsigned int op) {
- unsigned int regs[4];
+ int regs[4];
cpuid_x86 (op, regs);
return regs[2];
}
static inline unsigned int cpuid_edx(unsigned int op) {
- unsigned int regs[4];
+ int regs[4];
cpuid_x86 (op, regs);
return regs[3];
}
@@ -103,7 +107,7 @@ def make_cpuid_c(dom) :
if no_test:
tempstring = tempstring + """\
int i_can_has_%s () {
-#if defined(__i386__) || (__x86_64__)
+#if defined(VOLK_CPU_x86)
return 1;
#else
return 0;
@@ -115,7 +119,7 @@ int i_can_has_%s () {
elif op == "1":
tempstring = tempstring + """\
int i_can_has_%s () {
-#if defined(__i386__) || (__x86_64__)
+#if defined(VOLK_CPU_x86)
unsigned int e%sx = cpuid_e%sx (%s);
return ((e%sx >> %s) & 1) == %s;
#else
@@ -128,7 +132,7 @@ int i_can_has_%s () {
elif op == "0x80000001":
tempstring = tempstring + """\
int i_can_has_%s () {
-#if defined(__i386__) || (__x86_64__)
+#if defined(VOLK_CPU_x86)
unsigned int extended_fct_count = cpuid_eax(0x80000000);
if (extended_fct_count < 0x80000001)
return %s^1;
--
cgit
From 6bf88fd950a9606d41d611ace8368f319a4b06e0 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 14 Nov 2011 09:48:20 -0800
Subject: volk: avx support for MSVC
---
volk/gen/compilers.xml | 14 +++++++++++++-
volk/gen/machines.xml | 8 ++++++--
volk/gen/make_cpuid_c.py | 2 +-
3 files changed, 20 insertions(+), 4 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/compilers.xml b/volk/gen/compilers.xml
index 70c82e555..005eda2aa 100644
--- a/volk/gen/compilers.xml
+++ b/volk/gen/compilers.xml
@@ -2,9 +2,21 @@
+
arch:SSE
arch:SSE
+
+
arch:SSE2
+
+
+ arch:AVX
+ arch:AVX
+ arch:AVX
+ arch:AVX
+ arch:AVX
+ arch:AVX
+
/
@@ -15,4 +27,4 @@
-
\ No newline at end of file
+
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index b872b9fb1..9c19c91c6 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -15,9 +15,9 @@
-->
@@ -57,6 +57,10 @@ however it does not support the gcc style inline assembly.
generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx
+
+generic mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx
+
+
generic altivec
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 7281f45a3..2be1123a8 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -39,7 +39,7 @@ struct VOLK_CPU volk_cpu;
//implement get cpuid for gcc compilers using a copy of cpuid.h
#if defined(__GNUC__)
#include
-#define cpuid_x86(op, r) __get_cpuid(op, r+0, r+1, r+2, r+3)
+#define cpuid_x86(op, r) __get_cpuid(op, (unsigned int *)r+0, (unsigned int *)r+1, (unsigned int *)r+2, (unsigned int *)r+3)
//implement get cpuid for MSVC compilers using __cpuid intrinsic
#elif defined(_MSC_VER)
--
cgit
From edbfdf08d8e4bfa3ea725dc69089123537403ed6 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 21 Nov 2011 21:38:06 -0800
Subject: volk: fix #466 deprecated string use, from Pinkava
---
volk/gen/volk_regexp.py | 3 +--
volk/gen/volk_register.py | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/volk_regexp.py b/volk/gen/volk_regexp.py
index b83ce5206..eb4ceb54b 100644
--- a/volk/gen/volk_regexp.py
+++ b/volk/gen/volk_regexp.py
@@ -1,5 +1,4 @@
import re
-import string
remove_after_underscore = re.compile("_.*");
space_remove = re.compile(" ");
@@ -10,5 +9,5 @@ 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, "");
+ tostrip = tostrip[0:lindex] + tostrip[lindex:len(tostrip)].replace(stripstr, "");
return tostrip
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index cd874e470..0774ece29 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -4,7 +4,6 @@ import sys
import os
import re
import glob
-import string
from xml.dom import minidom
from volk_regexp import *
from make_cpuid_c import make_cpuid_c
@@ -101,7 +100,7 @@ for filearch in filearchs:
archs_or = "("
for arch in archs:
- archs_or = archs_or + string.upper(arch) + "|";
+ archs_or = archs_or + arch.upper() + "|";
archs_or = archs_or[0:len(archs_or)-1];
archs_or = archs_or + ")";
--
cgit
From 00420d32081d8252bb37142b2be19a8a7c4dc4c4 Mon Sep 17 00:00:00 2001
From: Johnathan Corgan
Date: Thu, 8 Dec 2011 13:48:48 -0800
Subject: Removed autotools, gr-waveform, some cleanup
Nick Foster owes Nick Corgan a six-pack of beer!
---
volk/gen/.gitignore | 3 ---
1 file changed, 3 deletions(-)
delete mode 100644 volk/gen/.gitignore
(limited to 'volk/gen')
diff --git a/volk/gen/.gitignore b/volk/gen/.gitignore
deleted file mode 100644
index a1c468f93..000000000
--- a/volk/gen/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/config
-/include
-/lib
--
cgit
From d88328072d5ecd0c3c5aef05b705e2b4a1425d9f Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Wed, 21 Mar 2012 16:59:12 -0700
Subject: volk: add include for config.h to cc file
volk_32f_s32f_convert_16i_a was also a problem,
previously volk_32f_s32f_convert_16i_u was fixed to have config.h.
I heard putting config h stuff into public headers was bad practice.
Including config.h into the generated cc file should fix this issue from now on.
---
volk/gen/make_each_machine_c.py | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'volk/gen')
diff --git a/volk/gen/make_each_machine_c.py b/volk/gen/make_each_machine_c.py
index 44e2ef3f2..a3f6203ba 100644
--- a/volk/gen/make_each_machine_c.py
+++ b/volk/gen/make_each_machine_c.py
@@ -65,6 +65,10 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist, ali
#include "volk_machines.h"
#include
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
"""
for func in functions:
tempstring += "#include \n"
--
cgit
From f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2 Mon Sep 17 00:00:00 2001
From: Tom Rondeau
Date: Fri, 13 Apr 2012 18:36:53 -0400
Subject: Removed whitespace and added dtools/bin/remove-whitespace as a tool
to do this in the future.
The sed script was provided by Moritz Fischer.
---
volk/gen/archs.xml | 2 +-
volk/gen/make_c.py | 4 ++--
volk/gen/make_config_fixed.py | 2 +-
volk/gen/make_cpuid_c.py | 38 ++++++++++++++++-----------------
volk/gen/make_cpuid_h.py | 12 +++++------
volk/gen/make_each_machine_c.py | 2 +-
volk/gen/make_environment_init_c.py | 10 ++++-----
volk/gen/make_environment_init_h.py | 4 ++--
volk/gen/make_h.py | 2 +-
volk/gen/make_machines_c.py | 2 +-
volk/gen/make_machines_h.py | 6 +++---
volk/gen/make_makefile_am.py | 12 +++++------
volk/gen/make_proccpu_sim.py | 12 +++++------
volk/gen/make_set_simd.py | 26 +++++++++++------------
volk/gen/make_typedefs.py | 2 +-
volk/gen/volk_register.py | 42 ++++++++++++++++++-------------------
16 files changed, 89 insertions(+), 89 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index effd90d33..ca2118475 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -19,7 +19,7 @@
m32
MD_SUBCPU
x86_64
-
+
0x80000001
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
index 0f9bcde34..233cb85c2 100644
--- a/volk/gen/make_c.py
+++ b/volk/gen/make_c.py
@@ -48,7 +48,7 @@ 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;
@@ -71,7 +71,7 @@ unsigned int volk_get_alignment(void) {
}
"""
-
+
for i in range(len(functions)):
tempstring += "void get_" + functions[i] + replace_arch.sub("", arched_arglist[i]) + "\n"
tempstring += " %s = get_machine()->%s_archs[volk_rank_archs(get_machine()->%s_indices, get_machine()->%s_arch_defs, get_machine()->%s_n_archs, get_machine()->%s_name, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i], functions[i], functions[i])
diff --git a/volk/gen/make_config_fixed.py b/volk/gen/make_config_fixed.py
index 3fd1bdf0a..96f20b6b2 100644
--- a/volk/gen/make_config_fixed.py
+++ b/volk/gen/make_config_fixed.py
@@ -18,4 +18,4 @@ def make_config_fixed(dom) :
return tempstring;
-
+
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 2be1123a8..e30d643cb 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -1,24 +1,24 @@
#!/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
@@ -79,7 +79,7 @@ static inline unsigned int cpuid_edx(unsigned int op) {
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():
@@ -103,7 +103,7 @@ def make_cpuid_c(dom) :
val = domarch.getElementsByTagName("val");
if val:
val = str(val[0].firstChild.data);
-
+
if no_test:
tempstring = tempstring + """\
int i_can_has_%s () {
@@ -113,9 +113,9 @@ int i_can_has_%s () {
return 0;
#endif
}
-
+
""" % (arch)
-
+
elif op == "1":
tempstring = tempstring + """\
int i_can_has_%s () {
@@ -144,7 +144,7 @@ int i_can_has_%s () {
}
""" % (arch, val, reg, op, shift, val)
-
+
elif str(domarch.attributes["type"].value) == "powerpc":
arch = str(domarch.attributes["name"].value);
tempstring = tempstring + """\
@@ -178,7 +178,7 @@ int i_can_has_%s () {
unsigned int found_neon = 0;
auxvec_f = fopen("/proc/self/auxv", "rb");
if(!auxvec_f) return 0;
-
+
//so auxv is basically 32b of ID and 32b of value
//so it goes like this
while(!found_neon && auxvec_f) {
@@ -186,7 +186,7 @@ int i_can_has_%s () {
if((auxvec[0] == AT_HWCAP) && (auxvec[1] & HWCAP_NEON))
found_neon = 1;
}
-
+
fclose(auxvec_f);
return found_neon;
@@ -196,7 +196,7 @@ int i_can_has_%s () {
}
""" % (arch)
-
+
elif str(domarch.attributes["type"].value) == "all":
arch = str(domarch.attributes["name"].value);
tempstring = tempstring + """\
@@ -213,7 +213,7 @@ int i_can_has_%s () {
}
""" % (arch)
-
+
tempstring = tempstring + "void volk_cpu_init() {\n";
for domarch in dom:
arch = str(domarch.attributes["name"].value);
@@ -231,9 +231,9 @@ int i_can_has_%s () {
return tempstring;
-
-
-
-
-
+
+
+
+
+
diff --git a/volk/gen/make_cpuid_h.py b/volk/gen/make_cpuid_h.py
index 4fe5c4e07..1aa783781 100644
--- a/volk/gen/make_cpuid_h.py
+++ b/volk/gen/make_cpuid_h.py
@@ -1,24 +1,24 @@
#!/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
@@ -44,5 +44,5 @@ def make_cpuid_h(dom) :
tempstring = tempstring + "\n";
tempstring = tempstring + "__VOLK_DECL_END\n";
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
index a3f6203ba..535578859 100644
--- a/volk/gen/make_each_machine_c.py
+++ b/volk/gen/make_each_machine_c.py
@@ -59,7 +59,7 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist, ali
"""
for arch in archs:
tempstring += "#define LV_HAVE_" + arch.swapcase() + " 1\n"
-
+
tempstring += """
#include
#include "volk_machines.h"
diff --git a/volk/gen/make_environment_init_c.py b/volk/gen/make_environment_init_c.py
index 263d5bcd1..6186162ee 100644
--- a/volk/gen/make_environment_init_c.py
+++ b/volk/gen/make_environment_init_c.py
@@ -14,7 +14,7 @@ def make_environment_init_c(dom) :
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");
@@ -22,11 +22,11 @@ def make_environment_init_c(dom) :
cmd = str(env.firstChild.data);
tempstring = tempstring + "#ifdef LV_HAVE_" + arch.swapcase() + "\n";
tempstring = tempstring + " " + cmd + "\n";
- tempstring = tempstring + "#endif\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
index 655d73f54..0b0f35d61 100644
--- a/volk/gen/make_environment_init_h.py
+++ b/volk/gen/make_environment_init_h.py
@@ -12,7 +12,7 @@ def make_environment_init_h() :
tempstring = tempstring + "__VOLK_DECL_END\n";
tempstring = tempstring + "#endif\n"
return tempstring;
-
-
+
+
diff --git a/volk/gen/make_h.py b/volk/gen/make_h.py
index 354e57258..cf8987c39 100644
--- a/volk/gen/make_h.py
+++ b/volk/gen/make_h.py
@@ -35,4 +35,4 @@ VOLK_API unsigned int volk_get_alignment(void);
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
index a7ab63d6e..f19da4ae4 100644
--- a/volk/gen/make_machines_c.py
+++ b/volk/gen/make_machines_c.py
@@ -33,7 +33,7 @@ struct volk_machine *volk_machines[] = {
tempstring += "&volk_machine_" + machine
tempstring += ","
tempstring += "\n#endif\n"
-
+
tempstring += r"""
};
unsigned int n_volk_machines = sizeof(volk_machines)/sizeof(*volk_machines);
diff --git a/volk/gen/make_machines_h.py b/volk/gen/make_machines_h.py
index a48caa89c..d2374120b 100644
--- a/volk/gen/make_machines_h.py
+++ b/volk/gen/make_machines_h.py
@@ -41,15 +41,15 @@ struct volk_machine {
tempstring += " const int %s_arch_defs[%d];\n"%(function, len(archs))
tempstring += " const %s %s_archs[%d];\n"%(replace_volk.sub("p", function), function, len(archs))
tempstring += " const int %s_n_archs;\n"%function
-
+
tempstring += r"""};
-
+
"""
for machine in machines:
tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n"
tempstring += "extern struct volk_machine volk_machine_" + machine + ";\n"
tempstring += """#endif\n"""
-
+
tempstring += r"""
__VOLK_DECL_END
diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py
index 0dc088a80..880ce4094 100644
--- a/volk/gen/make_makefile_am.py
+++ b/volk/gen/make_makefile_am.py
@@ -21,7 +21,7 @@ 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) \
@@ -55,17 +55,17 @@ 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_CFLAGS =
volk_orc_LDFLAGS =
-volk_orc_LIBADD =
+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 =
-
+noinst_LTLIBRARIES =
+
"""
#here be dragons
@@ -76,7 +76,7 @@ noinst_LTLIBRARIES =
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"
diff --git a/volk/gen/make_proccpu_sim.py b/volk/gen/make_proccpu_sim.py
index 029dacfcc..e2c8123e5 100644
--- a/volk/gen/make_proccpu_sim.py
+++ b/volk/gen/make_proccpu_sim.py
@@ -1,24 +1,24 @@
#!/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
@@ -35,7 +35,7 @@ def make_proccpu_sim(dom) :
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";
diff --git a/volk/gen/make_set_simd.py b/volk/gen/make_set_simd.py
index 5a848e59e..8334487d7 100644
--- a/volk/gen/make_set_simd.py
+++ b/volk/gen/make_set_simd.py
@@ -43,17 +43,17 @@ def make_set_simd(dom, machines) :
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);
+ 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";
@@ -67,7 +67,7 @@ def make_set_simd(dom, machines) :
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":
@@ -118,9 +118,9 @@ def make_set_simd(dom, machines) :
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 + " 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";
@@ -138,17 +138,17 @@ def make_set_simd(dom, machines) :
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 + " 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:
@@ -156,11 +156,11 @@ def make_set_simd(dom, machines) :
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
index 8f9f2b55e..09221d2ef 100644
--- a/volk/gen/make_typedefs.py
+++ b/volk/gen/make_typedefs.py
@@ -15,7 +15,7 @@ def make_typedefs(funclist, retlist, my_argtypelist) :
tempstring = tempstring + '\n';
- for i in range(len(funclist)):
+ 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";
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
index 0774ece29..3a237c5ca 100644
--- a/volk/gen/volk_register.py
+++ b/volk/gen/volk_register.py
@@ -62,7 +62,7 @@ for line in hdr_files:
subdtype = re.search("[0-9]+[A-z]+", dtype);
if subdtype:
datatypes.append(subdtype.group(0));
-
+
datatypes = set(datatypes);
@@ -71,7 +71,7 @@ for line in hdr_files:
if dt in line:
subline = re.search("(volk_" + dt +"_.*(a|u).*\.h)", line);
if subline:
-
+
subsubline = re.search(".+(?=\.h)", subline.group(0));
functions.append(subsubline.group(0));
@@ -80,13 +80,13 @@ 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);
-
-#strip out mutex archs
+
+#strip out mutex archs
archflags_dict = {}
for filearch in filearchs:
@@ -177,22 +177,22 @@ for func in functions:
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));
@@ -214,25 +214,25 @@ for func in functions:
if subline:
args = subline.group(0);
begun_name = 0;
- else:
+ 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:
@@ -241,7 +241,7 @@ for func in functions:
replace = re.compile(" " + temp[-1]);
atypes.append(replace.sub("", arg));
-
+
my_args = ""
arg_types = ""
for arg in range(0, len(margs) - 1):
@@ -255,7 +255,7 @@ for func in functions:
this_type = leading_space_remove.sub("", atypes[-1]);
arg_types = arg_types + this_type;
my_argtypelist.append(arg_types);
-
+
if(ret[-1] != ' '):
ret = ret + ' ';
@@ -263,7 +263,7 @@ for func in functions:
my_arglist.append(my_args) #!!!!!!!!!!!!!!!!!
retlist.append(ret);
fcountlist.append(fcount);
- taglist.append(tags);
+ taglist.append(tags);
outfile_cpu_h.write(make_cpuid_h(filearchs));
--
cgit
From c3f2c30a54c75575f464afdd7cd11a017fb07695 Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Sun, 15 Apr 2012 16:03:27 -0700
Subject: Volk: add support for checking AVX enable state of OS.
Some systems (notably Xen hypervisor) appear to use XSETBV to disable AVX. This causes SIGILL when running AVX instructions. This commit makes Volk check XCR0 on the AVX arch before proceeding.
---
volk/gen/archs.xml | 2 ++
volk/gen/make_cpuid_c.py | 40 ++++++++++++++++++++++++++++------------
2 files changed, 30 insertions(+), 12 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index effd90d33..53db3e577 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -148,6 +148,8 @@
c
28
mavx
+ xgetbv
+ 7
32
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 2be1123a8..4bd1ce5b1 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -90,20 +90,26 @@ def make_cpuid_c(dom) :
no_test = False;
else:
no_test = False;
- arch = str(domarch.attributes["name"].value);
- op = domarch.getElementsByTagName("op");
+ arch = str(domarch.attributes["name"].value)
+ op = domarch.getElementsByTagName("op")
if op:
- op = str(op[0].firstChild.data);
- reg = domarch.getElementsByTagName("reg");
+ op = str(op[0].firstChild.data)
+ reg = domarch.getElementsByTagName("reg")
if reg:
- reg = str(reg[0].firstChild.data);
- shift = domarch.getElementsByTagName("shift");
+ reg = str(reg[0].firstChild.data)
+ shift = domarch.getElementsByTagName("shift")
if shift:
- shift = str(shift[0].firstChild.data);
- val = domarch.getElementsByTagName("val");
+ shift = str(shift[0].firstChild.data)
+ val = domarch.getElementsByTagName("val")
if val:
- val = str(val[0].firstChild.data);
-
+ val = str(val[0].firstChild.data)
+ check = domarch.getElementsByTagName("check")
+ if check:
+ check = str(check[0].firstChild.data)
+ checkval = domarch.getElementsByTagName("checkval")
+ if checkval:
+ checkval = str(checkval[0].firstChild.data)
+
if no_test:
tempstring = tempstring + """\
int i_can_has_%s () {
@@ -121,13 +127,23 @@ int i_can_has_%s () {
int i_can_has_%s () {
#if defined(VOLK_CPU_x86)
unsigned int e%sx = cpuid_e%sx (%s);
- return ((e%sx >> %s) & 1) == %s;
+ int hwcap = (((e%sx >> %s) & 1) == %s);
+""" % (arch, reg, reg, op, reg, shift, val)
+
+ if check and checkval:
+ tempstring += """\
+ if (hwcap == 0) return 0;
+ hwcap &= (%s() == %s);
+""" % (check, checkval)
+
+ tempstring += """\
+ return hwcap;
#else
return 0;
#endif
}
-""" % (arch, reg, reg, op, reg, shift, val)
+"""
elif op == "0x80000001":
tempstring = tempstring + """\
--
cgit
From 92db96430685e843443a00936328b3539354c83e Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Sun, 15 Apr 2012 17:21:44 -0700
Subject: Volk: also check to make sure OSXSAVE is enabled so you don't check
XGETBV when OS has it disabled.
---
volk/gen/make_cpuid_c.py | 7 +++++++
1 file changed, 7 insertions(+)
(limited to 'volk/gen')
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 4bd1ce5b1..c6bb5059e 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -73,6 +73,13 @@ static inline unsigned int cpuid_edx(unsigned int op) {
cpuid_x86 (op, regs);
return regs[3];
}
+
+static inline unsigned int xgetbv(void) {
+ //check to make sure that xgetbv is enabled in OS
+ int xgetbv_enabled = cpuid_ecx(1) >> 27 & 0x01;
+ if(xgetbv_enabled == 0) return 0;
+ return __xgetbv();
+}
#endif
"""
--
cgit
From ad9752793bbb7134e14483553766ab3d36e02366 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Wed, 18 Apr 2012 11:18:21 -0700
Subject: volk: added xgetbv stuff from volk_work to maint
This ensures that the compiler has support for xgetbv.
This also fixes MSVC by checking for _xgetbv.
Also, restored copy of cpuid.h, this should not be modified.
---
volk/gen/make_cpuid_c.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
(limited to 'volk/gen')
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index c6bb5059e..674b4fb2e 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -41,11 +41,32 @@ struct VOLK_CPU volk_cpu;
#include
#define cpuid_x86(op, r) __get_cpuid(op, (unsigned int *)r+0, (unsigned int *)r+1, (unsigned int *)r+2, (unsigned int *)r+3)
+ /* Return Intel AVX extended CPU capabilities register.
+ * This function will bomb on non-AVX-capable machines, so
+ * check for AVX capability before executing.
+ */
+ #if defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 4)
+ static inline unsigned long long _xgetbv(unsigned int index){
+ unsigned int eax, edx;
+ __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
+ return ((unsigned long long)edx << 32) | eax;
+ }
+ #define __xgetbv() _xgetbv(0)
+ #else
+ #define __xgetbv() 0
+ #endif
+
//implement get cpuid for MSVC compilers using __cpuid intrinsic
#elif defined(_MSC_VER)
#include
#define cpuid_x86(op, r) __cpuid(r, op)
+ #if defined(_XCR_XFEATURE_ENABLED_MASK)
+ #define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
+ #else
+ #define __xgetbv() 0
+ #endif
+
#else
#error "A get cpuid for volk is not available on this compiler..."
#endif
--
cgit
From ef97a9935853b928cefe0bf27273e935c0df7552 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Wed, 18 Apr 2012 13:32:36 -0700
Subject: volk: gcc version check without __GNUC_PREREQ
---
volk/gen/make_cpuid_c.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 674b4fb2e..49b216677 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -45,7 +45,7 @@ struct VOLK_CPU volk_cpu;
* This function will bomb on non-AVX-capable machines, so
* check for AVX capability before executing.
*/
- #if defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 4)
+ #if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4
static inline unsigned long long _xgetbv(unsigned int index){
unsigned int eax, edx;
__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
--
cgit
From e91983371498cfd87d3f4673d6e5874c9ba03ab9 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 15 Apr 2012 13:56:10 -0700
Subject: volk: work on template stuff
---
volk/gen/volk_arch_defs.py | 70 ++++++++++++++++++++++++++++
volk/gen/volk_machine_defs.py | 0
volk/gen/volk_tmpl_utils.py | 51 +++++++++++++++++++++
volk/gen/volk_xml_utils.py | 103 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 224 insertions(+)
create mode 100644 volk/gen/volk_arch_defs.py
create mode 100644 volk/gen/volk_machine_defs.py
create mode 100644 volk/gen/volk_tmpl_utils.py
create mode 100644 volk/gen/volk_xml_utils.py
(limited to 'volk/gen')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
new file mode 100644
index 000000000..271fc90c7
--- /dev/null
+++ b/volk/gen/volk_arch_defs.py
@@ -0,0 +1,70 @@
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+import os
+import copy
+
+archs = list()
+
+class arch_class:
+ def __init__(self, **kwargs):
+ for key, cast, failval in (
+ ('name', str, None),
+ ('type', str, None),
+ ('no_test', bool, False),
+ ('val', int, None),
+ ('op', eval, None),
+ ('reg', int, None),
+ ('shift', int, None),
+ ('flag', str, None),
+ ('environment', str, None),
+ ('include', str, None),
+ ('alignment', int, 1),
+ ):
+ try: setattr(self, key, cast(kwargs[key]))
+ except: setattr(self, key, failval)
+ assert(self.name)
+ assert(self.type)
+
+ def __repr__(self): return self.name
+
+def register_arch(**kwargs):
+ arch = arch_class(**kwargs)
+ archs.append(arch)
+ if arch.alignment > 1:
+ kwargs['name'] += '_u'
+ kwargs['alignment'] = 1
+ register_arch(**kwargs)
+
+########################################################################
+# register the arches
+########################################################################
+#TODO skip the XML and put it here
+from xml.dom import minidom
+gendir = os.path.dirname(__file__)
+archs_xml = minidom.parse(os.path.join(gendir, 'archs.xml')).getElementsByTagName('arch')
+for arch_xml in archs_xml:
+ kwargs = dict()
+ for attr in arch_xml.attributes.keys():
+ kwargs[attr] = arch_xml.attributes[attr].value
+ for node in arch_xml.childNodes:
+ try:
+ name = node.tagName
+ val = arch_xml.getElementsByTagName(name)[0].firstChild.data
+ kwargs[name] = val
+ except: pass
+ register_arch(**kwargs)
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py
new file mode 100644
index 000000000..8b00f2f1f
--- /dev/null
+++ b/volk/gen/volk_tmpl_utils.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 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.
+#
+
+import os
+import re
+import volk_arch_defs
+from Cheetah import Template
+
+def __escape_pre_processor(code):
+ out = list()
+ for line in code.splitlines():
+ m = re.match('^(\s*)#(\s*)(\w+)(.*)$', line)
+ if m:
+ p0, p1, fcn, stuff = m.groups()
+ pponly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif')
+ both = fcn in ('if', 'else')
+ istmpl = '$' in stuff
+ if pponly or (both and not istmpl):
+ line = '%s\\#%s%s%s'%(p0, p1, fcn, stuff)
+ out.append(line)
+ return '\n'.join(out)
+
+def __parse_tmpl(_tmpl, **kwargs):
+ defs = {
+ 'archs': volk_arch_defs.archs,
+ }
+ defs.update(kwargs)
+ _tmpl = __escape_pre_processor(_tmpl)
+ return str(Template.Template(_tmpl, defs))
+
+import sys
+print __parse_tmpl(open(sys.argv[1]).read())
diff --git a/volk/gen/volk_xml_utils.py b/volk/gen/volk_xml_utils.py
new file mode 100644
index 000000000..05c0e1193
--- /dev/null
+++ b/volk/gen/volk_xml_utils.py
@@ -0,0 +1,103 @@
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+#this would not be necessary if we just skipped the xml part and stored the data in python
+
+import os
+from xml.dom import minidom
+import copy
+
+gendir = os.path.dirname(__file__)
+archs_xml = minidom.parse(os.path.join(gendir, 'archs.xml')).getElementsByTagName('arch')
+machines_xml = minidom.parse(os.path.join(gendir, 'machines.xml')).getElementsByTagName('machine')
+compilers_xml = minidom.parse(os.path.join(gendir, 'compilers.xml')).getElementsByTagName('compiler')
+
+class arch_class:
+ def __init__(self, arch_xml):
+ self.name = arch_xml.attributes['name'].value
+ self.type = arch_xml.attributes['type'].value
+ for key in ('val', 'op', 'reg', 'shift', 'flag', 'environment', 'include', 'alignment'):
+ try: setattr(self, key, arch_xml.getElementsByTagName(key)[0].firstChild.data)
+ except: setattr(self, key, None)
+ if self.alignment is None: self.alignment = 1
+
+ def __repr__(self): return self.name
+
+def get_archs():
+ adict = dict([(a.name, a) for a in map(arch_class, archs_xml)])
+ udict = dict()
+ for name, arch in adict.iteritems():
+ if arch.alignment == 1: continue
+ uarch = copy.deepcopy(arch)
+ uarch.name = arch.name + '_u'
+ uarch.alignment = 1
+ udict[uarch.name] = uarch
+ adict.update(udict)
+ return adict
+
+volk_archs = get_archs()
+
+class machine_class:
+ def __init__(self, name, archlist):
+ self.name = name
+ self.archs = list()
+ for arch_name in archlist:
+ if not arch_name: continue
+ self.archs.append(volk_archs[arch_name])
+ if volk_archs.has_key(arch_name + '_u'):
+ self.archs.append(volk_archs[arch_name + '_u'])
+
+ def __repr__(self): return self.name
+
+def yield_machines(name, archlist):
+ for i, arch_name in enumerate(archlist):
+ if '|' in arch_name:
+ for arch_sub in arch_name.split('|'):
+ for m in yield_machines(name, archlist[:i] + [arch_sub] + archlist[i+1:]):
+ yield m
+ return
+ yield machine_class(name, archlist)
+
+def get_machines():
+ mdict = dict()
+ for machine_xml in machines_xml:
+ name = machine_xml.attributes['name'].value
+ archlist = machine_xml.getElementsByTagName('archs')[0].firstChild.data.split()
+ for machine in yield_machines(name, archlist):
+ mdict[machine.name] = machine
+ return mdict
+
+volk_machines = get_machines()
+
+class compiler_class:
+ def __init__(self, compiler_xml):
+ self.name = compiler_xml.attributes['name'].value
+ self.prefix = compiler_xml.getElementsByTagName('prefix')[0].firstChild.data
+ self._remap = dict()
+ for remap_xml in compiler_xml.getElementsByTagName('remap'):
+ self._remap[remap_xml.attributes['name'].value] = remap_xml.firstChild.data
+
+ def remap(self, option):
+ if not self._remap.has_key(option): return option
+ return self._remap[option]
+
+ def __repr__(self): return self.name
+
+def get_compilers():
+ return dict([(c.name, c) for c in map(compiler_class, compilers_xml)])
+
+volk_compilers = get_compilers()
--
cgit
From eccc86fbb8aa0392307bfdf1bd802e4394868334 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 15 Apr 2012 15:38:14 -0700
Subject: volk: added kernel defs and typedefs
---
volk/gen/volk_arch_defs.py | 9 +-
volk/gen/volk_kernel_defs.py | 210 ++++++++++++++++++++++++++++++++++++++++++
volk/gen/volk_machine_defs.py | 70 ++++++++++++++
volk/gen/volk_tmpl_utils.py | 18 +++-
4 files changed, 300 insertions(+), 7 deletions(-)
create mode 100644 volk/gen/volk_kernel_defs.py
(limited to 'volk/gen')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 271fc90c7..6869ef7a9 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -15,10 +15,8 @@
# along with this program. If not, see .
#
-import os
-import copy
-
archs = list()
+arch_dict = dict()
class arch_class:
def __init__(self, **kwargs):
@@ -45,6 +43,7 @@ class arch_class:
def register_arch(**kwargs):
arch = arch_class(**kwargs)
archs.append(arch)
+ arch_dict[arch.name] = arch
if arch.alignment > 1:
kwargs['name'] += '_u'
kwargs['alignment'] = 1
@@ -55,6 +54,7 @@ def register_arch(**kwargs):
########################################################################
#TODO skip the XML and put it here
from xml.dom import minidom
+import os
gendir = os.path.dirname(__file__)
archs_xml = minidom.parse(os.path.join(gendir, 'archs.xml')).getElementsByTagName('arch')
for arch_xml in archs_xml:
@@ -68,3 +68,6 @@ for arch_xml in archs_xml:
kwargs[name] = val
except: pass
register_arch(**kwargs)
+
+if __name__ == '__main__':
+ print archs
diff --git a/volk/gen/volk_kernel_defs.py b/volk/gen/volk_kernel_defs.py
new file mode 100644
index 000000000..f598ed3c0
--- /dev/null
+++ b/volk/gen/volk_kernel_defs.py
@@ -0,0 +1,210 @@
+#
+# Copyright 2011-2012 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.
+#
+
+import os
+import re
+import sys
+import glob
+
+from volk_arch_defs import archs
+
+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] + tostrip[lindex:len(tostrip)].replace(stripstr, "");
+ return tostrip
+
+srcdir = os.path.dirname(os.path.dirname(__file__))
+hdr_files = glob.glob(os.path.join(srcdir, "include/volk/*.h"))
+
+datatypes = [];
+functions = [];
+
+for line in hdr_files:
+ subline = re.search(".*_(a|u)\.h.*", os.path.basename(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 hdr_files:
+ for dt in datatypes:
+ if dt in line:
+ subline = re.search("(volk_" + dt +"_.*(a|u).*\.h)", line);
+ if subline:
+
+ subsubline = re.search(".+(?=\.h)", subline.group(0));
+ functions.append(subsubline.group(0));
+
+archs_or = "("
+for arch in archs:
+ archs_or = archs_or + arch.name.upper() + "|";
+archs_or = archs_or[0:len(archs_or)-1];
+archs_or = archs_or + ")";
+
+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);
+
+class kernel_class:
+ def __init__(self, index):
+ self.name = functions[index]
+ self.rettype = retlist[index]
+ self.arglist = my_argtypelist[index]
+
+ def __repr__(self):
+ return self.name
+
+kernels = map(kernel_class, range(len(retlist)))
+
+if __name__ == '__main__':
+ print kernels
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index e69de29bb..1c879cd50 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -0,0 +1,70 @@
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+from volk_arch_defs import arch_dict
+
+machines = list()
+machine_dict = dict()
+
+class machine_class:
+ def __init__(self, name, archs):
+ self.name = name
+ self.archs = list()
+ for arch_name in archs:
+ if not arch_name: continue
+ arch = arch_dict[arch_name]
+ self.archs.append(arch)
+ arch_name += '_u'
+ if arch.alignment > 1 and arch_dict.has_key(arch_name):
+ arch = arch_dict[arch_name]
+ self.archs.append(arch)
+
+ def __repr__(self): return self.name
+
+def register_machine(name, archs):
+ for i, arch_name in enumerate(archs):
+ if '|' in arch_name: #handle special arch names with the '|'
+ for arch_sub in arch_name.split('|'):
+ register_machine(name, archs[:i] + [arch_sub] + archs[i+1:])
+ return
+ machine = machine_class(name=name, archs=archs)
+ machines.append(machine)
+ machine_dict[machine.name] = machine
+
+########################################################################
+# register the machines
+########################################################################
+#TODO skip the XML and put it here
+from xml.dom import minidom
+import os
+gendir = os.path.dirname(__file__)
+machines_xml = minidom.parse(os.path.join(gendir, 'machines.xml')).getElementsByTagName('machine')
+for machine_xml in machines_xml:
+ kwargs = dict()
+ for attr in machine_xml.attributes.keys():
+ kwargs[attr] = machine_xml.attributes[attr].value
+ for node in machine_xml.childNodes:
+ try:
+ name = node.tagName
+ val = machine_xml.getElementsByTagName(name)[0].firstChild.data
+ kwargs[name] = val
+ except: pass
+ kwargs['archs'] = kwargs['archs'].split()
+ register_machine(**kwargs)
+
+if __name__ == '__main__':
+ print machines
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py
index 8b00f2f1f..804cc2f28 100644
--- a/volk/gen/volk_tmpl_utils.py
+++ b/volk/gen/volk_tmpl_utils.py
@@ -22,7 +22,10 @@
import os
import re
+import sys
import volk_arch_defs
+import volk_machine_defs
+import volk_kernel_defs
from Cheetah import Template
def __escape_pre_processor(code):
@@ -31,10 +34,10 @@ def __escape_pre_processor(code):
m = re.match('^(\s*)#(\s*)(\w+)(.*)$', line)
if m:
p0, p1, fcn, stuff = m.groups()
- pponly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif')
+ conly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif')
both = fcn in ('if', 'else')
istmpl = '$' in stuff
- if pponly or (both and not istmpl):
+ if conly or (both and not istmpl):
line = '%s\\#%s%s%s'%(p0, p1, fcn, stuff)
out.append(line)
return '\n'.join(out)
@@ -42,10 +45,17 @@ def __escape_pre_processor(code):
def __parse_tmpl(_tmpl, **kwargs):
defs = {
'archs': volk_arch_defs.archs,
+ 'machines': volk_machine_defs.machines,
+ 'kernels': volk_kernel_defs.kernels,
}
defs.update(kwargs)
_tmpl = __escape_pre_processor(_tmpl)
+ _tmpl = """
+
+/* this file was generated by volk template utils, do not edit! */
+
+""" + _tmpl
return str(Template.Template(_tmpl, defs))
-import sys
-print __parse_tmpl(open(sys.argv[1]).read())
+if __name__ == '__main__':
+ print __parse_tmpl(open(sys.argv[1]).read())
--
cgit
From 95e91b44d2ef3535129c0a402c51bc56cfd74d06 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 15 Apr 2012 17:32:38 -0700
Subject: volk: created other templates for runtime + machines
---
volk/gen/volk_arch_defs.py | 5 ++++-
volk/gen/volk_kernel_defs.py | 10 +++++++---
volk/gen/volk_machine_defs.py | 3 ++-
volk/gen/volk_tmpl_utils.py | 10 +++++++++-
4 files changed, 22 insertions(+), 6 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 6869ef7a9..c6115d64e 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -18,6 +18,9 @@
archs = list()
arch_dict = dict()
+#TODO enable this when we are ready
+create_unaligned_archs = False
+
class arch_class:
def __init__(self, **kwargs):
for key, cast, failval in (
@@ -44,7 +47,7 @@ def register_arch(**kwargs):
arch = arch_class(**kwargs)
archs.append(arch)
arch_dict[arch.name] = arch
- if arch.alignment > 1:
+ if arch.alignment > 1 and create_unaligned_archs:
kwargs['name'] += '_u'
kwargs['alignment'] = 1
register_arch(**kwargs)
diff --git a/volk/gen/volk_kernel_defs.py b/volk/gen/volk_kernel_defs.py
index f598ed3c0..a5c7cb710 100644
--- a/volk/gen/volk_kernel_defs.py
+++ b/volk/gen/volk_kernel_defs.py
@@ -154,8 +154,7 @@ for func in functions:
ret = replace.sub("", ret);
replace = re.compile("inline ");
ret = replace.sub("", ret);
- replace = re.compile("\)");
- arched_args = replace.sub(", const char* arch) {", args);
+ arched_args = args[args.find('(')+1:args.find(')')]
remove = re.compile('\)|\(|{');
rargs = remove.sub("", args);
@@ -198,8 +197,13 @@ for func in functions:
class kernel_class:
def __init__(self, index):
self.name = functions[index]
+ self.pname = self.name.replace('volk_', 'p_')
self.rettype = retlist[index]
- self.arglist = my_argtypelist[index]
+ self.arglist_defs = my_argtypelist[index]
+ self.arglist_namedefs = arched_arglist[index]
+ self.arglist_names = my_arglist[index]
+ self.tagdeps = fcountlist[index]
+ self.taglist = taglist[index]
def __repr__(self):
return self.name
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index 1c879cd50..82734679c 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -32,6 +32,7 @@ class machine_class:
if arch.alignment > 1 and arch_dict.has_key(arch_name):
arch = arch_dict[arch_name]
self.archs.append(arch)
+ self.alignment = max(map(lambda a: a.alignment, self.archs))
def __repr__(self): return self.name
@@ -39,7 +40,7 @@ def register_machine(name, archs):
for i, arch_name in enumerate(archs):
if '|' in arch_name: #handle special arch names with the '|'
for arch_sub in arch_name.split('|'):
- register_machine(name, archs[:i] + [arch_sub] + archs[i+1:])
+ register_machine(name+'_'+arch_sub, archs[:i] + [arch_sub] + archs[i+1:])
return
machine = machine_class(name=name, archs=archs)
machines.append(machine)
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py
index 804cc2f28..92b7fb1a4 100644
--- a/volk/gen/volk_tmpl_utils.py
+++ b/volk/gen/volk_tmpl_utils.py
@@ -37,6 +37,7 @@ def __escape_pre_processor(code):
conly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif')
both = fcn in ('if', 'else')
istmpl = '$' in stuff
+ if 'defined' in stuff: istmpl = False
if conly or (both and not istmpl):
line = '%s\\#%s%s%s'%(p0, p1, fcn, stuff)
out.append(line)
@@ -45,7 +46,9 @@ def __escape_pre_processor(code):
def __parse_tmpl(_tmpl, **kwargs):
defs = {
'archs': volk_arch_defs.archs,
+ 'arch_dict': volk_arch_defs.arch_dict,
'machines': volk_machine_defs.machines,
+ 'machine_dict': volk_machine_defs.machine_dict,
'kernels': volk_kernel_defs.kernels,
}
defs.update(kwargs)
@@ -58,4 +61,9 @@ def __parse_tmpl(_tmpl, **kwargs):
return str(Template.Template(_tmpl, defs))
if __name__ == '__main__':
- print __parse_tmpl(open(sys.argv[1]).read())
+ input_file = sys.argv[1]
+ output_file = sys.argv[2]
+ which = sys.argv[3]
+ output = __parse_tmpl(open(input_file).read(), which=which)
+ if output_file: open(output_file, 'w').write(output)
+ else: print output
--
cgit
From 37f9a62fd45ece1e6a92769fbb1798403c86ba9b Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 15 Apr 2012 19:11:52 -0700
Subject: volk: working build w/ cmakelists
---
volk/gen/volk_arch_defs.py | 2 +-
volk/gen/volk_kernel_defs.py | 14 +++++-
volk/gen/volk_tmpl_utils.py | 3 +-
volk/gen/volk_xml_utils.py | 103 -------------------------------------------
4 files changed, 15 insertions(+), 107 deletions(-)
delete mode 100644 volk/gen/volk_xml_utils.py
(limited to 'volk/gen')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index c6115d64e..d29a951eb 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -29,7 +29,7 @@ class arch_class:
('no_test', bool, False),
('val', int, None),
('op', eval, None),
- ('reg', int, None),
+ ('reg', str, None),
('shift', int, None),
('flag', str, None),
('environment', str, None),
diff --git a/volk/gen/volk_kernel_defs.py b/volk/gen/volk_kernel_defs.py
index a5c7cb710..52cdb684c 100644
--- a/volk/gen/volk_kernel_defs.py
+++ b/volk/gen/volk_kernel_defs.py
@@ -202,8 +202,18 @@ class kernel_class:
self.arglist_defs = my_argtypelist[index]
self.arglist_namedefs = arched_arglist[index]
self.arglist_names = my_arglist[index]
- self.tagdeps = fcountlist[index]
- self.taglist = taglist[index]
+ self._tagdeps = fcountlist[index]
+ self._taglist = taglist[index]
+
+ def get_tags(self, archs):
+ def is_in(x): return x.lower() in archs
+ taglist = list()
+ tagdeps = list()
+ for i in range(len(self._tagdeps)):
+ if all(map(is_in, self._tagdeps[i])):
+ taglist.append(self._taglist[i])
+ tagdeps.append(self._tagdeps[i])
+ return taglist, tagdeps
def __repr__(self):
return self.name
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py
index 92b7fb1a4..9d7a0d0e5 100644
--- a/volk/gen/volk_tmpl_utils.py
+++ b/volk/gen/volk_tmpl_utils.py
@@ -63,7 +63,8 @@ def __parse_tmpl(_tmpl, **kwargs):
if __name__ == '__main__':
input_file = sys.argv[1]
output_file = sys.argv[2]
- which = sys.argv[3]
+ try: which = sys.argv[3]
+ except: which = ''
output = __parse_tmpl(open(input_file).read(), which=which)
if output_file: open(output_file, 'w').write(output)
else: print output
diff --git a/volk/gen/volk_xml_utils.py b/volk/gen/volk_xml_utils.py
deleted file mode 100644
index 05c0e1193..000000000
--- a/volk/gen/volk_xml_utils.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#
-# Copyright 2012 Free Software Foundation, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-
-#this would not be necessary if we just skipped the xml part and stored the data in python
-
-import os
-from xml.dom import minidom
-import copy
-
-gendir = os.path.dirname(__file__)
-archs_xml = minidom.parse(os.path.join(gendir, 'archs.xml')).getElementsByTagName('arch')
-machines_xml = minidom.parse(os.path.join(gendir, 'machines.xml')).getElementsByTagName('machine')
-compilers_xml = minidom.parse(os.path.join(gendir, 'compilers.xml')).getElementsByTagName('compiler')
-
-class arch_class:
- def __init__(self, arch_xml):
- self.name = arch_xml.attributes['name'].value
- self.type = arch_xml.attributes['type'].value
- for key in ('val', 'op', 'reg', 'shift', 'flag', 'environment', 'include', 'alignment'):
- try: setattr(self, key, arch_xml.getElementsByTagName(key)[0].firstChild.data)
- except: setattr(self, key, None)
- if self.alignment is None: self.alignment = 1
-
- def __repr__(self): return self.name
-
-def get_archs():
- adict = dict([(a.name, a) for a in map(arch_class, archs_xml)])
- udict = dict()
- for name, arch in adict.iteritems():
- if arch.alignment == 1: continue
- uarch = copy.deepcopy(arch)
- uarch.name = arch.name + '_u'
- uarch.alignment = 1
- udict[uarch.name] = uarch
- adict.update(udict)
- return adict
-
-volk_archs = get_archs()
-
-class machine_class:
- def __init__(self, name, archlist):
- self.name = name
- self.archs = list()
- for arch_name in archlist:
- if not arch_name: continue
- self.archs.append(volk_archs[arch_name])
- if volk_archs.has_key(arch_name + '_u'):
- self.archs.append(volk_archs[arch_name + '_u'])
-
- def __repr__(self): return self.name
-
-def yield_machines(name, archlist):
- for i, arch_name in enumerate(archlist):
- if '|' in arch_name:
- for arch_sub in arch_name.split('|'):
- for m in yield_machines(name, archlist[:i] + [arch_sub] + archlist[i+1:]):
- yield m
- return
- yield machine_class(name, archlist)
-
-def get_machines():
- mdict = dict()
- for machine_xml in machines_xml:
- name = machine_xml.attributes['name'].value
- archlist = machine_xml.getElementsByTagName('archs')[0].firstChild.data.split()
- for machine in yield_machines(name, archlist):
- mdict[machine.name] = machine
- return mdict
-
-volk_machines = get_machines()
-
-class compiler_class:
- def __init__(self, compiler_xml):
- self.name = compiler_xml.attributes['name'].value
- self.prefix = compiler_xml.getElementsByTagName('prefix')[0].firstChild.data
- self._remap = dict()
- for remap_xml in compiler_xml.getElementsByTagName('remap'):
- self._remap[remap_xml.attributes['name'].value] = remap_xml.firstChild.data
-
- def remap(self, option):
- if not self._remap.has_key(option): return option
- return self._remap[option]
-
- def __repr__(self): return self.name
-
-def get_compilers():
- return dict([(c.name, c) for c in map(compiler_class, compilers_xml)])
-
-volk_compilers = get_compilers()
--
cgit
From 3af0f815ae3442dacdac78acf238b277f472c404 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 00:29:26 -0700
Subject: volk: added compile utils and cleanup cmakelists
---
volk/gen/machines.xml | 19 ++++--------
volk/gen/volk_arch_defs.py | 3 ++
volk/gen/volk_compile_utils.py | 68 ++++++++++++++++++++++++++++++++++++++++++
volk/gen/volk_machine_defs.py | 7 ++++-
4 files changed, 82 insertions(+), 15 deletions(-)
create mode 100644 volk/gen/volk_compile_utils.py
(limited to 'volk/gen')
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index 9c19c91c6..04ffef22b 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -10,27 +10,17 @@
-generic 32|64 mmx sse
+generic 32|64| mmx sse
-->
-
-
generic neon
-
-generic mmx sse sse2
-
-
+
-generic 32|64 mmx sse sse2
+generic 32|64| mmx sse sse2
@@ -53,8 +43,9 @@ however it does not support the gcc style inline assembly.
generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount
+
-generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx
+generic 32|64| mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index d29a951eb..4f4796840 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -40,6 +40,9 @@ class arch_class:
except: setattr(self, key, failval)
assert(self.name)
assert(self.type)
+ if self.flag == 'none': self.flag = None
+ self.flags = list()
+ if self.flag: self.flags = map(str.strip, self.flag.split(','))
def __repr__(self): return self.name
diff --git a/volk/gen/volk_compile_utils.py b/volk/gen/volk_compile_utils.py
new file mode 100644
index 000000000..a62c5657e
--- /dev/null
+++ b/volk/gen/volk_compile_utils.py
@@ -0,0 +1,68 @@
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
+import optparse
+import volk_arch_defs
+import volk_machine_defs
+
+def format_flag(flag, compiler):
+ if compiler == 'msvc' and flag in ('mmmx', 'msse'):
+ return '/arch:SSE'
+ if compiler == 'msvc' and flag in ('msse2',):
+ return '/arch:SSE2'
+ if compiler == 'msvc' and flag in ('msse3', 'mssse3', 'msse4.1', 'msse4.2', 'mpopcnt', 'mavx'):
+ return '/arch:AVX'
+ #otherwise its a gcc compiler
+ return '-' + flag
+
+def do_arch_flags_list(compiler):
+ output = list()
+ for arch in volk_arch_defs.archs:
+ fields = [arch.name]
+ fields += list(map(lambda f: format_flag(f, compiler), arch.flags))
+ output.append(','.join(fields))
+ print ';'.join(output)
+
+def do_machines_list(arch_names):
+ output = list()
+ for machine in volk_machine_defs.machines:
+ machine_arch_set = set(machine.arch_names)
+ if set(arch_names).intersection(machine_arch_set) == machine_arch_set:
+ output.append(machine.name)
+ print ';'.join(output)
+
+def do_machine_flags_list(compiler, machine_name):
+ output = list()
+ machine = volk_machine_defs.machine_dict[machine_name]
+ for arch in machine.archs:
+ for flag in arch.flags:
+ output.append(format_flag(flag, compiler))
+ print ' '.join(output)
+
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('--mode', type='string', default='')
+ parser.add_option('--compiler', type='string', default='')
+ parser.add_option('--archs', type='string', default='')
+ parser.add_option('--machine', type='string', default='')
+ (opts, args) = parser.parse_args()
+
+ if opts.mode == 'arch_flags': return do_arch_flags_list(opts.compiler.lower())
+ if opts.mode == 'machines': return do_machines_list(opts.archs.split(';'))
+ if opts.mode == 'machine_flags': return do_machine_flags_list(opts.compiler.lower(), opts.machine)
+
+if __name__ == '__main__': main()
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index 82734679c..b30a480ba 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -24,10 +24,12 @@ class machine_class:
def __init__(self, name, archs):
self.name = name
self.archs = list()
+ self.arch_names = list()
for arch_name in archs:
if not arch_name: continue
arch = arch_dict[arch_name]
self.archs.append(arch)
+ self.arch_names.append(arch_name)
arch_name += '_u'
if arch.alignment > 1 and arch_dict.has_key(arch_name):
arch = arch_dict[arch_name]
@@ -40,7 +42,10 @@ def register_machine(name, archs):
for i, arch_name in enumerate(archs):
if '|' in arch_name: #handle special arch names with the '|'
for arch_sub in arch_name.split('|'):
- register_machine(name+'_'+arch_sub, archs[:i] + [arch_sub] + archs[i+1:])
+ if arch_sub:
+ register_machine(name+'_'+arch_sub, archs[:i] + [arch_sub] + archs[i+1:])
+ else:
+ register_machine(name, archs[:i] + archs[i+1:])
return
machine = machine_class(name=name, archs=archs)
machines.append(machine)
--
cgit
From 25a3690954d80819fe59e179e4675c5cdf81a347 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 00:41:16 -0700
Subject: volk: make orc a normal arch with overrule
---
volk/gen/archs.xml | 8 +++++++-
volk/gen/machines.xml | 4 ----
volk/gen/volk_machine_defs.py | 2 +-
3 files changed, 8 insertions(+), 6 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 59cc81cc5..2b0e8e508 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -89,7 +89,13 @@
- lorc-0.4
+ none
+ LV_HAVE_ORC
+ no
+
+
+
+ none
LV_HAVE_ORC
no
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index 04ffef22b..6ce077e3c 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -48,10 +48,6 @@
generic 32|64| mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx
-
-generic mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx
-
-
generic altivec
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index b30a480ba..77ebe64f0 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -69,7 +69,7 @@ for machine_xml in machines_xml:
val = machine_xml.getElementsByTagName(name)[0].firstChild.data
kwargs[name] = val
except: pass
- kwargs['archs'] = kwargs['archs'].split()
+ kwargs['archs'] = kwargs['archs'].split() + ['orc|norc']
register_machine(**kwargs)
if __name__ == '__main__':
--
cgit
From 0faf0107e38e93bc3fddf8296449a1439978bec1 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 13:38:44 -0700
Subject: volk: updated build system for avx checking support
updated copy of cpuid.h with the latest from gcc 4.6
---
volk/gen/volk_arch_defs.py | 1 +
volk/gen/volk_tmpl_utils.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
(limited to 'volk/gen')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 4f4796840..fd81eed8c 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -35,6 +35,7 @@ class arch_class:
('environment', str, None),
('include', str, None),
('alignment', int, 1),
+ ('check', str, None),
):
try: setattr(self, key, cast(kwargs[key]))
except: setattr(self, key, failval)
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py
index 9d7a0d0e5..c215e389e 100644
--- a/volk/gen/volk_tmpl_utils.py
+++ b/volk/gen/volk_tmpl_utils.py
@@ -34,7 +34,7 @@ def __escape_pre_processor(code):
m = re.match('^(\s*)#(\s*)(\w+)(.*)$', line)
if m:
p0, p1, fcn, stuff = m.groups()
- conly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif')
+ conly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif', 'pragma')
both = fcn in ('if', 'else')
istmpl = '$' in stuff
if 'defined' in stuff: istmpl = False
--
cgit
From 3e2aebaaccf3e97aa56e1159694a212028eb92ad Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 14:35:16 -0700
Subject: volk: removed old generator python code
---
volk/gen/compilers.xml | 30 ----
volk/gen/make_c.py | 88 -----------
volk/gen/make_config_fixed.py | 21 ---
volk/gen/make_config_in.py | 13 --
volk/gen/make_cpuid_c.py | 283 ---------------------------------
volk/gen/make_cpuid_h.py | 48 ------
volk/gen/make_each_machine_c.py | 90 -----------
volk/gen/make_environment_init_c.py | 32 ----
volk/gen/make_environment_init_h.py | 18 ---
volk/gen/make_h.py | 38 -----
volk/gen/make_machines_c.py | 41 -----
volk/gen/make_machines_h.py | 59 -------
volk/gen/make_makefile_am.py | 123 ---------------
volk/gen/make_proccpu_sim.py | 47 ------
volk/gen/make_set_simd.py | 166 --------------------
volk/gen/make_typedefs.py | 23 ---
volk/gen/volk_regexp.py | 13 --
volk/gen/volk_register.py | 303 ------------------------------------
18 files changed, 1436 deletions(-)
delete mode 100644 volk/gen/compilers.xml
delete mode 100644 volk/gen/make_c.py
delete mode 100644 volk/gen/make_config_fixed.py
delete mode 100644 volk/gen/make_config_in.py
delete mode 100644 volk/gen/make_cpuid_c.py
delete mode 100644 volk/gen/make_cpuid_h.py
delete mode 100644 volk/gen/make_each_machine_c.py
delete mode 100644 volk/gen/make_environment_init_c.py
delete mode 100644 volk/gen/make_environment_init_h.py
delete mode 100644 volk/gen/make_h.py
delete mode 100644 volk/gen/make_machines_c.py
delete mode 100644 volk/gen/make_machines_h.py
delete mode 100644 volk/gen/make_makefile_am.py
delete mode 100644 volk/gen/make_proccpu_sim.py
delete mode 100644 volk/gen/make_set_simd.py
delete mode 100644 volk/gen/make_typedefs.py
delete mode 100644 volk/gen/volk_regexp.py
delete mode 100644 volk/gen/volk_register.py
(limited to 'volk/gen')
diff --git a/volk/gen/compilers.xml b/volk/gen/compilers.xml
deleted file mode 100644
index 005eda2aa..000000000
--- a/volk/gen/compilers.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
- arch:SSE
- arch:SSE
-
-
- arch:SSE2
-
-
- arch:AVX
- arch:AVX
- arch:AVX
- arch:AVX
- arch:AVX
- arch:AVX
-
- /
-
-
-
- -
-
-
-
-
-
-
diff --git a/volk/gen/make_c.py b/volk/gen/make_c.py
deleted file mode 100644
index 233cb85c2..000000000
--- a/volk/gen/make_c.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# Copyright 2010-2011 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
-
-#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 "volk_machines.h"
-#include
-#include
-#include "volk_rank_archs.h"
-#include
-#include
-#include
-
-"""
-
-#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;
- unsigned int i;
- for(i=0; icaps & (~volk_get_lvarch()))) {
- if(volk_machines[i]->caps > max_score) {
- max_score = volk_machines[i]->caps;
- machine = volk_machines[i];
- }
- }
- }
- printf("Using Volk machine: %s\n", machine->name);
- return machine;
- }
-}
-
-unsigned int volk_get_alignment(void) {
- return get_machine()->alignment;
-}
-
-"""
-
- for i in range(len(functions)):
- tempstring += "void get_" + functions[i] + replace_arch.sub("", arched_arglist[i]) + "\n"
- tempstring += " %s = get_machine()->%s_archs[volk_rank_archs(get_machine()->%s_indices, get_machine()->%s_arch_defs, get_machine()->%s_n_archs, get_machine()->%s_name, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i], functions[i], functions[i], functions[i])
- tempstring += " %s(%s);\n}\n\n" % (functions[i], my_arglist[i])
- tempstring += replace_volk.sub("p", functions[i]) + " " + functions[i] + " = &get_" + functions[i] + ";\n\n"
- tempstring += "void %s_manual%s\n" % (functions[i], arched_arglist[i])
- tempstring += " get_machine()->%s_archs[get_index(get_machine()->%s_indices, get_machine()->%s_n_archs, arch)](%s);\n}\n" % (functions[i], functions[i], functions[i], my_arglist[i])
- tempstring += "struct volk_func_desc %s_get_func_desc(void) {\n" % (functions[i])
- tempstring += " struct volk_func_desc desc = {get_machine()->%s_indices, get_machine()->%s_arch_defs, get_machine()->%s_n_archs};\n" % (functions[i], functions[i], functions[i])
- tempstring += " return desc;\n}\n"
-
- return tempstring
-
-
diff --git a/volk/gen/make_config_fixed.py b/volk/gen/make_config_fixed.py
deleted file mode 100644
index 96f20b6b2..000000000
--- a/volk/gen/make_config_fixed.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from xml.dom import minidom
-
-def make_config_fixed(dom) :
- tempstring = "";
- tempstring = tempstring +'/*this file is auto generated by volk_register.py*/';
- tempstring = tempstring + '\n#ifndef INCLUDED_VOLK_CONFIG_FIXED_H';
- tempstring = tempstring + '\n#define INCLUDED_VOLK_CONFIG_FIXED_H';
- tempstring = tempstring + '\n\n';
- enum_counter = 0;
- for domarch in dom:
- arch = str(domarch.attributes["name"].value);
- tempstring = tempstring + '#define LV_' + arch.swapcase() + " " + str(enum_counter) + '\n';
- enum_counter = enum_counter + 1;
- tempstring = tempstring + '\n\n';
-
- tempstring = tempstring + "#endif /*INCLUDED_VOLK_CONFIG_FIXED*/\n"
-
- return tempstring;
-
-
-
diff --git a/volk/gen/make_config_in.py b/volk/gen/make_config_in.py
deleted file mode 100644
index d29680af2..000000000
--- a/volk/gen/make_config_in.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from xml.dom import minidom
-
-def make_config_in(dom) :
- tempstring = "";
- tempstring = tempstring +'/*this file is auto generated by volk_register.py*/';
- tempstring = tempstring + '\n\n';
-
- for domarch in dom:
- arch = str(domarch.attributes["name"].value);
- tempstring = tempstring + '#undef LV_HAVE_' + arch.swapcase() + '\n';
- tempstring = tempstring + '\n';
-
- return tempstring
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
deleted file mode 100644
index 005fc2b19..000000000
--- a/volk/gen/make_cpuid_c.py
+++ /dev/null
@@ -1,283 +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
-
-HEADER_TEMPL = """\
-/*this file is auto_generated by volk_register.py*/
-
-#include
-#include
-
-struct VOLK_CPU volk_cpu;
-
-#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
-# define VOLK_CPU_x86
-#endif
-
-#if defined(VOLK_CPU_x86)
-
-//implement get cpuid for gcc compilers using a copy of cpuid.h
-#if defined(__GNUC__)
-#include
-#define cpuid_x86(op, r) __get_cpuid(op, (unsigned int *)r+0, (unsigned int *)r+1, (unsigned int *)r+2, (unsigned int *)r+3)
-
- /* Return Intel AVX extended CPU capabilities register.
- * This function will bomb on non-AVX-capable machines, so
- * check for AVX capability before executing.
- */
- #if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4
- static inline unsigned long long _xgetbv(unsigned int index){
- unsigned int eax, edx;
- __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
- return ((unsigned long long)edx << 32) | eax;
- }
- #define __xgetbv() _xgetbv(0)
- #else
- #define __xgetbv() 0
- #endif
-
-//implement get cpuid for MSVC compilers using __cpuid intrinsic
-#elif defined(_MSC_VER)
-#include
-#define cpuid_x86(op, r) __cpuid(r, op)
-
- #if defined(_XCR_XFEATURE_ENABLED_MASK)
- #define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
- #else
- #define __xgetbv() 0
- #endif
-
-#else
-#error "A get cpuid for volk is not available on this compiler..."
-#endif
-
-static inline unsigned int cpuid_eax(unsigned int op) {
- int regs[4];
- cpuid_x86 (op, regs);
- return regs[0];
-}
-
-static inline unsigned int cpuid_ebx(unsigned int op) {
- int regs[4];
- cpuid_x86 (op, regs);
- return regs[1];
-}
-
-static inline unsigned int cpuid_ecx(unsigned int op) {
- int regs[4];
- cpuid_x86 (op, regs);
- return regs[2];
-}
-
-static inline unsigned int cpuid_edx(unsigned int op) {
- int regs[4];
- cpuid_x86 (op, regs);
- return regs[3];
-}
-
-static inline unsigned int xgetbv(void) {
- //check to make sure that xgetbv is enabled in OS
- int xgetbv_enabled = cpuid_ecx(1) >> 27 & 0x01;
- if(xgetbv_enabled == 0) return 0;
- return __xgetbv();
-}
-#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)
- check = domarch.getElementsByTagName("check")
- if check:
- check = str(check[0].firstChild.data)
- checkval = domarch.getElementsByTagName("checkval")
- if checkval:
- checkval = str(checkval[0].firstChild.data)
-
- if no_test:
- tempstring = tempstring + """\
-int i_can_has_%s () {
-#if defined(VOLK_CPU_x86)
- return 1;
-#else
- return 0;
-#endif
-}
-
-""" % (arch)
-
- elif op == "1":
- tempstring = tempstring + """\
-int i_can_has_%s () {
-#if defined(VOLK_CPU_x86)
- unsigned int e%sx = cpuid_e%sx (%s);
- int hwcap = (((e%sx >> %s) & 1) == %s);
-""" % (arch, reg, reg, op, reg, shift, val)
-
- if check and checkval:
- tempstring += """\
- if (hwcap == 0) return 0;
- hwcap &= (%s() == %s);
-""" % (check, checkval)
-
- tempstring += """\
- return hwcap;
-#else
- return 0;
-#endif
-}
-
-"""
-
- elif op == "0x80000001":
- tempstring = tempstring + """\
-int i_can_has_%s () {
-#if defined(VOLK_CPU_x86)
- 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) == "arm":
- arch = str(domarch.attributes["name"].value);
- tempstring = tempstring + """\
-#if defined(__arm__) && defined(__linux__)
-#include
-#include
-#include
-#define LOOK_FOR_NEON
-#endif
-
-int i_can_has_%s () {
-//it's linux-specific, but if you're compiling libvolk for NEON
-//on Windows you have other problems
-
-#ifdef LOOK_FOR_NEON
- FILE *auxvec_f;
- unsigned long auxvec[2];
- unsigned int found_neon = 0;
- auxvec_f = fopen("/proc/self/auxv", "rb");
- if(!auxvec_f) return 0;
-
- //so auxv is basically 32b of ID and 32b of value
- //so it goes like this
- while(!found_neon && auxvec_f) {
- fread(auxvec, sizeof(unsigned long), 2, auxvec_f);
- if((auxvec[0] == AT_HWCAP) && (auxvec[1] & HWCAP_NEON))
- found_neon = 1;
- }
-
- fclose(auxvec_f);
- return found_neon;
-
-#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
deleted file mode 100644
index 1aa783781..000000000
--- a/volk/gen/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
-
-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 + "#include \n\n";
- tempstring = tempstring + '__VOLK_DECL_BEGIN\n';
- 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 + "__VOLK_DECL_END\n";
- 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
deleted file mode 100644
index 535578859..000000000
--- a/volk/gen/make_each_machine_c.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#
-# Copyright 2010-2011 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
-
-def _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglist, alignment):
-
- #make the machine fcountlist and taglist a subset given the archs list
- machine_fcountlists = list()
- machine_taglists = list()
- for i in range(len(fcountlist)):
- machine_fcountlist = list()
- machine_taglist = list()
- for j in range(len(fcountlist[i])):
- if len(set(archs).intersection(map(str.lower, fcountlist[i][j]))) == len(fcountlist[i][j]):
- machine_fcountlist.append(fcountlist[i][j])
- machine_taglist.append(taglist[i][j])
- machine_fcountlists.append(machine_fcountlist)
- machine_taglists.append(machine_taglist)
-
- #create the volk machine struct for this machine file
- tempstring = ""
- tempstring += "struct volk_machine volk_machine_" + machine_name + " = {\n"
- tempstring += " " + ' | '.join(["(1 << LV_" + arch.swapcase() + ")" for arch in archs]) + ",\n"
- tempstring += " \"%s\",\n"%machine_name
- tempstring += " %s,\n"%alignment
-
- #fill in the description for each function
- for i in range(len(functions)):
- tempstring += " \"%s\",\n"%functions[i]
- tempstring += " {%s},\n"%(', '.join(['"%s"'%tag for tag in machine_taglists[i]]))
- tempstring += " {%s},\n"%(', '.join([' | '.join(['(1 << LV_%s)'%fc for fc in fcount]) for fcount in machine_fcountlists[i]]))
- tempstring += " {%s},\n"%(', '.join(['%s_%s'%(functions[i], tag) for tag in machine_taglists[i]]))
- tempstring += " %d,\n"%len(machine_taglists[i])
-
- tempstring = strip_trailing(tempstring, ",")
- tempstring += "};\n"
- return tempstring
-
-def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist, alignment):
- 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 "volk_machines.h"
-#include
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-"""
- for func in functions:
- tempstring += "#include \n"
- tempstring += "\n\n"
-
- tempstring += """
-#ifdef LV_HAVE_ORC
-%s
-#else
-%s
-#endif
-"""%(
- _make_each_machine_struct(machine_name, archs+["orc"], functions, fcountlist, taglist, alignment),
- _make_each_machine_struct(machine_name, archs, functions, fcountlist, taglist, alignment)
-)
-
- return tempstring
-
-
diff --git a/volk/gen/make_environment_init_c.py b/volk/gen/make_environment_init_c.py
deleted file mode 100644
index 6186162ee..000000000
--- a/volk/gen/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/gen/make_environment_init_h.py b/volk/gen/make_environment_init_h.py
deleted file mode 100644
index 0b0f35d61..000000000
--- a/volk/gen/make_environment_init_h.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from xml.dom import minidom
-
-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 + "#include \n\n";
- tempstring = tempstring + "__VOLK_DECL_BEGIN\n";
- tempstring = tempstring + "void volk_environment_init();\n";
- tempstring = tempstring + "__VOLK_DECL_END\n";
- tempstring = tempstring + "#endif\n"
- return tempstring;
-
-
-
-
diff --git a/volk/gen/make_h.py b/volk/gen/make_h.py
deleted file mode 100644
index cf8987c39..000000000
--- a/volk/gen/make_h.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from xml.dom import minidom
-from volk_regexp import *
-
-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_DECL_BEGIN\n';
-
- tempstring = tempstring + '\n';
-
- tempstring += """
-struct volk_func_desc {
- const char **indices;
- const int *arch_defs;
- const int n_archs;
-};
-
-VOLK_API unsigned int volk_get_alignment(void);
-
-"""
- for i in range(len(funclist)):
- tempstring += "extern VOLK_API " + 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 + '__VOLK_DECL_END\n';
- 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
deleted file mode 100644
index f19da4ae4..000000000
--- a/volk/gen/make_machines_c.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright 2010-2011 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 "volk_machines.h"
-
-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"""
-};
-unsigned int n_volk_machines = sizeof(volk_machines)/sizeof(*volk_machines);
-"""
- return tempstring
diff --git a/volk/gen/make_machines_h.py b/volk/gen/make_machines_h.py
deleted file mode 100644
index d2374120b..000000000
--- a/volk/gen/make_machines_h.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright 2010-2011 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, archs):
- 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
-
-__VOLK_DECL_BEGIN
-
-struct volk_machine {
- const unsigned int caps; //capabilities (i.e., archs compiled into this machine, in the volk_get_lvarch format)
- const char *name;
- const unsigned int alignment; //the maximum byte alignment required for functions in this library
-"""
- for function in functions:
- tempstring += " const char *%s_name;\n"%function
- tempstring += " const char *%s_indices[%d];\n"%(function, len(archs))
- tempstring += " const int %s_arch_defs[%d];\n"%(function, len(archs))
- tempstring += " const %s %s_archs[%d];\n"%(replace_volk.sub("p", function), function, len(archs))
- tempstring += " const int %s_n_archs;\n"%function
-
- tempstring += r"""};
-
-"""
- for machine in machines:
- tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n"
- tempstring += "extern struct volk_machine volk_machine_" + machine + ";\n"
- tempstring += """#endif\n"""
-
- tempstring += r"""
-
-__VOLK_DECL_END
-
-#endif //INCLUDED_LIBVOLK_MACHINES_H"""
-
- return tempstring
diff --git a/volk/gen/make_makefile_am.py b/volk/gen/make_makefile_am.py
deleted file mode 100644
index 880ce4094..000000000
--- a/volk/gen/make_makefile_am.py
+++ /dev/null
@@ -1,123 +0,0 @@
-#
-# Copyright 2010-2011 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 \
- -I$(top_srcdir)/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.c \
- $(top_gendir)/lib/volk_cpu.c \
- volk_rank_archs.c \
- volk_prefs.c \
- $(top_gendir)/lib/volk_machines.c
-
-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 + ".c\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 \
- $(top_gendir)/lib/volk_machines.h \
- $(top_gendir)/lib/volk_environment_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
deleted file mode 100644
index e2c8123e5..000000000
--- a/volk/gen/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/gen/make_set_simd.py b/volk/gen/make_set_simd.py
deleted file mode 100644
index 8334487d7..000000000
--- a/volk/gen/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/gen/make_typedefs.py b/volk/gen/make_typedefs.py
deleted file mode 100644
index 09221d2ef..000000000
--- a/volk/gen/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/gen/volk_regexp.py b/volk/gen/volk_regexp.py
deleted file mode 100644
index eb4ceb54b..000000000
--- a/volk/gen/volk_regexp.py
+++ /dev/null
@@ -1,13 +0,0 @@
-import re
-
-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] + tostrip[lindex:len(tostrip)].replace(stripstr, "");
- return tostrip
diff --git a/volk/gen/volk_register.py b/volk/gen/volk_register.py
deleted file mode 100644
index 3a237c5ca..000000000
--- a/volk/gen/volk_register.py
+++ /dev/null
@@ -1,303 +0,0 @@
-#! /usr/bin/env python
-
-import sys
-import os
-import re
-import glob
-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_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_h = open(os.path.join(gendir, "include/volk/volk.h"), "w")
-outfile_c = open(os.path.join(gendir, "lib/volk.c"), "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_environment_c = open(os.path.join(gendir, "lib/volk_environment_init.c"), "w")
-outfile_environment_h = open(os.path.join(gendir, "lib/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, "lib/volk_machines.h"), "w")
-outfile_machines_c = open(os.path.join(gendir, "lib/volk_machines.c"), "w")
-hdr_files = glob.glob(os.path.join(srcdir, "include/volk/*.h"))
-
-datatypes = [];
-functions = [];
-
-for line in hdr_files:
- subline = re.search(".*_(a|u)\.h.*", os.path.basename(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 hdr_files:
- for dt in datatypes:
- if dt in line:
- subline = re.search("(volk_" + dt +"_.*(a|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);
-
-#strip out mutex archs
-
-archflags_dict = {}
-for filearch in filearchs:
- archflags_dict[str(filearch.attributes["name"].value)] = str(filearch.getElementsByTagName("flag")[0].firstChild.data)
-
-archalign_dict = {}
-for filearch in filearchs:
- alignelem = filearch.getElementsByTagName("alignment")
- if(alignelem):
- archalign_dict[str(filearch.attributes["name"].value)] = int(alignelem[0].firstChild.data)
-
-archs_or = "("
-for arch in archs:
- archs_or = archs_or + arch.upper() + "|";
-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
-
-#get the maximum alignment for all archs in a machine
-machine_alignment_dict = {}
-for machine in machines:
- machine_alignment_dict[machine] = max((archalign_dict.get(k, 1)) for k in machines[machine])
-
-#for machine in machine_alignment_dict:
-# print machine + ": %d" % machine_alignment_dict[machine]
-
-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_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, archs))
-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 + ".c")
- outfile_machine_c = open(machine_c_filename, "w")
- outfile_machine_c.write(make_each_machine_c(machine, machines[machine], functions, fcountlist, taglist, machine_alignment_dict[machine]))
- outfile_machine_c.close()
--
cgit
From 0595b7f2283e0aa1cdebefdac2d3a2702324727d Mon Sep 17 00:00:00 2001
From: Nick Foster
Date: Mon, 16 Apr 2012 17:18:36 -0700
Subject: Volk: redo the archs.xml language to make checks generic. no more
"type", no more piles of #if crap in the template.
---
volk/gen/archs.xml | 183 +++++++++++++++++++++++----------------------
volk/gen/volk_arch_defs.py | 31 ++++----
2 files changed, 111 insertions(+), 103 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 2b0e8e508..134dfa2d9 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -1,161 +1,168 @@
-
- none
+
-
+
maltivec
16
+
-
- mfpu=neon,mfloat-abi=softfp,funsafe-math-optimizations
+
+ mfpu=neon
+ mfloat-abi=softfp
+ funsafe-math-optimizations
16
+
-
+
m32
- MD_SUBCPU
- x86_64
-
- 0x80000001
- d
- 29
+
+
+ 0x80000001
+
+
+ 3
+ 0x80000001
+ 29
+
m64
- 1
- MD_SUBCPU
- x86
-
- 0x80000001
- d
- 31
+
+
+ 3
+ 0x80000001
+ 31
+
m3dnow
- 1
8
-
- 1
- 0x80000001
- d
- 5
+
+
+ 3
+ 0x80000001
+ 5
+
msse4.2
16
-
- 1
- 1
- c
- 23
+
+
+ 2
+ 0x00000001
+ 23
+
mpopcnt
-
- 1
- 1
- d
- 23
+
+
+ 3
+ 0x00000001
+ 23
+
mmmx
8
-
-
- 1
- 1
- d
- 25
+
+
+ 3
+ 0x00000001
+ 25
+
msse
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
xmmintrin.h
16
-
-
- 1
- 1
- d
- 26
+
+
+ 3
+ 0x00000001
+ 26
+
msse2
16
-
- none
- LV_HAVE_ORC
- no
+
-
- none
- LV_HAVE_ORC
- no
+
+
-
- 1
- 1
- c
- 0
+
+
+ 2
+ 0x00000001
+ 0
+
msse3
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
pmmintrin.h
16
-
- 1
- 1
- c
- 9
+
+
+ 2
+ 0x00000001
+ 9
+
mssse3
16
-
- 1
- 0x80000001
- c
- 6
+
+
+ 2
+ 0x80000001
+ 6
+
msse4a
16
-
-
- 1
- 1
- c
- 19
+
+
+ 2
+ 0x00000001
+ 19
+
msse4.1
16
-
- 1
- 1
- c
- 20
+
+
+ 2
+ 0x00000001
+ 20
+
msse4.2
16
-
- 1
- 1
- c
- 28
+
+
+ 2
+ 0x00000001
+ 28
+
+
+
mavx
- xgetbv
- 7
32
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index fd81eed8c..d64f8def2 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -22,28 +22,18 @@ arch_dict = dict()
create_unaligned_archs = False
class arch_class:
- def __init__(self, **kwargs):
+ def __init__(self, flags, checks, **kwargs):
for key, cast, failval in (
('name', str, None),
- ('type', str, None),
- ('no_test', bool, False),
- ('val', int, None),
- ('op', eval, None),
- ('reg', str, None),
- ('shift', int, None),
- ('flag', str, None),
('environment', str, None),
('include', str, None),
- ('alignment', int, 1),
- ('check', str, None),
+ ('alignment', int, 1)
):
try: setattr(self, key, cast(kwargs[key]))
except: setattr(self, key, failval)
+ self.checks = checks
assert(self.name)
- assert(self.type)
- if self.flag == 'none': self.flag = None
- self.flags = list()
- if self.flag: self.flags = map(str.strip, self.flag.split(','))
+ self.flags = flags
def __repr__(self): return self.name
@@ -74,7 +64,18 @@ for arch_xml in archs_xml:
val = arch_xml.getElementsByTagName(name)[0].firstChild.data
kwargs[name] = val
except: pass
- register_arch(**kwargs)
+ checks = []
+ for check_xml in arch_xml.getElementsByTagName("check"):
+ name = check_xml.attributes["name"].value
+ params = list()
+ for param_xml in check_xml.getElementsByTagName("param"):
+ params.append(param_xml.firstChild.data)
+ checks.append([name, params])
+ flags = []
+ for flag_xml in arch_xml.getElementsByTagName("flag"):
+ flags.append(flag_xml.firstChild.data)
+
+ register_arch(flags=flags, checks=checks, **kwargs)
if __name__ == '__main__':
print archs
--
cgit
From 0b117624e09643b7615316d3fa4741e2004529fa Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 18:39:29 -0700
Subject: volk: move avx cpuid_x86_bit check in archs.xml
---
volk/gen/archs.xml | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 134dfa2d9..ac4dd9f7f 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -160,6 +160,12 @@
0x00000001
28
+
+
+ 2
+ 0x00000001
+ 27
+
mavx
--
cgit
From f70cb7901a43c201242399225d31eed83e7d41ce Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 16 Apr 2012 21:56:01 -0700
Subject: volk: use archs.xml to specify compiler flags + support
---
volk/gen/archs.xml | 45 +++++++++++++++++++++++++-----------------
volk/gen/volk_arch_defs.py | 19 +++++++++++++-----
volk/gen/volk_compile_utils.py | 17 +++-------------
3 files changed, 44 insertions(+), 37 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index ac4dd9f7f..2c9ab41a5 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -5,21 +5,21 @@
- maltivec
+ -maltivec
16
- mfpu=neon
- mfloat-abi=softfp
- funsafe-math-optimizations
+ -mfpu=neon
+ -mfloat-abi=softfp
+ -funsafe-math-optimizations
16
- m32
+ -m32
@@ -31,7 +31,7 @@
0x80000001
29
- m64
+ -m64
@@ -40,7 +40,7 @@
0x80000001
31
- m3dnow
+ -m3dnow
8
@@ -50,7 +50,7 @@
0x80000001
5
- msse4.2
+ -msse4.2
16
@@ -60,7 +60,8 @@
0x00000001
23
- mpopcnt
+ -mpopcnt
+ /arch:AVX
@@ -69,7 +70,8 @@
0x00000001
23
- mmmx
+ -mmmx
+ /arch:SSE
8
@@ -79,7 +81,8 @@
0x00000001
25
- msse
+ -msse
+ /arch:SSE
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
xmmintrin.h
16
@@ -91,7 +94,8 @@
0x00000001
26
- msse2
+ -msse2
+ /arch:SSE2
16
@@ -108,7 +112,8 @@
0x00000001
0
- msse3
+ -msse3
+ /arch:AVX
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
pmmintrin.h
16
@@ -120,7 +125,8 @@
0x00000001
9
- mssse3
+ -mssse3
+ /arch:AVX
16
@@ -130,7 +136,7 @@
0x80000001
6
- msse4a
+ -msse4a
16
@@ -140,7 +146,8 @@
0x00000001
19
- msse4.1
+ -msse4.1
+ /arch:AVX
16
@@ -150,7 +157,8 @@
0x00000001
20
- msse4.2
+ -msse4.2
+ /arch:AVX
16
@@ -168,7 +176,8 @@
- mavx
+ -mavx
+ /arch:AVX
32
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index d64f8def2..8ac99b338 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -33,7 +33,15 @@ class arch_class:
except: setattr(self, key, failval)
self.checks = checks
assert(self.name)
- self.flags = flags
+ self._flags = flags
+
+ def is_supported(self, compiler):
+ if not self._flags.keys(): return True
+ return compiler in self._flags.keys()
+
+ def get_flags(self, compiler):
+ try: return self._flags[compiler]
+ except KeyError: return list()
def __repr__(self): return self.name
@@ -64,17 +72,18 @@ for arch_xml in archs_xml:
val = arch_xml.getElementsByTagName(name)[0].firstChild.data
kwargs[name] = val
except: pass
- checks = []
+ checks = list()
for check_xml in arch_xml.getElementsByTagName("check"):
name = check_xml.attributes["name"].value
params = list()
for param_xml in check_xml.getElementsByTagName("param"):
params.append(param_xml.firstChild.data)
checks.append([name, params])
- flags = []
+ flags = dict()
for flag_xml in arch_xml.getElementsByTagName("flag"):
- flags.append(flag_xml.firstChild.data)
-
+ name = flag_xml.attributes["compiler"].value
+ if not flags.has_key(name): flags[name] = list()
+ flags[name].append(flag_xml.firstChild.data)
register_arch(flags=flags, checks=checks, **kwargs)
if __name__ == '__main__':
diff --git a/volk/gen/volk_compile_utils.py b/volk/gen/volk_compile_utils.py
index a62c5657e..cd9f9f0a9 100644
--- a/volk/gen/volk_compile_utils.py
+++ b/volk/gen/volk_compile_utils.py
@@ -19,21 +19,11 @@ import optparse
import volk_arch_defs
import volk_machine_defs
-def format_flag(flag, compiler):
- if compiler == 'msvc' and flag in ('mmmx', 'msse'):
- return '/arch:SSE'
- if compiler == 'msvc' and flag in ('msse2',):
- return '/arch:SSE2'
- if compiler == 'msvc' and flag in ('msse3', 'mssse3', 'msse4.1', 'msse4.2', 'mpopcnt', 'mavx'):
- return '/arch:AVX'
- #otherwise its a gcc compiler
- return '-' + flag
-
def do_arch_flags_list(compiler):
output = list()
for arch in volk_arch_defs.archs:
- fields = [arch.name]
- fields += list(map(lambda f: format_flag(f, compiler), arch.flags))
+ if not arch.is_supported(compiler): continue
+ fields = [arch.name] + arch.get_flags(compiler)
output.append(','.join(fields))
print ';'.join(output)
@@ -49,8 +39,7 @@ def do_machine_flags_list(compiler, machine_name):
output = list()
machine = volk_machine_defs.machine_dict[machine_name]
for arch in machine.archs:
- for flag in arch.flags:
- output.append(format_flag(flag, compiler))
+ output.extend(arch.get_flags(compiler))
print ' '.join(output)
def main():
--
cgit
From c1348c8cdc8d607a00f2c427e0bdf78c80e836d1 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Tue, 17 Apr 2012 11:44:49 -0700
Subject: volk: remove norc, implement machine overrule
---
volk/gen/machines.xml | 22 +++++++++++-----------
volk/gen/volk_machine_defs.py | 2 +-
2 files changed, 12 insertions(+), 12 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index 6ce077e3c..8e3c9c8c2 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -1,51 +1,51 @@
-generic
+generic orc|
-generic neon
+generic neon orc|
-generic 32|64| mmx sse sse2
+generic 32|64| mmx sse sse2 orc|
-generic 32|64 mmx sse sse2 sse3
+generic 32|64 mmx sse sse2 sse3 orc|
-generic 32|64 mmx sse sse2 sse3 ssse3
+generic 32|64 mmx sse sse2 sse3 ssse3 orc|
-generic 32|64 mmx sse sse2 sse3 sse4_a popcount
+generic 32|64 mmx sse sse2 sse3 sse4_a popcount orc|
-generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1
+generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 orc|
-generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount
+generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount orc|
-generic 32|64| mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx
+generic 32|64| mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx orc|
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index 77ebe64f0..b30a480ba 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -69,7 +69,7 @@ for machine_xml in machines_xml:
val = machine_xml.getElementsByTagName(name)[0].firstChild.data
kwargs[name] = val
except: pass
- kwargs['archs'] = kwargs['archs'].split() + ['orc|norc']
+ kwargs['archs'] = kwargs['archs'].split()
register_machine(**kwargs)
if __name__ == '__main__':
--
cgit
From bb61c325dabfc80bbd8404b2892575948b77496b Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Thu, 19 Apr 2012 00:50:18 -0700
Subject: volk: code simplification, overrule macro and python opts
---
volk/gen/volk_compile_utils.py | 9 +++++----
volk/gen/volk_tmpl_utils.py | 18 +++++++++++-------
2 files changed, 16 insertions(+), 11 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/volk_compile_utils.py b/volk/gen/volk_compile_utils.py
index cd9f9f0a9..cf1357375 100644
--- a/volk/gen/volk_compile_utils.py
+++ b/volk/gen/volk_compile_utils.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
#
# Copyright 2012 Free Software Foundation, Inc.
#
@@ -44,10 +45,10 @@ def do_machine_flags_list(compiler, machine_name):
def main():
parser = optparse.OptionParser()
- parser.add_option('--mode', type='string', default='')
- parser.add_option('--compiler', type='string', default='')
- parser.add_option('--archs', type='string', default='')
- parser.add_option('--machine', type='string', default='')
+ parser.add_option('--mode', type='string')
+ parser.add_option('--compiler', type='string')
+ parser.add_option('--archs', type='string')
+ parser.add_option('--machine', type='string')
(opts, args) = parser.parse_args()
if opts.mode == 'arch_flags': return do_arch_flags_list(opts.compiler.lower())
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py
index c215e389e..6c08a8213 100644
--- a/volk/gen/volk_tmpl_utils.py
+++ b/volk/gen/volk_tmpl_utils.py
@@ -23,6 +23,7 @@
import os
import re
import sys
+import optparse
import volk_arch_defs
import volk_machine_defs
import volk_kernel_defs
@@ -60,11 +61,14 @@ def __parse_tmpl(_tmpl, **kwargs):
""" + _tmpl
return str(Template.Template(_tmpl, defs))
-if __name__ == '__main__':
- input_file = sys.argv[1]
- output_file = sys.argv[2]
- try: which = sys.argv[3]
- except: which = ''
- output = __parse_tmpl(open(input_file).read(), which=which)
- if output_file: open(output_file, 'w').write(output)
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('--input', type='string')
+ parser.add_option('--output', type='string')
+ (opts, args) = parser.parse_args()
+
+ output = __parse_tmpl(open(opts.input).read(), args=args)
+ if opts.output: open(opts.output, 'w').write(output)
else: print output
+
+if __name__ == '__main__': main()
--
cgit
From 954ee16a180e16fbd232f18b0a69eaed55bd7fdd Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Mon, 23 Apr 2012 14:07:08 -0700
Subject: volk: force kwargs keys to be of type str, not unicode for py25
---
volk/gen/volk_arch_defs.py | 2 ++
volk/gen/volk_machine_defs.py | 2 ++
2 files changed, 4 insertions(+)
(limited to 'volk/gen')
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 8ac99b338..41154d5a7 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -84,6 +84,8 @@ for arch_xml in archs_xml:
name = flag_xml.attributes["compiler"].value
if not flags.has_key(name): flags[name] = list()
flags[name].append(flag_xml.firstChild.data)
+ #force kwargs keys to be of type str, not unicode for py25
+ kwargs = dict((str(k), v) for k, v in kwargs.iteritems())
register_arch(flags=flags, checks=checks, **kwargs)
if __name__ == '__main__':
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index b30a480ba..d1a856981 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -70,6 +70,8 @@ for machine_xml in machines_xml:
kwargs[name] = val
except: pass
kwargs['archs'] = kwargs['archs'].split()
+ #force kwargs keys to be of type str, not unicode for py25
+ kwargs = dict((str(k), v) for k, v in kwargs.iteritems())
register_machine(**kwargs)
if __name__ == '__main__':
--
cgit
From 95318443bc4ebc9be796f12857d6da4f59c6471d Mon Sep 17 00:00:00 2001
From: Tom Rondeau
Date: Thu, 7 Jun 2012 15:52:17 -0400
Subject: volk: have an alignment even for unknown (generic) machines.
---
volk/gen/archs.xml | 1 +
1 file changed, 1 insertion(+)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index 2c9ab41a5..a18455801 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -2,6 +2,7 @@
+ 1
--
cgit
From cf8b2a8ff57ff6d3fd4b78a897854cc9a6f49fe1 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Tue, 17 Jul 2012 10:29:35 -0700
Subject: volk: fix for win64 MSVC not having MMX support
1) For the machine defs that will pass on windows,
generate a machine with mmx and without using mmx|
2) In the cmakelists, we overrule MMX arch on MSVC 64.
Also overrule redundant machines for when MMX does pass.
3) Set LV_HAVE_SSE && LV_HAVE_MMX for volk_16i_32fc_dot_prod_32fc_a.
Afterall, it is calling into MMX intrinsics as well.
---
volk/gen/machines.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/machines.xml b/volk/gen/machines.xml
index 8e3c9c8c2..d88a1a50c 100644
--- a/volk/gen/machines.xml
+++ b/volk/gen/machines.xml
@@ -10,7 +10,7 @@
-generic 32|64| mmx sse orc|
+generic 32|64| mmx| sse orc|
-->
@@ -20,7 +20,7 @@
-generic 32|64| mmx sse sse2 orc|
+generic 32|64| mmx| sse sse2 orc|
@@ -45,7 +45,7 @@
-generic 32|64| mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx orc|
+generic 32|64| mmx| sse sse2 sse3 ssse3 sse4_1 sse4_2 popcount avx orc|
--
cgit
From e826097e09fdfb04d14bf87861646b88229db881 Mon Sep 17 00:00:00 2001
From: Josh Blum
Date: Sun, 13 Jan 2013 13:51:46 -0800
Subject: gras: support changeset for 3.6.4
used volk from next branch cf5c930d89ac89ba5a0da4a616c88d3c37e018ae for grextras support (it uses the dispatcher)
empty stubs for the gr_basic_block msg passing. This is going to be difficult to figure out. The alias stuff may or may not be related
most qa pass, there seems to be some additional issues, will be working through them on futher commits
Conflicts:
gnuradio-core/CMakeLists.txt
gnuradio-core/src/lib/runtime/CMakeLists.txt
gnuradio-core/src/lib/runtime/gr_block.cc
gnuradio-core/src/lib/runtime/gr_block.h
gnuradio-core/src/lib/runtime/gr_hier_block2.h
gnuradio-core/src/lib/runtime/gr_top_block.h
gnuradio-core/src/python/gnuradio/gr/__init__.py
gr-audio/examples/c++/CMakeLists.txt
gr-fcd/examples/c++/CMakeLists.txt
grc/python/Port.py
---
volk/gen/archs.xml | 1 -
volk/gen/volk_arch_defs.py | 7 -
volk/gen/volk_kernel_defs.py | 343 ++++++++++++++++++++----------------------
volk/gen/volk_machine_defs.py | 4 -
4 files changed, 164 insertions(+), 191 deletions(-)
(limited to 'volk/gen')
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml
index a18455801..2c9ab41a5 100644
--- a/volk/gen/archs.xml
+++ b/volk/gen/archs.xml
@@ -2,7 +2,6 @@
- 1
diff --git a/volk/gen/volk_arch_defs.py b/volk/gen/volk_arch_defs.py
index 41154d5a7..3c75e1374 100644
--- a/volk/gen/volk_arch_defs.py
+++ b/volk/gen/volk_arch_defs.py
@@ -18,9 +18,6 @@
archs = list()
arch_dict = dict()
-#TODO enable this when we are ready
-create_unaligned_archs = False
-
class arch_class:
def __init__(self, flags, checks, **kwargs):
for key, cast, failval in (
@@ -49,10 +46,6 @@ def register_arch(**kwargs):
arch = arch_class(**kwargs)
archs.append(arch)
arch_dict[arch.name] = arch
- if arch.alignment > 1 and create_unaligned_archs:
- kwargs['name'] += '_u'
- kwargs['alignment'] = 1
- register_arch(**kwargs)
########################################################################
# register the arches
diff --git a/volk/gen/volk_kernel_defs.py b/volk/gen/volk_kernel_defs.py
index 52cdb684c..f246db0f9 100644
--- a/volk/gen/volk_kernel_defs.py
+++ b/volk/gen/volk_kernel_defs.py
@@ -24,201 +24,186 @@ import re
import sys
import glob
-from volk_arch_defs import archs
-
-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] + tostrip[lindex:len(tostrip)].replace(stripstr, "");
- return tostrip
+########################################################################
+# Strip comments from a c/cpp file.
+# Input is code string, output is code string without comments.
+# http://stackoverflow.com/questions/241327/python-snippet-to-remove-c-and-c-comments
+########################################################################
+def comment_remover(text):
+ def replacer(match):
+ s = match.group(0)
+ if s.startswith('/'):
+ return ""
+ else:
+ return s
+ pattern = re.compile(
+ r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
+ re.DOTALL | re.MULTILINE
+ )
+ return re.sub(pattern, replacer, text)
+
+########################################################################
+# Split code into nested sections according to ifdef preprocessor macros
+########################################################################
+def split_into_nested_ifdef_sections(code):
+ sections = list()
+ section = ''
+ header = 'text'
+ in_section_depth = 0
+ for i, line in enumerate(code.splitlines()):
+ m = re.match('^(\s*)#(\s*)(\w+)(.*)$', line)
+ line_is = 'normal'
+ if m:
+ p0, p1, fcn, stuff = m.groups()
+ if fcn in ('if', 'ifndef', 'ifdef'): line_is = 'if'
+ if fcn in ('else', 'elif'): line_is = 'else'
+ if fcn in ('endif',): line_is = 'end'
+
+ if line_is == 'if': in_section_depth += 1
+ if line_is == 'end': in_section_depth -= 1
+
+ if in_section_depth == 1 and line_is == 'if':
+ sections.append((header, section))
+ section = ''
+ header = line
+ continue
-srcdir = os.path.dirname(os.path.dirname(__file__))
-hdr_files = glob.glob(os.path.join(srcdir, "include/volk/*.h"))
-
-datatypes = [];
-functions = [];
-
-for line in hdr_files:
- subline = re.search(".*_(a|u)\.h.*", os.path.basename(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 hdr_files:
- for dt in datatypes:
- if dt in line:
- subline = re.search("(volk_" + dt +"_.*(a|u).*\.h)", line);
- if subline:
-
- subsubline = re.search(".+(?=\.h)", subline.group(0));
- functions.append(subsubline.group(0));
-
-archs_or = "("
-for arch in archs:
- archs_or = archs_or + arch.name.upper() + "|";
-archs_or = archs_or[0:len(archs_or)-1];
-archs_or = archs_or + ")";
-
-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):
+ if in_section_depth == 1 and line_is == 'else':
+ sections.append((header, section))
+ section = ''
+ header = line
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 in_section_depth == 0 and line_is == 'end':
+ sections.append((header, section))
+ section = ''
+ header = 'text'
+ continue
- if begun_name == 0:
- retline = re.search(".+(?=" + func + ")", line);
- if retline:
- ret = retline.group(0);
+ section += line + '\n'
+ sections.append((header, section)) #and pack remainder into sections
+ sections = [sec for sec in sections if sec[1].strip()] #filter empty sections
+ #recurse into non-text sections to fill subsections
+ for i, (header, section) in enumerate(sections):
+ if header == 'text': continue
+ sections[i] = (header, split_into_nested_ifdef_sections(section))
+ return sections
- subline = re.search(func + ".*", line);
- if subline:
- subsubline = re.search("\(.*?\)", subline.group(0));
- if subsubline:
- args = subsubline.group(0);
+########################################################################
+# Recursive print of sections to test code above
+########################################################################
+def print_sections(sections, indent = ' '):
+ for header, body in sections:
+ if header == 'text':
+ print indent, ('\n'+indent).join(body.splitlines())
+ continue
+ print indent.replace(' ', '-') + '>', header
+ print_sections(body, indent + ' ')
+
+########################################################################
+# Flatten a section to just body text
+########################################################################
+def flatten_section_text(sections):
+ output = ''
+ for hdr, bdy in sections:
+ if hdr != 'text': output += flatten_section_text(bdy)
+ else: output += bdy
+ return output
+
+########################################################################
+# Extract kernel info from section, represent as an implementation
+########################################################################
+class impl_class:
+ def __init__(self, kern_name, header, body):
+ #extract LV_HAVE_*
+ self.deps = set(map(str.lower, re.findall('LV_HAVE_(\w+)', header)))
+ #extract function suffix and args
+ body = flatten_section_text(body)
+ try:
+ fcn_matcher = re.compile('^.*(%s\\w*)\\s*\\((.*)$'%kern_name, re.DOTALL | re.MULTILINE)
+ body = body.split('{')[0].rsplit(')', 1)[0] #get the part before the open ){ bracket
+ m = fcn_matcher.match(body)
+ impl_name, the_rest = m.groups()
+ self.name = impl_name.replace(kern_name+'_', '')
+ self.args = list()
+ fcn_args = the_rest.split(',')
+ for fcn_arg in fcn_args:
+ arg_matcher = re.compile('^\s*(.*\\W)\s*(\w+)\s*$', re.DOTALL | re.MULTILINE)
+ m = arg_matcher.match(fcn_arg)
+ arg_type, arg_name = m.groups()
+ self.args.append((arg_type, arg_name))
+ except Exception as ex:
+ raise Exception, 'I cant parse the function prototype from: %s in %s\n%s'%(kern_name, body, ex)
+
+ assert self.name
+ self.is_aligned = self.name.startswith('a_')
- 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);
- arched_args = args[args.find('(')+1:args.find(')')]
-
- 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);
+ def __repr__(self):
+ return self.name
+########################################################################
+# Get sets of LV_HAVE_* from the code
+########################################################################
+def extract_lv_haves(code):
+ haves = list()
+ for line in code.splitlines():
+ if not line.strip().startswith('#'): continue
+ have_set = set(map(str.lower, re.findall('LV_HAVE_(\w+)', line)))
+ if have_set: haves.append(have_set)
+ return haves
+
+########################################################################
+# Represent a processing kernel, parse from file
+########################################################################
class kernel_class:
- def __init__(self, index):
- self.name = functions[index]
+ def __init__(self, kernel_file):
+ self.name = os.path.splitext(os.path.basename(kernel_file))[0]
self.pname = self.name.replace('volk_', 'p_')
- self.rettype = retlist[index]
- self.arglist_defs = my_argtypelist[index]
- self.arglist_namedefs = arched_arglist[index]
- self.arglist_names = my_arglist[index]
- self._tagdeps = fcountlist[index]
- self._taglist = taglist[index]
-
- def get_tags(self, archs):
- def is_in(x): return x.lower() in archs
- taglist = list()
- tagdeps = list()
- for i in range(len(self._tagdeps)):
- if all(map(is_in, self._tagdeps[i])):
- taglist.append(self._taglist[i])
- tagdeps.append(self._tagdeps[i])
- return taglist, tagdeps
+ code = open(kernel_file, 'r').read()
+ code = comment_remover(code)
+ sections = split_into_nested_ifdef_sections(code)
+ self._impls = list()
+ for header, section in sections:
+ if 'ifndef' not in header.lower(): continue
+ for sub_hdr, body in section:
+ if 'if' not in sub_hdr.lower(): continue
+ if 'LV_HAVE_' not in sub_hdr: continue
+ self._impls.append(impl_class(
+ kern_name=self.name, header=sub_hdr, body=body,
+ ))
+ assert(self._impls)
+ self.has_dispatcher = False
+ for impl in self._impls:
+ if impl.name == 'dispatcher':
+ self._impls.remove(impl)
+ self.has_dispatcher = True
+ break
+ self.args = self._impls[0].args
+ self.arglist_types = ', '.join([a[0] for a in self.args])
+ self.arglist_full = ', '.join(['%s %s'%a for a in self.args])
+ self.arglist_names = ', '.join([a[1] for a in self.args])
+
+ def get_impls(self, archs):
+ archs = set(archs)
+ impls = list()
+ for impl in self._impls:
+ if impl.deps.intersection(archs) == impl.deps:
+ impls.append(impl)
+ return impls
def __repr__(self):
return self.name
-kernels = map(kernel_class, range(len(retlist)))
+########################################################################
+# Extract information from the VOLK kernels
+########################################################################
+__file__ = os.path.abspath(__file__)
+srcdir = os.path.dirname(os.path.dirname(__file__))
+kernel_files = glob.glob(os.path.join(srcdir, "kernels", "volk", "*.h"))
+kernels = map(kernel_class, kernel_files)
if __name__ == '__main__':
print kernels
diff --git a/volk/gen/volk_machine_defs.py b/volk/gen/volk_machine_defs.py
index d1a856981..7293d4746 100644
--- a/volk/gen/volk_machine_defs.py
+++ b/volk/gen/volk_machine_defs.py
@@ -30,10 +30,6 @@ class machine_class:
arch = arch_dict[arch_name]
self.archs.append(arch)
self.arch_names.append(arch_name)
- arch_name += '_u'
- if arch.alignment > 1 and arch_dict.has_key(arch_name):
- arch = arch_dict[arch_name]
- self.archs.append(arch)
self.alignment = max(map(lambda a: a.alignment, self.archs))
def __repr__(self): return self.name
--
cgit