24 #include "utils/Utils.h" 26 #define BENCHMARK_EXAMPLES 49 std::string command_line(
int argc,
char **argv)
52 for(
int i = 0; i < argc; i++)
63 static std::unique_ptr<Example> g_example =
nullptr;
64 static std::vector<char *> g_example_argv = {};
68 ExampleTest() =
default;
69 void do_setup()
override 72 _is_setup = g_example->do_setup(g_example_argv.size(), &g_example_argv[0]);
74 void do_run()
override 81 void do_teardown()
override 85 g_example->do_teardown();
91 bool _is_setup{
false };
94 int run_example(
int argc,
char **argv, std::unique_ptr<Example> example)
99 example_args->
set_help(
"Arguments to pass to the example separated by commas (e.g: arg0,arg1,arg2)");
102 parser.
parse(argc, argv);
110 std::vector<std::unique_ptr<framework::Printer>> printers = options.
create_printers();
111 g_example = std::move(example);
112 g_example_argv.clear();
113 g_example_argv.emplace_back(argv[0]);
114 for(
auto &arg : example_args->value())
116 g_example_argv.emplace_back(const_cast<char *>(arg.c_str()));
121 for(
auto &p : printers)
123 p->print_global_header();
127 #ifdef ARM_COMPUTE_CL 132 for(
auto &arg : example_args->value())
134 if(arg.find(
"--target=clvk") != std::string::npos)
150 for(
auto &p : printers)
153 p->print_entry(
"CommandLine", command_line(argc, argv));
154 #ifdef ARM_COMPUTE_CL 161 p->print_entry(
"CL_DEVICE_VERSION",
"Unavailable");
173 framework.
init(fconfig);
175 for(
auto &p : printers)
188 bool success = framework.
run();
191 for(
auto &p : printers)
193 p->print_global_footer();
197 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(CLBackendType cl_backend_type)
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.
CLBackendType
List the possible OpenCL backends.
arm_compute::utils::EnumOption< LogLevel > * log_level
Logging level option.
std::string build_information()
Returns the arm_compute library build information.
#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.