summaryrefslogtreecommitdiff
path: root/volk/tmpl
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-04-15 17:32:38 -0700
committerJosh Blum <josh@joshknows.com>2012-04-19 18:12:55 -0700
commit95e91b44d2ef3535129c0a402c51bc56cfd74d06 (patch)
treebfd183e0494cb1ea7b5cf87c9319dd7a5c061aaf /volk/tmpl
parenteccc86fbb8aa0392307bfdf1bd802e4394868334 (diff)
volk: created other templates for runtime + machines
Diffstat (limited to 'volk/tmpl')
-rw-r--r--volk/tmpl/volk.tmpl.c92
-rw-r--r--volk/tmpl/volk.tmpl.h48
-rw-r--r--volk/tmpl/volk_machine_xxx.tmpl.c88
-rw-r--r--volk/tmpl/volk_machines.tmpl.c34
-rw-r--r--volk/tmpl/volk_machines.tmpl.h51
-rw-r--r--volk/tmpl/volk_typedefs.tmpl.h2
6 files changed, 314 insertions, 1 deletions
diff --git a/volk/tmpl/volk.tmpl.c b/volk/tmpl/volk.tmpl.c
new file mode 100644
index 0000000000..161f49a433
--- /dev/null
+++ b/volk/tmpl/volk.tmpl.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2011-2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <volk/volk_common.h>
+#include "volk_machines.h"
+#include <volk/volk_typedefs.h>
+#include <volk/volk_cpu.h>
+#include "volk_rank_archs.h"
+#include <volk/volk.h>
+#include <stdio.h>
+#include <string.h>
+
+struct volk_machine *get_machine(void) {
+ extern struct volk_machine *volk_machines[];
+ extern unsigned int n_volk_machines;
+ static struct volk_machine *machine = NULL;
+
+ if(machine != NULL) return machine;
+ else {
+ unsigned int max_score = 0;
+ unsigned int i;
+ for(i=0; i<n_volk_machines; i++) {
+ if(!(volk_machines[i]->caps & (~volk_get_lvarch()))) {
+ if(volk_machines[i]->caps > max_score) {
+ max_score = volk_machines[i]->caps;
+ machine = volk_machines[i];
+ }
+ }
+ }
+ printf("Using Volk machine: %s\n", machine->name);
+ return machine;
+ }
+}
+
+unsigned int volk_get_alignment(void) {
+ return get_machine()->alignment;
+}
+
+#for $kern in $kernels
+
+void get_$(kern.name)($kern.arglist_defs) {
+ $kern.name = get_machine()->$(kern.name)_archs[volk_rank_archs(
+ get_machine()->$(kern.name)_indices,
+ get_machine()->$(kern.name)_arch_defs,
+ get_machine()->$(kern.name)_n_archs,
+ get_machine()->$(kern.name)_name,
+ volk_get_lvarch()
+ )];
+ $(kern.name)($kern.arglist_names);
+}
+
+$kern.pname $kern.name = &get_$(kern.name);
+
+void $(kern.name)_manual($kern.arglist_defs, const char* arch) {
+ const size_t index = get_index(
+ get_machine()->$(kern.name)_indices,
+ get_machine()->$(kern.name)_n_archs,
+ arch
+ );
+ get_machine()->$(kern.name)_archs[index](
+ $kern.arglist_names
+ );
+}
+
+struct volk_func_desc volk_32f_x2_add_32f_a_get_func_desc(void) {
+ struct volk_func_desc desc = {
+ get_machine()->$(kern.name)_indices,
+ get_machine()->$(kern.name)_arch_defs,
+ get_machine()->$(kern.name)_n_archs
+ };
+ return desc;
+}
+
+#end for
diff --git a/volk/tmpl/volk.tmpl.h b/volk/tmpl/volk.tmpl.h
new file mode 100644
index 0000000000..161579e46d
--- /dev/null
+++ b/volk/tmpl/volk.tmpl.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011-2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_VOLK_RUNTIME
+#define INCLUDED_VOLK_RUNTIME
+
+#include <volk/volk_typedefs.h>
+#include <volk/volk_config_fixed.h>
+#include <volk/volk_common.h>
+#include <volk/volk_complex.h>
+
+__VOLK_DECL_BEGIN
+
+struct volk_func_desc {
+ const char **indices;
+ const int *arch_defs;
+ const int n_archs;
+};
+
+VOLK_API unsigned int volk_get_alignment(void);
+
+#for $kern in $kernels
+extern VOLK_API $kern.pname $kern.name;
+extern VOLK_API void $(kern.name)_manual($kern.arglist_namedefs, const char* arch);
+extern VOLK_API struct volk_func_desc $(kern.name)_get_func_desc(void);
+#end for
+
+__VOLK_DECL_END
+
+#endif /*INCLUDED_VOLK_RUNTIME*/
diff --git a/volk/tmpl/volk_machine_xxx.tmpl.c b/volk/tmpl/volk_machine_xxx.tmpl.c
new file mode 100644
index 0000000000..57e652e4c2
--- /dev/null
+++ b/volk/tmpl/volk_machine_xxx.tmpl.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2011-2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#set $this_machine = $machine_dict[$which]
+
+#for $arch in $this_machine.archs
+#define LV_HAVE_$(arch.name.upper()) 1
+#end for
+
+#include <volk/volk_common.h>
+#include "volk_machines.h"
+#include <volk/volk_config_fixed.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#for $kern in $kernels
+#include <volk/$(kern.name).h>
+#end for
+
+########################################################################
+#def make_arch_have_list($archs)
+$(' | '.join(['(1 << LV_%s)'%a.name.upper() for a in $archs]))#slurp
+#end def
+
+########################################################################
+#def make_tag_str_list($tags)
+{$(', '.join(['"%s"'%a for a in $tags]))}#slurp
+#end def
+
+########################################################################
+#def make_tag_have_list($deps)
+{$(', '.join([' | '.join(['(1 << LV_%s)'%a.upper() for a in d]) for d in $deps]))}#slurp
+#end def
+
+########################################################################
+#def make_tag_kern_list($name, $tags)
+{$(', '.join(['%s_%s'%($name, a) for a in $tags]))}#slurp
+#end def
+
+#ifdef LV_HAVE_ORC
+struct volk_machine volk_machine_generic = {
+ $make_arch_have_list($this_machine.archs) | (1 << LV_ORC),
+ "$this_machine.name",
+ $this_machine.alignment,
+ #for $kern in $kernels
+ "$kern.name",
+ $make_tag_str_list($kern.taglist),
+ $make_tag_have_list($kern.tagdeps),
+ $make_tag_kern_list($kern.name, $kern.taglist),
+ $(len($kern.taglist)),
+ #end for
+};
+
+#else
+struct volk_machine volk_machine_generic = {
+ $make_arch_have_list($this_machine.archs),
+ "$this_machine.name",
+ $this_machine.alignment,
+ #for $kern in $kernels
+ "$kern.name",
+ $make_tag_str_list($kern.taglist),
+ $make_tag_have_list($kern.tagdeps),
+ $make_tag_kern_list($kern.name, $kern.taglist),
+ $(len($kern.taglist)),
+ #end for
+};
+
+#endif
diff --git a/volk/tmpl/volk_machines.tmpl.c b/volk/tmpl/volk_machines.tmpl.c
new file mode 100644
index 0000000000..57dd03c985
--- /dev/null
+++ b/volk/tmpl/volk_machines.tmpl.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011-2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <volk/volk_common.h>
+#include <volk/volk_typedefs.h>
+#include "volk_machines.h"
+
+struct volk_machine *volk_machines[] = {
+#for $machine in $machines
+#ifdef LV_MACHINE_$(machine.name.upper())
+&volk_machine_$(machine.name),
+#endif
+#end for
+};
+
+unsigned int n_volk_machines = sizeof(volk_machines)/sizeof(*volk_machines);
diff --git a/volk/tmpl/volk_machines.tmpl.h b/volk/tmpl/volk_machines.tmpl.h
new file mode 100644
index 0000000000..b30e600ed8
--- /dev/null
+++ b/volk/tmpl/volk_machines.tmpl.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011-2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_LIBVOLK_MACHINES_H
+#define INCLUDED_LIBVOLK_MACHINES_H
+
+#include <volk/volk_common.h>
+#include <volk/volk_typedefs.h>
+
+__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 $kern in $kernels
+ const char *$(kern.name)_name;
+ const char *$(kern.name)_indices[$(len($archs))];
+ const int $(kern.name)_arch_defs[$(len($archs))];
+ const $(kern.pname) $(kern.name)_archs[$(len($archs))];
+ const int $(kern.name)_n_archs;
+ #end for
+};
+
+#for $machine in $machines
+#ifdef LV_MACHINE_$(machine.name.upper())
+extern struct volk_machine volk_machine_$(machine.name);
+#endif
+#end for
+
+__VOLK_DECL_END
+
+#endif //INCLUDED_LIBVOLK_MACHINES_H
diff --git a/volk/tmpl/volk_typedefs.tmpl.h b/volk/tmpl/volk_typedefs.tmpl.h
index 947cb9ed5d..2577df14e8 100644
--- a/volk/tmpl/volk_typedefs.tmpl.h
+++ b/volk/tmpl/volk_typedefs.tmpl.h
@@ -26,7 +26,7 @@
#include <volk/volk_complex.h>
#for $kern in $kernels
-typedef $kern.rettype (*$(kern.name.replace('volk_', 'p_')))($kern.arglist);
+typedef $kern.rettype (*$(kern.pname))($kern.arglist);
#end for
#endif /*INCLUDED_VOLK_TYPEDEFS*/