summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--volk/include/volk/make_c.py9
-rw-r--r--volk/include/volk/make_each_machine_c.py2
-rw-r--r--volk/include/volk/make_registry.py33
-rw-r--r--volk/include/volk/volk_common.h1
-rw-r--r--volk/lib/volk_rank_archs.c6
-rw-r--r--volk/lib/volk_rank_archs.h2
6 files changed, 32 insertions, 21 deletions
diff --git a/volk/include/volk/make_c.py b/volk/include/volk/make_c.py
index 7cb0616c8..1129285bb 100644
--- a/volk/include/volk/make_c.py
+++ b/volk/include/volk/make_c.py
@@ -68,11 +68,18 @@ struct volk_machine *get_machine(void) {
}
}
+static unsigned int get_index(const char **indices, char *arch_name) {
+
+
+
+
+}
+
"""
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, volk_get_lvarch())];\n" % (functions[i], functions[i], functions[i])
+ 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(%s);\n}\n\n" % (functions[i], my_arglist[i])
tempstring += replace_volk.sub("p", functions[i]) + " " + functions[i] + " = &get_" + functions[i] + ";\n\n"
diff --git a/volk/include/volk/make_each_machine_c.py b/volk/include/volk/make_each_machine_c.py
index 866e18bc3..11f669566 100644
--- a/volk/include/volk/make_each_machine_c.py
+++ b/volk/include/volk/make_each_machine_c.py
@@ -71,7 +71,7 @@ def make_each_machine_c(machine_name, archs, functions, fcountlist, taglist):
tempstring += " name,\n"
for i in range(len(functions)):
- tempstring += " { " + functions[i] + "_indices, " + functions[i] + "_arch_defs },\n"
+ tempstring += " { " + functions[i] + "_indices, " + functions[i] + "_arch_defs, " + functions[i] + "_n_archs },\n"
tempstring += " " + functions[i] + "_archs,\n"
tempstring = strip_trailing(tempstring, ",")
diff --git a/volk/include/volk/make_registry.py b/volk/include/volk/make_registry.py
index 7fbe9a8b0..de1f46aa6 100644
--- a/volk/include/volk/make_registry.py
+++ b/volk/include/volk/make_registry.py
@@ -1,5 +1,6 @@
from xml.dom import minidom
from emit_omnilog import *
+from volk_regexp import *
import string
def make_registry(dom, funclist, fcountlist, taglist) :
@@ -39,24 +40,13 @@ def make_registry(dom, funclist, fcountlist, taglist) :
tempstring = tempstring + "\n \"" + str(taglist[i][tags_counter]) + "\",\n#endif\n";
tags_counter = tags_counter + 1;
- lindex = tempstring.rfind(",");
- tempstring = tempstring[0:lindex] + string.replace(tempstring[lindex:len(tempstring)], ",", "");
+ tempstring = strip_trailing(tempstring, ",")
tempstring = tempstring + "};\n\n";
for fcount in fcountlist:
tempstring = tempstring + "static const int " + funclist[counter] + "_arch_defs[] = {\n";
- counter = 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 + ") + ";
- lindex = tempstring.rfind(" + ");
- tempstring = tempstring[0:lindex] + string.replace(tempstring[lindex:len(tempstring)], " + ", "");
- tempstring = tempstring + ",\n"
+ counter += 1;
for arch_list in fcount:
tempstring = tempstring + "#if defined(LV_HAVE_"
for ind in range(len(arch_list)):
@@ -70,9 +60,22 @@ def make_registry(dom, funclist, fcountlist, taglist) :
if ind < len(arch_list) - 1:
tempstring = tempstring + ") + (1 << LV_"
tempstring = tempstring + "),\n#endif\n"
- lindex = tempstring.rfind(",");
- tempstring = tempstring[0:lindex] + string.replace(tempstring[lindex:len(tempstring)], ",", "");
+ 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();
diff --git a/volk/include/volk/volk_common.h b/volk/include/volk/volk_common.h
index e050600f0..0a47ff864 100644
--- a/volk/include/volk/volk_common.h
+++ b/volk/include/volk/volk_common.h
@@ -18,6 +18,7 @@ union bit128{
struct volk_func_desc {
const char **indices;
const int *arch_defs;
+ const int n_archs;
};
#endif /*INCLUDED_LIBVOLK_COMMON_H*/
diff --git a/volk/lib/volk_rank_archs.c b/volk/lib/volk_rank_archs.c
index b1a93db26..25ad75cda 100644
--- a/volk/lib/volk_rank_archs.c
+++ b/volk/lib/volk_rank_archs.c
@@ -1,10 +1,10 @@
#include<volk_rank_archs.h>
#include<stdio.h>
-unsigned int volk_rank_archs(const int* arch_defs, unsigned int arch) {
- int i = 2;
+unsigned int volk_rank_archs(const int* arch_defs, unsigned int n_archs, unsigned int arch) {
+ int i = 1;
unsigned int best_val = 0;
- for(; i < arch_defs[0] + 1; ++i) {
+ for(; i < n_archs; ++i) {
if((arch_defs[i]&(!arch)) == 0) {
best_val = (arch_defs[i] > arch_defs[best_val + 1]) ? i-1 : best_val;
}
diff --git a/volk/lib/volk_rank_archs.h b/volk/lib/volk_rank_archs.h
index 26b9f7503..8fa0631ee 100644
--- a/volk/lib/volk_rank_archs.h
+++ b/volk/lib/volk_rank_archs.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-unsigned int volk_rank_archs(const int* arch_defs, unsigned int arch);
+unsigned int volk_rank_archs(const int* arch_defs, unsigned int n_archs, unsigned int arch);
#ifdef __cplusplus