26 #define BENCHMARK_EXAMPLES 52 std::string command_line(
int argc,
char **argv)
55 for(
int i = 0; i < argc; i++)
66 static std::unique_ptr<Example> g_example =
nullptr;
67 static std::vector<char *> g_example_argv = {};
71 ExampleTest() =
default;
72 void do_setup()
override 75 _is_setup = g_example->do_setup(g_example_argv.size(), &g_example_argv[0]);
77 void do_run()
override 84 void do_teardown()
override 88 g_example->do_teardown();
94 bool _is_setup{
false };
97 int run_example(
int argc,
char **argv, std::unique_ptr<Example> example)
102 example_args->
set_help(
"Arguments to pass to the example separated by commas (e.g: arg0,arg1,arg2)");
105 parser.
parse(argc, argv);
113 std::vector<std::unique_ptr<framework::Printer>> printers = options.
create_printers();
114 g_example = std::move(example);
115 g_example_argv.clear();
116 g_example_argv.emplace_back(argv[0]);
117 for(
auto &arg : example_args->value())
119 g_example_argv.emplace_back(const_cast<char *>(arg.c_str()));
124 for(
auto &p : printers)
126 p->print_global_header();
130 #ifdef ARM_COMPUTE_CL 143 for(
auto &p : printers)
146 p->print_entry(
"CommandLine", command_line(argc, argv));
147 #ifdef ARM_COMPUTE_CL 154 p->print_entry(
"CL_DEVICE_VERSION",
"Unavailable");
166 framework.
init(fconfig);
168 for(
auto &p : printers)
181 bool success = framework.
run();
184 for(
auto &p : printers)
186 p->print_global_footer();
190 return (success ? 0 : 1);
Framework configuration structure.
arm_compute::utils::ToggleOption * help
Show help option.
int run_example(int argc, char **argv, std::unique_ptr< ValidateExample > example)
Run an example and handle the potential exceptions it throws.
int num_iterations
Number of iterations per test.
static CLScheduler & get()
Access the scheduler singleton.
void default_init_with_context(cl::Device &device, cl::Context &ctx, ICLTuner *cl_tuner=nullptr, CLGEMMHeuristicsHandle *gemm_h=nullptr)
Initialises the scheduler with context and device provided by the user.
std::string to_string(T &&value)
Convert integer and float values to string.
void set_throw_errors(bool throw_errors)
Set whether errors are caught or thrown by the framework.
const std::vector< T > & value() const
Get the values of the option.
void add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status)
Add a test case to the framework.
std::stringstream ss(mlgo_str)
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
std::tuple< cl::Context, cl::Device, cl_int > create_opencl_context_and_device()
This function creates an OpenCL context and a device.
Class to parse command line arguments.
Copyright (c) 2017-2021 Arm Limited.
Implementation of an option that accepts any number of values.
static Framework & get()
Access to the singleton.
T * add_option(const std::string &name, As &&... args)
Function to add a new option to the parser.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
LogLevel log_level
Verbosity of the output.
bool run()
Run all enabled test cases.
void parse(int argc, char **argv)
Parses the command line arguments and updates the options accordingly.
std::vector< framework::InstrumentsDescription > instruments
Instrument types that will be used for benchmarking.
std::vector< std::unique_ptr< Printer > > create_printers()
Create the printers based on parsed command line options.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
const T & value() const
Get the option value.
Abstract test case class.
Helper class to statically begin and end a test suite.
arm_compute::utils::SimpleOption< int > * iterations
Number of iterations option.
arm_compute::utils::EnumListOption< InstrumentsDescription > * instruments
Instruments option.
Handle for loading and retrieving GEMM heuristics.
arm_compute::utils::EnumOption< LogLevel > * log_level
Logging level option.
std::string build_information()
Returns the arm_compute library build information.
Interface to enqueue GLES kernels and get/set the GLES CommandQueue.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
void add_printer(Printer *printer)
Set the printer used for the output of test results.
bool is_set() const
Has a value been assigned to the option?
void print_help(const std::string &program_name) const
Prints a help message for all configured options.
const T & value() const
Get the selected value.
Common command line options used to configure the framework.
void set_help(std::string help)
Set the help message for the option.
void init(const FrameworkConfig &config)
Init the framework.
bool opencl_is_available()
Check if OpenCL is available.
arm_compute::utils::ToggleOption * throw_errors
Throw errors option.