From 95e91b44d2ef3535129c0a402c51bc56cfd74d06 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 15 Apr 2012 17:32:38 -0700 Subject: volk: created other templates for runtime + machines --- volk/tmpl/volk.tmpl.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 volk/tmpl/volk.tmpl.c (limited to 'volk/tmpl/volk.tmpl.c') diff --git a/volk/tmpl/volk.tmpl.c b/volk/tmpl/volk.tmpl.c new file mode 100644 index 000000000..161f49a43 --- /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 +#include "volk_machines.h" +#include +#include +#include "volk_rank_archs.h" +#include +#include +#include + +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; icaps & (~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 -- cgit From 37f9a62fd45ece1e6a92769fbb1798403c86ba9b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 15 Apr 2012 19:11:52 -0700 Subject: volk: working build w/ cmakelists --- volk/tmpl/volk.tmpl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'volk/tmpl/volk.tmpl.c') diff --git a/volk/tmpl/volk.tmpl.c b/volk/tmpl/volk.tmpl.c index 161f49a43..c3a1544ff 100644 --- a/volk/tmpl/volk.tmpl.c +++ b/volk/tmpl/volk.tmpl.c @@ -56,7 +56,7 @@ unsigned int volk_get_alignment(void) { #for $kern in $kernels -void get_$(kern.name)($kern.arglist_defs) { +void get_$(kern.name)($kern.arglist_namedefs) { $kern.name = get_machine()->$(kern.name)_archs[volk_rank_archs( get_machine()->$(kern.name)_indices, get_machine()->$(kern.name)_arch_defs, @@ -69,7 +69,7 @@ void get_$(kern.name)($kern.arglist_defs) { $kern.pname $kern.name = &get_$(kern.name); -void $(kern.name)_manual($kern.arglist_defs, const char* arch) { +void $(kern.name)_manual($kern.arglist_namedefs, const char* arch) { const size_t index = get_index( get_machine()->$(kern.name)_indices, get_machine()->$(kern.name)_n_archs, @@ -80,7 +80,7 @@ void $(kern.name)_manual($kern.arglist_defs, const char* arch) { ); } -struct volk_func_desc volk_32f_x2_add_32f_a_get_func_desc(void) { +struct volk_func_desc $(kern.name)_get_func_desc(void) { struct volk_func_desc desc = { get_machine()->$(kern.name)_indices, get_machine()->$(kern.name)_arch_defs, -- cgit