24.02.1
|
Go to the documentation of this file.
52 #include <initializer_list>
63 std::string command_line(
int argc,
char **argv)
66 for(
int i = 0; i < argc; i++)
79 static constexpr uint32_t fixed_seed = 1;
82 extern std::unique_ptr<ParametersLibrary>
parameters;
89 bool file_exists(
const std::string &filename)
91 std::ifstream file(filename);
97 int main(
int argc,
char **argv)
103 std::set<framework::DatasetMode> allowed_modes
114 dataset_mode->
set_help(
"For managed datasets select which group to use");
116 filter->
set_help(
"Regular expression to select test cases");
118 filter_id->
set_help(
"List of test ids. ... can be used to define a range.");
120 stop_on_error->
set_help(
"Stop execution after the first failed test (useful for debugging)");
122 seed->set_help(
"Global seed for random number generation");
124 list_tests->
set_help(
"List all test names");
126 test_instruments->
set_help(
"Test if the instruments work on the platform");
128 error_on_missing_assets->
set_help(
"Mark a test as failed instead of skipping it when assets are missing");
130 assets->
set_help(
"Path to the assets directory");
132 print_rerun_command->
set_help(
"Print out the command to rerun the exact failed testcase");
133 #ifdef ARM_COMPUTE_CL
135 enable_tuner->
set_help(
"Enable OpenCL dynamic tuner");
137 const std::set<CLTunerMode> supported_tuner_modes
144 tuner_mode->
set_help(
"Configures the time taken by the tuner to tune. Slow tuner produces the most performant LWS configuration");
147 tuner_file->
set_help(
"File to load/save CLTuner values");
150 mlgo_file->
set_help(
"File to load MLGO heuristics");
153 threads->
set_help(
"Number of threads to use");
155 cooldown_sec->
set_help(
"Delay to add between test executions in seconds");
157 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");
165 parser.print_help(argv[0]);
169 std::vector<std::unique_ptr<framework::Printer>> printers = options.
create_printers();
175 auto cpu_ctx = std::make_unique<RuntimeContext>();
179 auto cpu_ctx_track = std::make_unique<ContextSchedulerUser>(cpu_ctx.get());
182 parameters = std::make_unique<ParametersLibrary>();
185 #ifdef ARM_COMPUTE_CL
196 if(enable_tuner->is_set())
204 if(file_exists(tuner_file->value()))
209 else if(!tuner_file->value().empty())
217 for(
auto &p : printers)
219 p->print_global_header();
225 for(
auto &p : printers)
228 p->print_entry(
"CommandLine", command_line(argc, argv));
230 #ifdef ARM_COMPUTE_CL
237 p->print_entry(
"CL_DEVICE_VERSION",
"Unavailable");
241 const unsigned int num_cpus = cpu_info.
get_cpu_num();
255 for(
unsigned int j = 0; j < num_cpus; ++j)
264 p->print_entry(
"Dataset mode",
to_string(dataset_mode->value()));
280 fconfig.
mode = dataset_mode->value();
285 fconfig.
seed = seed->value();
286 framework.
init(fconfig);
288 for(
auto &p : printers)
298 if(list_tests->value())
300 for(
auto &p : printers)
303 p->print_global_footer();
309 if(test_instruments->value())
314 for(
auto &p : printers)
322 library = std::make_unique<AssetsLibrary>(assets->value(), seed->value());
323 fixed_library = std::make_unique<AssetsLibrary>(assets->value(), fixed_seed);
330 success = framework.
run();
334 for(
auto &p : printers)
336 p->print_global_footer();
340 #ifdef ARM_COMPUTE_CL
344 if(enable_tuner->is_set() && enable_tuner->value() && tuner_file->is_set())
351 return (success ? 0 : 1);
353 catch(
const std::exception &error)
355 std::cerr << error.what() <<
"\n";
std::string to_string(T &&value)
Convert integer and float values to string.
bool opencl_is_available()
Check if OpenCL is available.
bool has_sve2() const
Checks if the cpu model supports sve2.
Framework configuration structure.
Common command line options used to configure the framework.
int num_iterations
Number of iterations per test.
Profiler class to collect benchmark numbers.
bool print_rerun_cmd
Print the command to rerun the failed testcase.
void add_printer(Printer *printer)
Set the printer used for the output of test results.
CPUModel
CPU models types.
std::string to_string(const SimpleTensor< T > &tensor)
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.
bool save_to_file(const std::string &filename) const
Save the content of the tuning parameters table to file.
std::vector< TestInfo > test_infos() const
List of TestInfo's.
arm_compute::utils::ToggleOption * help
Show help option.
void sync()
Blocks until all commands in the associated command queue have finished.
DatasetMode mode
Dataset mode.
void set_stop_on_error(bool stop_on_error)
Set whether to stop execution after the first failed test.
CPUInfo & cpu_info()
Get CPU info.
virtual void set_num_threads(unsigned int num_threads)=0
Sets the number of threads the scheduler will use to run the kernels.
bool has_dotprod() const
Checks if the cpu model supports dot product.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
LogLevel log_level
Verbosity of the output.
@ EXHAUSTIVE
Searches all possible LWS configurations while tuning.
bool has_sme() const
Checks if the cpu model supports sme.
std::vector< std::unique_ptr< Printer > > create_printers()
Create the printers based on parsed command line options.
unsigned int get_cpu_num() const
Return the maximum number of CPUs present.
@ NORMAL
Searches a subset of LWS configurations while tuning.
Class to parse command line arguments.
const std::vector< T > & value() const
Get the values of the option.
bool has_bf16() const
Checks if the cpu model supports bf16.
std::stringstream ss(mlgo_str)
bool has_fp16() const
Checks if the cpu model supports fp16.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Profiler get_profiler() const
Factory method to obtain a configured profiler.
bool configure_only
Only configure kernels.
void set_instruments_info(InstrumentsInfo instr_info)
Sets instruments info.
static IScheduler & get()
Access the scheduler singleton.
std::string id_filter
String to match selected test ids.
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.
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.
@ RAPID
Searches a minimal subset of LWS configurations while tuning.
bool run()
Run all enabled test cases.
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.
bool is_set() const
Has a value been assigned to the option?
Handle for loading and retrieving GEMM heuristics.
Wrapper to configure the Khronos OpenCL C++ header.
const T & value() const
Get the selected value.
bool has_svebf16() const
Checks if the cpu model supports bf16.
bool has_i8mm() const
Checks if the cpu model supports integer matrix multiplication.
bool reload_from_file(const std::string &filename)
(Re)Load the heuristics from reading a dotmlgo file
static Framework & get()
Access to the singleton.
std::unique_ptr< AssetsLibrary > fixed_library
static CLScheduler & get()
Access the scheduler singleton.
const MeasurementsMap & measurements() const
Return measurements for all instruments.
void set_help(std::string help)
Set the help message for the option.
std::unique_ptr< AssetsLibrary > library
std::string name_filter
Regular expression to filter tests by name.
bool has_sme2() const
Checks if the cpu model supports sme2.
std::unique_ptr< ParametersLibrary > parameters
bool has_sve() const
Checks if the cpu model supports sve.
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.
Implementation of a simple option that accepts a value from a fixed set.
std::string build_information()
Returns the arm_compute library build information.
arm_compute::utils::SimpleOption< int > * iterations
Number of iterations option.
bool has_svei8mm() const
Checks if the cpu model supports integer matrix multiplication.
const T & value() const
Get the option value.
arm_compute::utils::EnumListOption< InstrumentsDescription > * instruments
Instruments option.
Copyright (c) 2017-2024 Arm Limited.
void stop()
Call stop() on all the added instruments.
void load_from_file(const std::string &filename)
Load the tuning parameters table from file.
void start()
Call start() on all the added instruments.
void set_tuner_mode(CLTunerMode mode)
Set OpenCL tuner mode.
std::string cpu_model_to_string(CpuModel model)
Convert a CPU model value to a string.
arm_compute::utils::EnumOption< LogLevel > * log_level
Logging level option.
void init(const FrameworkConfig &config)
Init the framework.
void set_tune_new_kernels(bool tune_new_kernels)
Setter for tune_new_kernels option.
arm_compute::utils::ToggleOption * throw_errors
Throw errors option.
unsigned int seed
The seed that is used to fill tensors with random values.
float cooldown_sec
Delay between tests in seconds.
bool has_svef32mm() const
Checks if the cpu model supports floating-point matrix multiplication.
std::unique_ptr< InstrumentsInfo > instruments_info
int main(int argc, char **argv)
Basic implementation of the OpenCL tuner interface.
CPUModel get_cpu_model(unsigned int cpuid) const
Gets the cpu model for a given cpuid.