summaryrefslogtreecommitdiff
path: root/volk
diff options
context:
space:
mode:
Diffstat (limited to 'volk')
-rw-r--r--volk/include/volk/machines.xml47
-rw-r--r--volk/include/volk/make_each_machine_c.py83
-rw-r--r--volk/include/volk/make_machines_c.py57
-rw-r--r--volk/include/volk/make_machines_h.py50
-rw-r--r--volk/include/volk/make_makefile_am.py13
-rw-r--r--volk/include/volk/make_typedefs.py2
-rw-r--r--volk/include/volk/volk_8ic_x2_multiply_conjugate_16ic_a16.h3
-rw-r--r--volk/include/volk/volk_8ic_x2_s32f_multiply_conjugate_32fc_a16.h4
-rw-r--r--volk/include/volk/volk_common.h11
-rw-r--r--volk/include/volk/volk_regexp.py6
-rwxr-xr-xvolk/include/volk/volk_register.py17
11 files changed, 278 insertions, 15 deletions
diff --git a/volk/include/volk/machines.xml b/volk/include/volk/machines.xml
new file mode 100644
index 000000000..8eed9e8d7
--- /dev/null
+++ b/volk/include/volk/machines.xml
@@ -0,0 +1,47 @@
+<grammar>
+
+<machine name="generic">
+<archs>generic</archs>
+</machine>
+
+<machine name="mmx">
+<archs>generic 32|64 mmx</archs>
+</machine>
+
+<machine name="sse">
+<archs>generic 32|64 mmx sse</archs>
+</machine>
+
+<machine name="sse2">
+<archs>generic 32|64 mmx sse sse2</archs>
+</machine>
+
+<machine name="sse3">
+<archs>generic 32|64 mmx sse sse2 sse3</archs>
+</machine>
+
+<machine name="ssse3">
+<archs>generic 32|64 mmx sse sse2 sse3 ssse3</archs>
+</machine>
+
+<machine name="sse4_a">
+<archs>generic 32|64 mmx sse sse2 sse3 sse4_a popcount</archs>
+</machine>
+
+<machine name="sse4_1">
+<archs>generic 32|64 mmx sse sse2 sse3 ssse3 sse4_1</archs>
+</machine>
+
+<machine name="sse4_2">
+<archs>generic 32|64 mmx sse sse2 sse3 ssse3 sse4_2 popcount</archs>
+</machine>
+
+<machine name="avx">
+<archs>generic 32|64 mmx sse sse2 sse3 ssse3 sse4_2 popcount avx</archs>
+</machine>
+
+<machine name="altivec">
+<archs>generic altivec</archs>
+</machine>
+
+</grammar>
diff --git a/volk/include/volk/make_each_machine_c.py b/volk/include/volk/make_each_machine_c.py
new file mode 100644
index 000000000..abf4bb2d5
--- /dev/null
+++ b/volk/include/volk/make_each_machine_c.py
@@ -0,0 +1,83 @@
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+
+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 <volk_common.h>
+#include <volk_machines.h>
+#include <volk_registry.h>
+
+"""
+ for func in functions:
+ tempstring += "#include <volk/" + func + ".h>\n"
+ tempstring += "\n\n"
+
+ tempstring += emit_prolog();
+
+ 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]:
+ ok = True
+ for arch in arch_list:
+ if arch.swapcase() not in archs:
+ ok = False
+ if ok:
+ tempstring += " " + functions[i] + "_" + str(taglist[i][tags_counter]) + ",\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 },\n"
+ tempstring += " " + functions[i] + "_archs,\n"
+
+ tempstring = strip_trailing(tempstring, ",")
+ tempstring += "};\n"
+ tempstring += emit_epilog();
+
+ return tempstring
+
+
diff --git a/volk/include/volk/make_machines_c.py b/volk/include/volk/make_machines_c.py
new file mode 100644
index 000000000..55c0f1c06
--- /dev/null
+++ b/volk/include/volk/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 <http://www.gnu.org/licenses/>.
+#
+
+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 <volk_common.h>
+#include <volk_typedefs.h>
+#include <volk_machines.h>
+
+volk_machine volk_machines[] = {
+"""
+ for machine in machines:
+ tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n"
+ tempstring += "volk_machine_" + machine
+ tempstring += ","
+ tempstring += "\n#endif\n"
+
+ tempstring += r"""
+};
+
+"""
+
+ for machine in machines:
+ tempstring += "#if LV_MACHINE_" + machine.swapcase() + "\n"
+ tempstring += "#define LV_MACHINE_" + machine.swapcase() + "_CNT 1\n"
+ tempstring += "#else\n"
+ tempstring += "#define LV_MACHINE_" + machine.swapcase() + "_CNT 0\n"
+ tempstring += "#endif\n"
+
+ tempstring += """unsigned int n_volk_machines =
+"""
+ for machine in machines:
+ tempstring += "(LV_MACHINE_" + machine.swapcase() + "_CNT) "
+ tempstring += "+ "
+ tempstring = tempstring[:-2]
+ tempstring += ";\n"
+
+ return tempstring
diff --git a/volk/include/volk/make_machines_h.py b/volk/include/volk/make_machines_h.py
new file mode 100644
index 000000000..68cdf3363
--- /dev/null
+++ b/volk/include/volk/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 <http://www.gnu.org/licenses/>.
+#
+
+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 <volk_common.h>
+#include <volk_typedefs.h>
+
+struct volk_machine {
+ const unsigned int caps; //capabilities (i.e., archs compiled into this machine, in the volk_get_lvarch format)
+ const char *name;
+"""
+ for function in functions:
+ tempstring += "\n const struct volk_func_desc " + function + "_desc;\n"
+ tempstring += " const " + replace_volk.sub("p", function) + " *" + function + "_archs;\n"
+
+ tempstring += r"""};
+
+"""
+ for machine in machines:
+ tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n"
+ tempstring += "extern const struct volk_machine volk_machine_" + machine + ";\n"
+ tempstring += """#endif\n"""
+
+ tempstring += r"""
+#endif //INCLUDED_LIBVOLK_MACHINES_H"""
+
+ return tempstring
diff --git a/volk/include/volk/make_makefile_am.py b/volk/include/volk/make_makefile_am.py
index c44fe11af..1c4c8fe7d 100644
--- a/volk/include/volk/make_makefile_am.py
+++ b/volk/include/volk/make_makefile_am.py
@@ -69,17 +69,16 @@ volk_orc_LIBADD = \
#here be dragons
for machine_name in machines:
tempstring += "if LV_MACHINE_" + machine_name.swapcase() + "\n"
- tempstring += "libvolk_" + machine_name + "_la_LDFLAGS = "
+ tempstring += "libvolk_" + machine_name + "_ar_LDFLAGS = "
for arch in machines[machine_name]:
if archflags_dict[arch] != "none":
tempstring += "-" + archflags_dict[arch] + " "
- tempstring += "\nlibvolk_" + machine_name + "_la_CFLAGS = "
- for arch in machines[machine_name]:
- if archflags_dict[arch] != "none":
- tempstring += "-DLV_HAVE_" + arch.swapcase() + " "
- tempstring += "\nlibvolk_" + machine_name + "_la_SOURCES = $(libvolk_la_SOURCES)"
- tempstring += "\nlibvolk_la_LIBADD = libvolk_" + machine_name + ".la"
+# tempstring += "\nlibvolk_" + machine_name + "_ar_CFLAGS = "
+# for arch in machines[machine_name]:
+# tempstring += "-DLV_HAVE_" + arch.swapcase() + " "
+ tempstring += "\nlibvolk_" + machine_name + "_ar_SOURCES = libvolk_machine_" + machine_name + ".cc"
+ tempstring += "\nlibvolk_la_LIBADD = libvolk_" + machine_name + ".ar"
tempstring += "\nendif\n"
diff --git a/volk/include/volk/make_typedefs.py b/volk/include/volk/make_typedefs.py
index fe81cb2b0..8f9f2b55e 100644
--- a/volk/include/volk/make_typedefs.py
+++ b/volk/include/volk/make_typedefs.py
@@ -16,7 +16,7 @@ def make_typedefs(funclist, retlist, my_argtypelist) :
tempstring = tempstring + '\n';
for i in range(len(funclist)):
- tempstring = tempstring + "typedef " + retlist[i] +" (*" + replace_volk.sub("p", funclist[i]) + ")(" + my_argtypelist[i] + ");\n\n";
+ 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/include/volk/volk_8ic_x2_multiply_conjugate_16ic_a16.h b/volk/include/volk/volk_8ic_x2_multiply_conjugate_16ic_a16.h
index 014f662a3..9e8982e9b 100644
--- a/volk/include/volk/volk_8ic_x2_multiply_conjugate_16ic_a16.h
+++ b/volk/include/volk/volk_8ic_x2_multiply_conjugate_16ic_a16.h
@@ -23,7 +23,6 @@ static inline void volk_8ic_x2_multiply_conjugate_16ic_a16_sse4_1(lv_16sc_t* cVe
const lv_8sc_t* a = aVector;
const lv_8sc_t* b = bVector;
__m128i conjugateSign = _mm_set_epi16(-1, 1, -1, 1, -1, 1, -1, 1);
- const int shuffleMask = _MM_SHUFFLE(2,3,0,1);
for(;number < quarterPoints; number++){
// Convert into 8 bit values into 16 bit values
@@ -37,7 +36,7 @@ static inline void volk_8ic_x2_multiply_conjugate_16ic_a16_sse4_1(lv_16sc_t* cVe
y = _mm_sign_epi16(y, conjugateSign);
// Shift the order of the cr and ci values
- y = _mm_shufflehi_epi16(_mm_shufflelo_epi16(y, shuffleMask ), shuffleMask);
+ y = _mm_shufflehi_epi16(_mm_shufflelo_epi16(y, _MM_SHUFFLE(2,3,0,1) ), _MM_SHUFFLE(2,3,0,1));
// Calculate the ar*(-ci) + cr*(ai)
imagz = _mm_madd_epi16(x,y);
diff --git a/volk/include/volk/volk_8ic_x2_s32f_multiply_conjugate_32fc_a16.h b/volk/include/volk/volk_8ic_x2_s32f_multiply_conjugate_32fc_a16.h
index ccf5eaa9d..fa58ff058 100644
--- a/volk/include/volk/volk_8ic_x2_s32f_multiply_conjugate_32fc_a16.h
+++ b/volk/include/volk/volk_8ic_x2_s32f_multiply_conjugate_32fc_a16.h
@@ -24,7 +24,7 @@ static inline void volk_8ic_x2_s32f_multiply_conjugate_32fc_a16_sse4_1(lv_32fc_t
const lv_8sc_t* a = aVector;
const lv_8sc_t* b = bVector;
__m128i conjugateSign = _mm_set_epi16(-1, 1, -1, 1, -1, 1, -1, 1);
- const int shuffleMask = _MM_SHUFFLE(2,3,0,1);
+
__m128 invScalar = _mm_set_ps1(1.0/scalar);
for(;number < quarterPoints; number++){
@@ -39,7 +39,7 @@ static inline void volk_8ic_x2_s32f_multiply_conjugate_32fc_a16_sse4_1(lv_32fc_t
y = _mm_sign_epi16(y, conjugateSign);
// Shift the order of the cr and ci values
- y = _mm_shufflehi_epi16(_mm_shufflelo_epi16(y, shuffleMask ), shuffleMask);
+ y = _mm_shufflehi_epi16(_mm_shufflelo_epi16(y, _MM_SHUFFLE(2,3,0,1) ), _MM_SHUFFLE(2,3,0,1));
// Calculate the ar*(-ci) + cr*(ai)
imagz = _mm_madd_epi16(x,y);
diff --git a/volk/include/volk/volk_common.h b/volk/include/volk/volk_common.h
index 0218e668c..e050600f0 100644
--- a/volk/include/volk/volk_common.h
+++ b/volk/include/volk/volk_common.h
@@ -1,5 +1,5 @@
-#ifndef INCLUDED_LIBVECTOR_COMMON_H
-#define INCLUDED_LIBVECTOR_COMMON_H
+#ifndef INCLUDED_LIBVOLK_COMMON_H
+#define INCLUDED_LIBVOLK_COMMON_H
#include<inttypes.h>
#ifdef LV_HAVE_MMX
@@ -15,4 +15,9 @@ union bit128{
};
#endif /*LV_HAVE_MMX*/
-#endif /*INCLUDED_LIBVECTOR_COMMON_H*/
+struct volk_func_desc {
+ const char **indices;
+ const int *arch_defs;
+};
+
+#endif /*INCLUDED_LIBVOLK_COMMON_H*/
diff --git a/volk/include/volk/volk_regexp.py b/volk/include/volk/volk_regexp.py
index 7b695cb3b..b83ce5206 100644
--- a/volk/include/volk/volk_regexp.py
+++ b/volk/include/volk/volk_regexp.py
@@ -1,4 +1,5 @@
import re
+import string
remove_after_underscore = re.compile("_.*");
space_remove = re.compile(" ");
@@ -6,3 +7,8 @@ leading_space_remove = re.compile("^ *");
replace_arch = re.compile(", const char\* arch");
replace_bracket = re.compile(" {");
replace_volk = re.compile("volk");
+
+def strip_trailing(tostrip, stripstr):
+ lindex = tostrip.rfind(stripstr)
+ tostrip = tostrip[0:lindex] + string.replace(tostrip[lindex:len(tostrip)], stripstr, "");
+ return tostrip
diff --git a/volk/include/volk/volk_register.py b/volk/include/volk/volk_register.py
index 10610dcfe..9d33abe89 100755
--- a/volk/include/volk/volk_register.py
+++ b/volk/include/volk/volk_register.py
@@ -22,6 +22,9 @@ from make_environment_init_c import make_environment_init_c
from make_environment_init_h import make_environment_init_h
from make_mktables import make_mktables
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
import copy
outfile_set_simd = open("../../config/lv_set_simd_flags.m4", "w");
@@ -41,6 +44,8 @@ outfile_mktables = open("../../lib/volk_mktables.c", "w");
outfile_environment_c = open("../../lib/volk_environment_init.c", "w");
outfile_environment_h = open("volk_environment_init.h", "w");
outfile_makefile_am = open("../../lib/Makefile.am", "w");
+outfile_machines_h = open("volk_machines.h", "w");
+outfile_machines_c = open("../../lib/volk_machines.c", "w");
infile = open("Makefile.am", "r");
@@ -305,3 +310,15 @@ outfile_mktables.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()
+
+for machine in machines:
+ machine_c_filename = "../../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()