From 8b04d29221719239b52a300a338513f05746ed7f Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Sat, 16 Apr 2011 10:05:43 -0700 Subject: Volk: split n_archs out of arch_defs[0], began to add _manual support --- volk/lib/volk_rank_archs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'volk/lib/volk_rank_archs.c') diff --git a/volk/lib/volk_rank_archs.c b/volk/lib/volk_rank_archs.c index b1a93db26..25ad75cda 100644 --- a/volk/lib/volk_rank_archs.c +++ b/volk/lib/volk_rank_archs.c @@ -1,10 +1,10 @@ #include #include -unsigned int volk_rank_archs(const int* arch_defs, unsigned int arch) { - int i = 2; +unsigned int volk_rank_archs(const int* arch_defs, unsigned int n_archs, unsigned int arch) { + int i = 1; unsigned int best_val = 0; - for(; i < arch_defs[0] + 1; ++i) { + for(; i < n_archs; ++i) { if((arch_defs[i]&(!arch)) == 0) { best_val = (arch_defs[i] > arch_defs[best_val + 1]) ? i-1 : best_val; } -- cgit From e3997ada93a25569a05bbfd615d73d00cee6eca5 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Tue, 10 May 2011 21:52:23 -0700 Subject: Volk: initial profiling support. Profiling works, reading doesn't yet. Need to add name field to volk arch_defs --- volk/lib/volk_rank_archs.c | 59 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'volk/lib/volk_rank_archs.c') diff --git a/volk/lib/volk_rank_archs.c b/volk/lib/volk_rank_archs.c index 25ad75cda..f505abeb6 100644 --- a/volk/lib/volk_rank_archs.c +++ b/volk/lib/volk_rank_archs.c @@ -1,5 +1,60 @@ -#include -#include +#include +#include +#include +#include + +#if defined(_WIN32) +#include +#endif + +void get_config_path(char *path) { + const char *suffix = "/.gnuradio/volk_config"; + memcpy(path, getenv("HOME"), strlen(getenv("HOME"))+1); + strcat(path, suffix); +} + +/* + * ok so volk stuff has to be loaded piecemeal, and to avoid reading + * the whole config file in at startup we should probably create a static + * prefs struct that can be read in by rank_archs with minimal modification. + * this makes rank_archs slower and load_preferences more complex, but + * we don't have to export load_preferences and we don't have to include volk.h. + * means we need to pass the name into rank_archs, though + * problem is that names don't appear anywhere in the volk function descriptor. + * so we have to modify things to include the name in the descriptor. + * + * also means you don't have to also spec the fn name in qa_utils.h/c, you can + * pass it in along with the func_desc + * + */ + +void load_preferences(void) { + static int prefs_loaded = 0; + FILE *config_file; + char path[512], line[512], function[256], arch[64]; + + if(prefs_loaded) return; + + int n_arch_preferences = 0; + + //get the config path + get_config_path(path); + config_file = fopen(path, "r"); + if(!config_file) return; //no prefs found + + while(fgets(line, 512, config_file) != NULL) { + if(sscanf(line, "%s %s", function, arch) == 2 && !strncmp(function, "volk_", 5)) { + printf("func: %s, arch: %s\n", function, arch); + //we have a function and we have an arch, let's set it + n_arch_preferences++; + } + } + + fclose(config_file); + + printf("Found %d prefs\n", n_arch_preferences); + prefs_loaded = 1; +} unsigned int volk_rank_archs(const int* arch_defs, unsigned int n_archs, unsigned int arch) { int i = 1; -- cgit From b50dbc4498842fecd7f0c6adc22f25726f8d27d3 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Wed, 11 May 2011 21:45:03 -0700 Subject: Volk: Profiler is in apps/ now. Added name to function info. Going to C++-ify the whole thing. --- volk/lib/volk_rank_archs.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'volk/lib/volk_rank_archs.c') diff --git a/volk/lib/volk_rank_archs.c b/volk/lib/volk_rank_archs.c index f505abeb6..14f1789da 100644 --- a/volk/lib/volk_rank_archs.c +++ b/volk/lib/volk_rank_archs.c @@ -7,6 +7,8 @@ #include #endif +//this should be used by the profiler app to find the path as well +//possibly all this stuff should go in a separate volk_prefs.cc void get_config_path(char *path) { const char *suffix = "/.gnuradio/volk_config"; memcpy(path, getenv("HOME"), strlen(getenv("HOME"))+1); @@ -25,8 +27,19 @@ void get_config_path(char *path) { * * also means you don't have to also spec the fn name in qa_utils.h/c, you can * pass it in along with the func_desc + * + * your prefs reader should also have a prefs writer which takes a vector of prefs and writes them + * then your profiler can just write the prefs by passing that out * */ + +struct volk_arch_pref { + const char *name; + const char *arch; +}; + +//if we end up with more this will have to use realloc +struct volk_arch_pref volk_arch_prefs[400]; void load_preferences(void) { static int prefs_loaded = 0; @@ -56,7 +69,7 @@ void load_preferences(void) { prefs_loaded = 1; } -unsigned int volk_rank_archs(const int* arch_defs, unsigned int n_archs, unsigned int arch) { +unsigned int volk_rank_archs(const int* arch_defs, unsigned int n_archs, const char* name, unsigned int arch) { int i = 1; unsigned int best_val = 0; for(; i < n_archs; ++i) { -- cgit From 30fdc38d20d4e38908059b6e351c550de5741621 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 12 May 2011 14:21:17 -0700 Subject: Volk: profiling works. loads prefs on init. volk_rank_archs looks in prefs first. --- volk/lib/volk_rank_archs.c | 92 ++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 65 deletions(-) (limited to 'volk/lib/volk_rank_archs.c') diff --git a/volk/lib/volk_rank_archs.c b/volk/lib/volk_rank_archs.c index 14f1789da..1b75af8f4 100644 --- a/volk/lib/volk_rank_archs.c +++ b/volk/lib/volk_rank_archs.c @@ -1,78 +1,40 @@ #include +#include #include #include #include -#if defined(_WIN32) -#include -#endif - -//this should be used by the profiler app to find the path as well -//possibly all this stuff should go in a separate volk_prefs.cc -void get_config_path(char *path) { - const char *suffix = "/.gnuradio/volk_config"; - memcpy(path, getenv("HOME"), strlen(getenv("HOME"))+1); - strcat(path, suffix); -} - -/* - * ok so volk stuff has to be loaded piecemeal, and to avoid reading - * the whole config file in at startup we should probably create a static - * prefs struct that can be read in by rank_archs with minimal modification. - * this makes rank_archs slower and load_preferences more complex, but - * we don't have to export load_preferences and we don't have to include volk.h. - * means we need to pass the name into rank_archs, though - * problem is that names don't appear anywhere in the volk function descriptor. - * so we have to modify things to include the name in the descriptor. - * - * also means you don't have to also spec the fn name in qa_utils.h/c, you can - * pass it in along with the func_desc - * - * your prefs reader should also have a prefs writer which takes a vector of prefs and writes them - * then your profiler can just write the prefs by passing that out - * - */ - -struct volk_arch_pref { - const char *name; - const char *arch; -}; - -//if we end up with more this will have to use realloc -struct volk_arch_pref volk_arch_prefs[400]; - -void load_preferences(void) { - static int prefs_loaded = 0; - FILE *config_file; - char path[512], line[512], function[256], arch[64]; - - if(prefs_loaded) return; - - int n_arch_preferences = 0; - - //get the config path - get_config_path(path); - config_file = fopen(path, "r"); - if(!config_file) return; //no prefs found - - while(fgets(line, 512, config_file) != NULL) { - if(sscanf(line, "%s %s", function, arch) == 2 && !strncmp(function, "volk_", 5)) { - printf("func: %s, arch: %s\n", function, arch); - //we have a function and we have an arch, let's set it - n_arch_preferences++; +unsigned int get_index(const char *indices[], unsigned int n_archs, const char *arch_name) { + int i; + for(i=0; i arch_defs[best_val + 1]) ? i-1 : best_val; } -- cgit From c21132e07100c62182a27a8e282cb72463dd2963 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 12 May 2011 14:50:48 -0700 Subject: Volk: actually return the preferred arch --- volk/lib/volk_rank_archs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'volk/lib/volk_rank_archs.c') diff --git a/volk/lib/volk_rank_archs.c b/volk/lib/volk_rank_archs.c index 1b75af8f4..e10433fd0 100644 --- a/volk/lib/volk_rank_archs.c +++ b/volk/lib/volk_rank_archs.c @@ -30,7 +30,7 @@ unsigned int volk_rank_archs(const char *indices[], const int* arch_defs, unsign //now look for the function name in the prefs list for(i=0; i < n_arch_prefs; i++) { if(!strncmp(name, volk_arch_prefs[i].name, 128)) { //found it - best_val = get_index(indices, n_archs, volk_arch_prefs[i].arch); + return get_index(indices, n_archs, volk_arch_prefs[i].arch); } } -- cgit