23.08
|
Go to the documentation of this file.
24 #include "utils/Utils.h"
26 #define BENCHMARK_EXAMPLES
50 std::string command_line(
int argc,
char **argv)
53 for(
int i = 0; i < argc; i++)
64 static std::unique_ptr<Example> g_example =
nullptr;
65 static std::vector<char *> g_example_argv = {};
69 ExampleTest() =
default;
70 void do_setup()
override
73 _is_setup = g_example->do_setup(g_example_argv.size(), &g_example_argv[0]);
75 void do_run()
override
82 void do_teardown()
override
86 g_example->do_teardown();
92 bool _is_setup{
false };
95 int run_example(
int argc,
char **argv, std::unique_ptr<Example> example)
100 example_args->
set_help(
"Arguments to pass to the example separated by commas (e.g: arg0,arg1,arg2)");
107 parser.print_help(argv[0]);
111 std::vector<std::unique_ptr<framework::Printer>> printers = options.
create_printers();
112 g_example = std::move(example);
113 g_example_argv.clear();
114 g_example_argv.emplace_back(argv[0]);
115 for(
auto &arg : example_args->value())
117 g_example_argv.emplace_back(
const_cast<char *
>(arg.c_str()));
122 for(
auto &p : printers)
124 p->print_global_header();
128 #ifdef ARM_COMPUTE_CL
133 for(
auto &arg : example_args->value())
135 if(arg.find(
"--target=clvk") != std::string::npos)
151 for(
auto &p : printers)
154 p->print_entry(
"CommandLine", command_line(argc, argv));
155 #ifdef ARM_COMPUTE_CL
162 p->print_entry(
"CL_DEVICE_VERSION",
"Unavailable");
174 framework.
init(fconfig);
176 for(
auto &p : printers)
189 bool success = framework.
run();
192 for(
auto &p : printers)
194 p->print_global_footer();
198 return (success ? 0 : 1);
std::string to_string(T &&value)
Convert integer and float values to string.
bool opencl_is_available()
Check if OpenCL is available.
Framework configuration structure.
Common command line options used to configure the framework.
int num_iterations
Number of iterations per test.
int run_example(int argc, char **argv, std::unique_ptr< ValidateExample > example)
Run an example and handle the potential exceptions it throws.
void add_printer(Printer *printer)
Set the printer used for the output of test results.
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.
void add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status)
Add a test case to the framework.
arm_compute::utils::ToggleOption * help
Show help option.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
LogLevel log_level
Verbosity of the output.
Implementation of an option that accepts any number of values.
std::vector< std::unique_ptr< Printer > > create_printers()
Create the printers based on parsed command line options.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Class to parse command line arguments.
const std::vector< T > & value() const
Get the values of the option.
std::stringstream ss(mlgo_str)
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
void set_throw_errors(bool throw_errors)
Set whether errors are caught or thrown by the framework.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
std::vector< framework::InstrumentsDescription > instruments
Instrument types that will be used for benchmarking.
bool run()
Run all enabled test cases.
bool is_set() const
Has a value been assigned to the option?
Handle for loading and retrieving GEMM heuristics.
const T & value() const
Get the selected value.
static Framework & get()
Access to the singleton.
static CLScheduler & get()
Access the scheduler singleton.
CLBackendType
List the possible OpenCL backends.
void set_help(std::string help)
Set the help message for the option.
Helper class to statically begin and end a test suite.
Abstract test case class.
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.
@ Native
OpenCL native backend.
std::string build_information()
Returns the arm_compute library build information.
arm_compute::utils::SimpleOption< int > * iterations
Number of iterations option.
const T & value() const
Get the option value.
arm_compute::utils::EnumListOption< InstrumentsDescription > * instruments
Instruments option.
Copyright (c) 2017-2023 Arm Limited.
arm_compute::utils::EnumOption< LogLevel > * log_level
Logging level option.
void init(const FrameworkConfig &config)
Init the framework.
arm_compute::utils::ToggleOption * throw_errors
Throw errors option.