42 #include <initializer_list>
48 using namespace arm_compute;
49 using namespace arm_compute::test;
59 int main(
int argc,
char **argv)
69 std::set<framework::InstrumentType> allowed_instruments
77 allowed_instruments.insert(
type);
80 std::set<framework::DatasetMode> allowed_modes
87 std::set<framework::LogFormat> supported_log_formats
94 std::set<framework::LogLevel> supported_log_levels
106 help->
set_help(
"Show this help message");
108 dataset_mode->
set_help(
"For managed datasets select which group to use");
110 instruments->
set_help(
"Set the profiling instruments to use");
112 iterations->
set_help(
"Number of iterations per test case");
114 threads->
set_help(
"Number of threads to use");
116 log_format->
set_help(
"Output format for measurements and failures");
118 filter->
set_help(
"Regular expression to select test cases");
120 filter_id->
set_help(
"List of test ids. ... can be used to define a range.");
122 log_file->
set_help(
"Write output to file instead of to the console");
124 log_level->
set_help(
"Verbosity of the output");
126 throw_errors->
set_help(
"Don't catch fatal errors (useful for debugging)");
128 stop_on_error->
set_help(
"Abort execution after the first failed test (useful for debugging)");
130 seed->set_help(
"Global seed for random number generation");
132 color_output->
set_help(
"Produce colored output on the console");
134 list_tests->
set_help(
"List all test names");
136 test_instruments->
set_help(
"Test if the instruments work on the platform");
138 error_on_missing_assets->
set_help(
"Mark a test as failed instead of skipping it when assets are missing");
140 assets->
set_help(
"Path to the assets directory");
144 parser.
parse(argc, argv);
146 if(help->is_set() && help->value())
152 std::unique_ptr<framework::Printer> printer;
153 std::ofstream log_stream;
155 switch(log_format->value())
158 printer = support::cpp14::make_unique<framework::JSONPrinter>();
165 auto pretty_printer = support::cpp14::make_unique<framework::PrettyPrinter>();
166 pretty_printer->set_color_output(color_output->value());
167 printer = std::move(pretty_printer);
172 if(printer !=
nullptr)
174 if(log_file->is_set())
176 log_stream.open(log_file->value());
177 printer->set_stream(log_stream);
185 printer->print_global_header();
195 printer->print_entry(
"Dataset mode",
to_string(dataset_mode->value()));
199 framework.
init(instruments->value(), iterations->value(), dataset_mode->value(), filter->value(), filter_id->value(), log_level->value());
207 if(list_tests->value())
211 std::cout <<
"[" <<
info.id <<
", " <<
info.mode <<
", " <<
info.status <<
"] " <<
info.name <<
"\n";
217 if(test_instruments->value())
222 if(printer !=
nullptr)
229 library = support::cpp14::make_unique<AssetsLibrary>(assets->value(), seed->value());
236 success = framework.
run();
240 printer->print_global_footer();
243 return (success ? 0 : 1);
245 catch(
const std::exception &
error)
247 std::cerr << error.what() <<
"\n";
249 if(throw_errors->value())
Implementation of an option that can be either true or false.
int main(int argc, char **argv)
T * add_option(const std::string &name, As &&...args)
Function to add a new option to the parser.
std::set< InstrumentType > available_instruments() const
Supported instrument types for benchmarking.
Profiler class to collect benchmark numbers.
virtual void set_num_threads(unsigned int num_threads)=0
Sets the number of threads the scheduler will use to run the kernels.
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.
Implementation of an option that accepts a single value.
void parse(int argc, char **argv)
Parses the command line arguments and updates the options accordingly.
void set_error_on_missing_assets(bool error_on_missing_assets)
Set whether a test should be considered as failed if its assets cannot be found.
T * add_positional_option(As &&...args)
Function to add a new positional argument to the parser.
std::string to_string(const NonLinearFilterFunction &function)
src info() -> set_format(Format::S16)
static Framework & get()
Access to the singleton.
void error(const char *function, const char *file, const int line, const char *msg,...)
Print an error message then throw an std::runtime_error.
bool run()
Run all enabled test cases.
std::vector< TestInfo > test_infos() const
List of TestInfo's.
bool validate() const
Validates the previously parsed command line arguments.
std::unique_ptr< AssetsLibrary > library
void init(const std::vector< InstrumentType > &instruments, int num_iterations, DatasetMode mode, const std::string &name_filter, const std::string &id_filter, LogLevel log_level)
Init the framework.
Implementation of an option that accepts any number of values from a fixed set.
static CLScheduler & get()
Access the scheduler singleton.
Implementation of a simple option that accepts a value from a fixed set.
const MeasurementsMap & measurements() const
Return measurements for all instruments.
void start()
Start all added instruments to measure performance.
Profiler get_profiler() const
Factory method to obtain a configured profiler.
Class to parse command line arguments.
void stop()
Stop all added instruments.
void set_help(std::string help)
Set the help message for the option.
void print_help(const std::string &program_name) const
Prints a help message for all configured options.
void set_stop_on_error(bool stop_on_error)
Set whether to abort execution after the first failed test.
void set_printer(Printer *printer)
Set the printer used for the output of test results.
void default_init(ICLTuner *cl_tuner=nullptr)
Initialises the context and command queue used by the scheduler to default values and sets a default ...
static IScheduler & get()
Access the scheduler singleton.