50 #include <initializer_list> 61 std::string command_line(
int argc,
char **argv)
64 for(
int i = 0; i < argc; i++)
77 static constexpr uint32_t fixed_seed = 1;
80 extern std::unique_ptr<ParametersLibrary>
parameters;
87 bool file_exists(
const std::string &filename)
89 std::ifstream file(filename);
95 int main(
int argc,
char **argv)
101 std::set<framework::DatasetMode> allowed_modes
112 dataset_mode->
set_help(
"For managed datasets select which group to use");
114 filter->
set_help(
"Regular expression to select test cases");
116 filter_id->
set_help(
"List of test ids. ... can be used to define a range.");
118 stop_on_error->
set_help(
"Abort execution after the first failed test (useful for debugging)");
120 seed->set_help(
"Global seed for random number generation");
122 list_tests->
set_help(
"List all test names");
124 test_instruments->
set_help(
"Test if the instruments work on the platform");
126 error_on_missing_assets->
set_help(
"Mark a test as failed instead of skipping it when assets are missing");
128 assets->
set_help(
"Path to the assets directory");
129 #ifdef ARM_COMPUTE_CL 131 enable_tuner->
set_help(
"Enable OpenCL dynamic tuner");
133 const std::set<CLTunerMode> supported_tuner_modes
140 tuner_mode->
set_help(
"Configures the time taken by the tuner to tune. Slow tuner produces the most performant LWS configuration");
143 tuner_file->
set_help(
"File to load/save CLTuner values");
146 mlgo_file->
set_help(
"File to load MLGO heuristics");
149 threads->
set_help(
"Number of threads to use");
151 cooldown_sec->
set_help(
"Delay to add between test executions in seconds");
153 configure_only->
set_help(
"Only configures kernels, without allocating, running or validating. Needed in order to validate OpenCL kernel run-time compilation, without necessarily running or validating the kernels' execution");
161 parser.print_help(argv[0]);
165 std::vector<std::unique_ptr<framework::Printer>> printers = options.
create_printers();
171 auto cpu_ctx = std::make_unique<RuntimeContext>();
175 auto cpu_ctx_track = std::make_unique<ContextSchedulerUser>(cpu_ctx.get());
178 parameters = std::make_unique<ParametersLibrary>();
181 #ifdef ARM_COMPUTE_CL 192 if(enable_tuner->is_set())
200 if(file_exists(tuner_file->value()))
205 else if(!tuner_file->value().empty())
213 for(
auto &p : printers)
215 p->print_global_header();
221 for(
auto &p : printers)
224 p->print_entry(
"CommandLine", command_line(argc, argv));
226 #ifdef ARM_COMPUTE_CL 233 p->print_entry(
"CL_DEVICE_VERSION",
"Unavailable");
237 const unsigned int num_cpus = cpu_info.
get_cpu_num();
241 for(
unsigned int j = 0; j < num_cpus; ++j)
250 p->print_entry(
"Dataset mode",
to_string(dataset_mode->value()));
266 fconfig.
mode = dataset_mode->value();
270 framework.
init(fconfig);
272 for(
auto &p : printers)
282 if(list_tests->value())
284 for(
auto &p : printers)
287 p->print_global_footer();
293 if(test_instruments->value())
298 for(
auto &p : printers)
306 library = std::make_unique<AssetsLibrary>(assets->value(), seed->value());
307 fixed_library = std::make_unique<AssetsLibrary>(assets->value(), fixed_seed);
314 success = framework.
run();
318 for(
auto &p : printers)
320 p->print_global_footer();
324 #ifdef ARM_COMPUTE_CL 328 if(enable_tuner->is_set() && enable_tuner->value() && tuner_file->is_set())
335 return (success ? 0 : 1);
337 catch(
const std::exception &error)
339 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)
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
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(CLBackendType cl_backend_type)
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.
Searches a minimal subset of LWS configurations while tuning.
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.
std::string to_string(const ROIPoolingLayerInfo &pool_info)
Formatted output of the ROIPoolingInfo type.
LogLevel log_level
Verbosity of the output.
bool run()
Run all enabled test cases.
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.
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.
const T & value() const
Get the selected value.
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.
void start()
Call start() on all the added instruments.
Wrapper to configure the Khronos OpenCL C++ header.
std::string build_information()
Returns the arm_compute library build information.
bool configure_only
Only configure kernels.
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?
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 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.