53 #include <initializer_list> 64 std::string command_line(
int argc,
char **argv)
67 for(
int i = 0; i < argc; i++)
80 static constexpr uint32_t fixed_seed = 1;
83 extern std::unique_ptr<ParametersLibrary>
parameters;
90 bool file_exists(
const std::string &filename)
92 std::ifstream file(filename);
98 int main(
int argc,
char **argv)
104 std::set<framework::DatasetMode> allowed_modes
115 dataset_mode->
set_help(
"For managed datasets select which group to use");
117 filter->
set_help(
"Regular expression to select test cases");
119 filter_id->
set_help(
"List of test ids. ... can be used to define a range.");
121 stop_on_error->
set_help(
"Abort execution after the first failed test (useful for debugging)");
123 seed->set_help(
"Global seed for random number generation");
125 list_tests->
set_help(
"List all test names");
127 test_instruments->
set_help(
"Test if the instruments work on the platform");
129 error_on_missing_assets->
set_help(
"Mark a test as failed instead of skipping it when assets are missing");
131 assets->
set_help(
"Path to the assets directory");
132 #ifdef ARM_COMPUTE_CL 134 enable_tuner->
set_help(
"Enable OpenCL dynamic tuner");
136 const std::set<CLTunerMode> supported_tuner_modes
143 tuner_mode->
set_help(
"Configures the time taken by the tuner to tune. Slow tuner produces the most performant LWS configuration");
146 tuner_file->
set_help(
"File to load/save CLTuner values");
149 mlgo_file->
set_help(
"File to load MLGO heuristics");
152 threads->
set_help(
"Number of threads to use");
154 cooldown_sec->
set_help(
"Delay to add between test executions in seconds");
158 parser.
parse(argc, argv);
166 std::vector<std::unique_ptr<framework::Printer>> printers = options.
create_printers();
172 auto cpu_ctx = std::make_unique<RuntimeContext>();
176 auto cpu_ctx_track = std::make_unique<ContextSchedulerUser>(cpu_ctx.get());
179 parameters = std::make_unique<ParametersLibrary>();
180 parameters->set_cpu_ctx(std::move(cpu_ctx));
182 #ifdef ARM_COMPUTE_GC 185 auto gles_ctx = std::make_unique<GCRuntimeContext>();
192 parameters->set_gc_ctx(std::move(gles_ctx));
196 #ifdef ARM_COMPUTE_CL 207 if(enable_tuner->is_set())
215 if(file_exists(tuner_file->value()))
220 else if(!tuner_file->value().empty())
228 for(
auto &p : printers)
230 p->print_global_header();
236 for(
auto &p : printers)
239 p->print_entry(
"CommandLine", command_line(argc, argv));
241 #ifdef ARM_COMPUTE_CL 248 p->print_entry(
"CL_DEVICE_VERSION",
"Unavailable");
252 const unsigned int num_cpus = cpu_info.
get_cpu_num();
256 for(
unsigned int j = 0; j < num_cpus; ++j)
265 p->print_entry(
"Dataset mode",
to_string(dataset_mode->value()));
281 fconfig.
mode = dataset_mode->value();
284 framework.
init(fconfig);
286 for(
auto &p : printers)
296 if(list_tests->value())
298 for(
auto &p : printers)
301 p->print_global_footer();
307 if(test_instruments->value())
312 for(
auto &p : printers)
320 library = std::make_unique<AssetsLibrary>(assets->value(), seed->value());
321 fixed_library = std::make_unique<AssetsLibrary>(assets->value(), fixed_seed);
328 success = framework.
run();
332 for(
auto &p : printers)
334 p->print_global_footer();
338 #ifdef ARM_COMPUTE_CL 342 if(enable_tuner->is_set() && enable_tuner->value() && tuner_file->is_set())
349 return (success ? 0 : 1);
351 catch(
const std::exception &error)
353 std::cerr << error.what() <<
"\n";
Basic implementation of the OpenCL tuner interface.
Framework configuration structure.
void set_tuner_mode(CLTunerMode mode)
Set OpenCL tuner mode.
arm_compute::utils::ToggleOption * help
Show help option.
int main(int argc, char **argv)
int num_iterations
Number of iterations per test.
static CLScheduler & get()
Access the scheduler singleton.
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.
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 load_from_file(const std::string &filename)
Load the tuning parameters table from file.
bool has_fp16() const
Checks if the cpu model supports fp16.
void set_throw_errors(bool throw_errors)
Set whether errors are caught or thrown by the framework.
Implementation of an option that can be either true or false.
const std::vector< T > & value() const
Get the values of the option.
void set_instruments_info(InstrumentsInfo instr_info)
Sets instruments info.
std::unique_ptr< InstrumentsInfo > instruments_info
std::stringstream ss(mlgo_str)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
bool validate() const
Validates the previously parsed command line arguments.
CPUModel
CPU models - we only need to detect CPUs we have microarchitecture-specific code for.
CPUInfo & cpu_info()
Get CPU info.
std::tuple< cl::Context, cl::Device, cl_int > create_opencl_context_and_device()
This function creates an OpenCL context and a device.
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.
Class to parse command line arguments.
Copyright (c) 2017-2021 Arm Limited.
CPUModel get_cpu_model(unsigned int cpuid) const
Gets the cpu model for a given cpuid.
float cooldown_sec
Delay between tests in seconds.
static Framework & get()
Access to the singleton.
static GCScheduler & get()
Access the scheduler singleton.
Searches a minimal subset of LWS configurations while tuning.
T * add_option(const std::string &name, As &&... args)
Function to add a new option to the parser.
std::string cpu_model_to_string(CPUModel val)
Convert a cpumodel value to a string.
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.
bool save_to_file(const std::string &filename) const
Save the content of the tuning parameters table to file.
std::vector< std::unique_ptr< Printer > > create_printers()
Create the printers based on parsed command line options.
std::vector< TestInfo > test_infos() const
List of TestInfo's.
std::string name_filter
Regular expression to filter tests by name.
std::unique_ptr< AssetsLibrary > library
bool reload_from_file(const std::string &filename)
(Re)Load the heuristics from reading a dotmlgo file
std::unique_ptr< ParametersLibrary > parameters
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
void set_tune_new_kernels(bool tune_new_kernels)
Setter for tune_new_kernels option.
DatasetMode mode
Dataset mode.
bool has_dotprod() const
Checks if the cpu model supports dot product.
Profiler get_profiler() const
Factory method to obtain a configured profiler.
const T & value() const
Get the option value.
T * add_positional_option(As &&... args)
Function to add a new positional argument to the parser.
const MeasurementsMap & measurements() const
Return measurements for all instruments.
unsigned int get_cpu_num() const
Return the maximum number of CPUs present.
arm_compute::utils::SimpleOption< int > * iterations
Number of iterations option.
arm_compute::utils::EnumListOption< InstrumentsDescription > * instruments
Instruments option.
void sync()
Blocks until all commands in the associated command queue have finished.
Handle for loading and retrieving GEMM heuristics.
arm_compute::utils::EnumOption< LogLevel > * log_level
Logging level option.
std::string id_filter
String to match selected test ids.
Implementation of a simple option that accepts a value from a fixed set.
std::string to_string(const ICLTensor &arg)
void start()
Call start() on all the added instruments.
Wrapper to configure the Khronos OpenCL C++ header.
std::vector< ISchedulerUser * > _scheduler_users
std::string build_information()
Returns the arm_compute library build information.
Interface to enqueue GLES kernels and get/set the GLES CommandQueue.
void add_printer(Printer *printer)
Set the printer used for the output of test results.
void stop()
Call stop() on all the added instruments.
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.
Searches all possible LWS configurations while tuning.
void set_stop_on_error(bool stop_on_error)
Set whether to abort execution after the first failed test.
void default_init()
Initialises the context and command queue used by the scheduler to default values and sets a default ...
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.
static IScheduler & get()
Access the scheduler singleton.
std::unique_ptr< AssetsLibrary > fixed_library
arm_compute::utils::ToggleOption * throw_errors
Throw errors option.