Skip to content

Commit

Permalink
shadow: rebase volk_profile fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemel committed Apr 10, 2020
1 parent 15bbbb9 commit 360acdb
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 93 deletions.
141 changes: 83 additions & 58 deletions apps/volk_option_helpers.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
//
// Created by nathan on 2/1/18.
//
/* -*- c++ -*- */
/*
* Copyright 2018-2020 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_option_helpers.h"

Expand All @@ -14,68 +33,74 @@
/*
* Option type
*/
option_t::option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)())
: longform("--" + longform), shortform("-" + shortform), msg(msg), callback(callback)
option_t::option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)())
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
callback(t_callback)
{
option_type = VOID_CALLBACK;
}

option_t::option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)(int))
: longform("--" + longform),
shortform("-" + shortform),
msg(msg),
callback((void (*)())callback)
option_t::option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)(int))
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
callback((void (*)())t_callback)
{
option_type = INT_CALLBACK;
}

option_t::option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)(float))
: longform("--" + longform),
shortform("-" + shortform),
msg(msg),
callback((void (*)())callback)
option_t::option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)(float))
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
callback((void (*)())t_callback)
{
option_type = FLOAT_CALLBACK;
}

option_t::option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)(bool))
: longform("--" + longform),
shortform("-" + shortform),
msg(msg),
callback((void (*)())callback)
option_t::option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)(bool))
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
callback((void (*)())t_callback)
{
option_type = BOOL_CALLBACK;
}

option_t::option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)(std::string))
: longform("--" + longform),
shortform("-" + shortform),
msg(msg),
callback((void (*)())callback)
option_t::option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)(std::string))
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
callback((void (*)())t_callback)
{
option_type = STRING_CALLBACK;
}

option_t::option_t(std::string longform,
std::string shortform,
std::string msg,
std::string printval)
: longform("--" + longform), shortform("-" + shortform), msg(msg), printval(printval)
option_t::option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
std::string t_printval)
: longform("--" + t_longform),
shortform("-" + t_shortform),
msg(t_msg),
printval(t_printval)
{
option_type = STRING;
}
Expand All @@ -85,29 +110,29 @@ option_t::option_t(std::string longform,
* Option List
*/

option_list::option_list(std::string program_name) : program_name(program_name)
option_list::option_list(std::string program_name) : d_program_name(program_name)
{
internal_list = std::vector<option_t>();
d_internal_list = std::vector<option_t>();
}


void option_list::add(option_t opt) { internal_list.push_back(opt); }
void option_list::add(option_t opt) { d_internal_list.push_back(opt); }

void option_list::parse(int argc, char** argv)
{
for (int arg_number = 0; arg_number < argc; ++arg_number) {
for (std::vector<option_t>::iterator this_option = internal_list.begin();
this_option != internal_list.end();
for (std::vector<option_t>::iterator this_option = d_internal_list.begin();
this_option != d_internal_list.end();
this_option++) {
int int_val = INT_MIN;
if (this_option->longform == std::string(argv[arg_number]) ||
this_option->shortform == std::string(argv[arg_number])) {

if (present_options.count(this_option->longform) == 0) {
present_options.insert(
if (d_present_options.count(this_option->longform) == 0) {
d_present_options.insert(
std::pair<std::string, int>(this_option->longform, 1));
} else {
present_options[this_option->longform] += 1;
d_present_options[this_option->longform] += 1;
}
switch (this_option->option_type) {
case VOID_CALLBACK:
Expand Down Expand Up @@ -184,15 +209,15 @@ void option_list::parse(int argc, char** argv)
}
if (std::string("--help") == std::string(argv[arg_number]) ||
std::string("-h") == std::string(argv[arg_number])) {
present_options.insert(std::pair<std::string, int>("--help", 1));
d_present_options.insert(std::pair<std::string, int>("--help", 1));
help();
}
}
}

bool option_list::present(std::string option_name)
{
if (present_options.count("--" + option_name)) {
if (d_present_options.count("--" + option_name)) {
return true;
} else {
return false;
Expand All @@ -201,10 +226,10 @@ bool option_list::present(std::string option_name)

void option_list::help()
{
std::cout << program_name << std::endl;
std::cout << d_program_name << std::endl;
std::cout << " -h [ --help ] \t\tdisplay this help message" << std::endl;
for (std::vector<option_t>::iterator this_option = internal_list.begin();
this_option != internal_list.end();
for (std::vector<option_t>::iterator this_option = d_internal_list.begin();
this_option != d_internal_list.end();
this_option++) {
std::string help_line(" ");
if (this_option->shortform == "-") {
Expand Down
78 changes: 48 additions & 30 deletions apps/volk_option_helpers.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
//
// Created by nathan on 2/1/18.
//
/* -*- c++ -*- */
/*
* Copyright 2018-2020 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 VOLK_VOLK_OPTION_HELPERS_H
#define VOLK_VOLK_OPTION_HELPERS_H
Expand All @@ -23,30 +41,30 @@ typedef enum {
class option_t
{
public:
option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)());
option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)(int));
option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)(float));
option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)(bool));
option_t(std::string longform,
std::string shortform,
std::string msg,
void (*callback)(std::string));
option_t(std::string longform,
std::string shortform,
std::string msg,
std::string printval);
option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)());
option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)(int));
option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)(float));
option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)(bool));
option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
void (*t_callback)(std::string));
option_t(std::string t_longform,
std::string t_shortform,
std::string t_msg,
std::string t_printval);

std::string longform;
std::string shortform;
Expand All @@ -69,9 +87,9 @@ class option_list
void help();

private:
std::string program_name;
std::vector<option_t> internal_list;
std::map<std::string, int> present_options;
std::string d_program_name;
std::vector<option_t> d_internal_list;
std::map<std::string, int> d_present_options;
};


Expand Down
8 changes: 4 additions & 4 deletions apps/volk_profile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ void read_results(std::vector<volk_test_results_t>* results, std::string path)
found = 127;
}
str_size = config_str.size();
char buffer[128] = { '\0' };
config_str.copy(buffer, found + 1, 0);
buffer[found] = '\0';
single_kernel_result.push_back(std::string(buffer));
char line_buffer[128] = { '\0' };
config_str.copy(line_buffer, found + 1, 0);
line_buffer[found] = '\0';
single_kernel_result.push_back(std::string(line_buffer));
config_str.erase(0, found + 1);
}

Expand Down
22 changes: 21 additions & 1 deletion apps/volk_profile.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@

/* -*- c++ -*- */
/*
* Copyright 2012-2014 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 <stdbool.h> // for bool
#include <iosfwd> // for ofstream
Expand Down

0 comments on commit 360acdb

Please sign in to comment.