diff options
Diffstat (limited to 'volk/gen')
-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 |
6 files changed, 39 insertions, 10 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() |