diff options
author | Nick Foster | 2011-05-18 18:03:26 -0700 |
---|---|---|
committer | Nick Foster | 2011-05-18 18:03:26 -0700 |
commit | 3a41b3208e222965e908c6a04e3ab05379c782c4 (patch) | |
tree | 4dcc39d3d7a765aa347a6d34bb2c6464fdb8fe17 | |
parent | c80e7b00de836a388013a002008c7256481414cb (diff) | |
download | gnuradio-3a41b3208e222965e908c6a04e3ab05379c782c4.tar.gz gnuradio-3a41b3208e222965e908c6a04e3ab05379c782c4.tar.bz2 gnuradio-3a41b3208e222965e908c6a04e3ab05379c782c4.zip |
Volk: added alignment prop to each machine. call volk_get_alignment() to get your machine's reqd alignment for malloc.
-rw-r--r-- | volk/gen/archs.xml | 12 | ||||
-rw-r--r-- | volk/gen/make_c.py | 4 | ||||
-rw-r--r-- | volk/gen/make_each_machine_c.py | 10 | ||||
-rw-r--r-- | volk/gen/make_h.py | 3 | ||||
-rw-r--r-- | volk/gen/make_machines_h.py | 1 | ||||
-rw-r--r-- | volk/gen/volk_register.py | 19 | ||||
-rw-r--r-- | volk/lib/qa_utils.cc | 3 |
7 files changed, 41 insertions, 11 deletions
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 @@ <arch name="altivec" type="powerpc"> <flag>maltivec</flag> + <alignment>16</alignment> </arch> <arch name="32" type="x86" no_test="true" > @@ -31,6 +32,7 @@ <shift>31</shift> <flag>m3dnow</flag> <val>1</val> + <alignment>8</alignment> </arch> <arch name="abm" type="x86"> @@ -39,6 +41,7 @@ <reg>d</reg> <shift>5</shift> <flag>sse4.2</flag> + <alignment>16</alignment> </arch> <arch name="popcount" type="x86"> @@ -55,6 +58,7 @@ <reg>d</reg> <shift>23</shift> <flag>mmmx</flag> + <alignment>8</alignment> </arch> @@ -66,6 +70,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 +80,7 @@ <reg>d</reg> <shift>26</shift> <flag>msse2</flag> + <alignment>16</alignment> </arch> <arch name="orc" type="all"> @@ -91,6 +97,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 +106,7 @@ <reg>c</reg> <shift>9</shift> <flag>mssse3</flag> + <alignment>16</alignment> </arch> <arch name="sse4_a" type="x86"> @@ -107,6 +115,7 @@ <reg>c</reg> <shift>6</shift> <flag>msse4a</flag> + <alignment>16</alignment> </arch> @@ -116,6 +125,7 @@ <reg>c</reg> <shift>19</shift> <flag>msse4.1</flag> + <alignment>16</alignment> </arch> <arch name="sse4_2" type="x86"> @@ -124,6 +134,7 @@ <reg>c</reg> <shift>20</shift> <flag>msse4.2</flag> + <alignment>16</alignment> </arch> <arch name="avx" type="x86"> @@ -132,6 +143,7 @@ <reg>c</reg> <shift>28</shift> <flag>mavx</flag> + <alignment>32</alignment> </arch> </grammar> 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() diff --git a/volk/lib/qa_utils.cc b/volk/lib/qa_utils.cc index db606a472..7f86dd78b 100644 --- a/volk/lib/qa_utils.cc +++ b/volk/lib/qa_utils.cc @@ -233,7 +233,8 @@ bool icompare(t *in1, t *in2, unsigned int vlen, unsigned int tol) { class volk_qa_aligned_mem_pool{ public: - void *get_new(size_t size, size_t alignment = 32){ + void *get_new(size_t size){ + size_t alignment = volk_get_alignment(); _mems.push_back(std::vector<char>(size + alignment-1, 0)); size_t ptr = size_t(&_mems.back().front()); return (void *)((ptr + alignment-1) & ~(alignment-1)); |