diff options
author | Johnathan Corgan | 2011-07-08 17:41:09 -0700 |
---|---|---|
committer | Johnathan Corgan | 2011-07-08 17:41:09 -0700 |
commit | 85477e81354597c40b37b75e5b9eb0af3c3fa4a2 (patch) | |
tree | 4decedcba81b4b2bab2d4c384387dd40e3b8650e /volk/gen | |
parent | 666cd2dd6818fb66e538fa52957f3a23d68e7b94 (diff) | |
parent | 85a8b62ff4b4382e216ea88661fc32c6f30b724f (diff) | |
download | gnuradio-85477e81354597c40b37b75e5b9eb0af3c3fa4a2.tar.gz gnuradio-85477e81354597c40b37b75e5b9eb0af3c3fa4a2.tar.bz2 gnuradio-85477e81354597c40b37b75e5b9eb0af3c3fa4a2.zip |
Merge remote branch 'nick/volk_cmake'
Diffstat (limited to 'volk/gen')
-rw-r--r-- | volk/gen/archs.xml | 17 | ||||
-rw-r--r-- | volk/gen/machines.xml | 5 | ||||
-rw-r--r-- | volk/gen/make_c.py | 4 | ||||
-rw-r--r-- | volk/gen/make_cpuid_c.py | 39 | ||||
-rw-r--r-- | volk/gen/make_each_machine_c.py | 10 | ||||
-rw-r--r-- | volk/gen/make_h.py | 5 | ||||
-rw-r--r-- | volk/gen/make_machines_h.py | 1 | ||||
-rw-r--r-- | volk/gen/volk_register.py | 23 |
8 files changed, 91 insertions, 13 deletions
diff --git a/volk/gen/archs.xml b/volk/gen/archs.xml index 977cc7924..f6822871f 100644 --- a/volk/gen/archs.xml +++ b/volk/gen/archs.xml @@ -7,6 +7,12 @@ <arch name="altivec" type="powerpc"> <flag>maltivec</flag> + <alignment>16</alignment> +</arch> + +<arch name="neon" type="arm"> + <flag>mfpu=neon -mfloat-abi=softfp -funsafe-math-optimizations</flag> + <alignment>16</alignment> </arch> <arch name="32" type="x86" no_test="true" > @@ -31,6 +37,7 @@ <shift>31</shift> <flag>m3dnow</flag> <val>1</val> + <alignment>8</alignment> </arch> <arch name="abm" type="x86"> @@ -39,6 +46,7 @@ <reg>d</reg> <shift>5</shift> <flag>sse4.2</flag> + <alignment>16</alignment> </arch> <arch name="popcount" type="x86"> @@ -55,6 +63,7 @@ <reg>d</reg> <shift>23</shift> <flag>mmmx</flag> + <alignment>8</alignment> </arch> @@ -66,6 +75,7 @@ <flag>msse</flag> <environment>_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);</environment> <include>xmmintrin.h</include> + <alignment>16</alignment> </arch> @@ -75,6 +85,7 @@ <reg>d</reg> <shift>26</shift> <flag>msse2</flag> + <alignment>16</alignment> </arch> <arch name="orc" type="all"> @@ -91,6 +102,7 @@ <flag>msse3</flag> <environment>_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);</environment> <include>pmmintrin.h</include> + <alignment>16</alignment> </arch> <arch name="ssse3" type="x86"> @@ -99,6 +111,7 @@ <reg>c</reg> <shift>9</shift> <flag>mssse3</flag> + <alignment>16</alignment> </arch> <arch name="sse4_a" type="x86"> @@ -107,6 +120,7 @@ <reg>c</reg> <shift>6</shift> <flag>msse4a</flag> + <alignment>16</alignment> </arch> @@ -116,6 +130,7 @@ <reg>c</reg> <shift>19</shift> <flag>msse4.1</flag> + <alignment>16</alignment> </arch> <arch name="sse4_2" type="x86"> @@ -124,6 +139,7 @@ <reg>c</reg> <shift>20</shift> <flag>msse4.2</flag> + <alignment>16</alignment> </arch> <arch name="avx" type="x86"> @@ -132,6 +148,7 @@ <reg>c</reg> <shift>28</shift> <flag>mavx</flag> + <alignment>32</alignment> </arch> </grammar> 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. --> + +<machine name="neon"> +<archs>generic neon</archs> +</machine> + <machine name="sse2_only"> <archs>generic mmx sse sse2</archs> </machine> 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_cpuid_c.py b/volk/gen/make_cpuid_c.py index 2fdbaf304..eb88dcd7f 100644 --- a/volk/gen/make_cpuid_c.py +++ b/volk/gen/make_cpuid_c.py @@ -153,6 +153,45 @@ int i_can_has_%s () { } """ % (arch) + + elif str(domarch.attributes["type"].value) == "arm": + arch = str(domarch.attributes["name"].value); + tempstring = tempstring + """\ +#if defined(__arm__) && defined(__linux__) +#include <asm/hwcap.h> +#include <linux/auxvec.h> +#include <stdio.h> +#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); 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..354e57258 100644 --- a/volk/gen/make_h.py +++ b/volk/gen/make_h.py @@ -21,9 +21,12 @@ 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" + 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]) 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 62ebba3c2..75e5eeb87 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)); @@ -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() |