Compute Library
 21.02
Framework.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "Framework.h"
25 
29 
30 #ifdef ARM_COMPUTE_CL
33 
34 #endif /* ARM_COMPUTE_CL */
35 
36 #include <chrono>
37 #include <iostream>
38 #include <memory>
39 #include <sstream>
40 #include <type_traits>
41 
42 namespace arm_compute
43 {
44 namespace test
45 {
46 std::unique_ptr<ParametersLibrary> parameters;
47 
48 namespace framework
49 {
50 std::unique_ptr<InstrumentsInfo> instruments_info;
51 
52 Framework::Framework()
53  : _test_filter(nullptr)
54 {
55  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMESTAMPS, ScaleFactor::NONE), Instrument::make_instrument<WallClockTimestamps, ScaleFactor::NONE>);
56  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMESTAMPS, ScaleFactor::TIME_MS),
57  Instrument::make_instrument<WallClockTimestamps, ScaleFactor::TIME_MS>);
58  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMESTAMPS, ScaleFactor::TIME_S),
59  Instrument::make_instrument<WallClockTimestamps, ScaleFactor::TIME_S>);
60  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::NONE), Instrument::make_instrument<WallClockTimer, ScaleFactor::NONE>);
61  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::TIME_MS), Instrument::make_instrument<WallClockTimer, ScaleFactor::TIME_MS>);
62  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::TIME_S), Instrument::make_instrument<WallClockTimer, ScaleFactor::TIME_S>);
63  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMESTAMPS, ScaleFactor::NONE), Instrument::make_instrument<SchedulerTimestamps, ScaleFactor::NONE>);
64  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMESTAMPS, ScaleFactor::TIME_MS),
65  Instrument::make_instrument<SchedulerTimestamps, ScaleFactor::TIME_MS>);
66  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMESTAMPS, ScaleFactor::TIME_S),
67  Instrument::make_instrument<SchedulerTimestamps, ScaleFactor::TIME_S>);
68  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMER, ScaleFactor::NONE), Instrument::make_instrument<SchedulerTimer, ScaleFactor::NONE>);
69  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMER, ScaleFactor::TIME_MS), Instrument::make_instrument<SchedulerTimer, ScaleFactor::TIME_MS>);
70  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMER, ScaleFactor::TIME_S), Instrument::make_instrument<SchedulerTimer, ScaleFactor::TIME_S>);
71 #ifdef PMU_ENABLED
72  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::PMU, ScaleFactor::NONE), Instrument::make_instrument<PMUCounter, ScaleFactor::NONE>);
73  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::PMU, ScaleFactor::SCALE_1K), Instrument::make_instrument<PMUCounter, ScaleFactor::SCALE_1K>);
74  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::PMU, ScaleFactor::SCALE_1M), Instrument::make_instrument<PMUCounter, ScaleFactor::SCALE_1M>);
75 #endif /* PMU_ENABLED */
76 #ifdef MALI_ENABLED
77  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::MALI, ScaleFactor::NONE), Instrument::make_instrument<MaliCounter, ScaleFactor::NONE>);
78  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::MALI, ScaleFactor::SCALE_1K), Instrument::make_instrument<MaliCounter, ScaleFactor::SCALE_1K>);
79  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::MALI, ScaleFactor::SCALE_1M), Instrument::make_instrument<MaliCounter, ScaleFactor::SCALE_1M>);
80 #endif /* MALI_ENABLED */
81 #ifdef ARM_COMPUTE_CL
82  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMESTAMPS, ScaleFactor::NONE), Instrument::make_instrument<OpenCLTimestamps, ScaleFactor::NONE>);
83  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMESTAMPS, ScaleFactor::TIME_US), Instrument::make_instrument<OpenCLTimestamps, ScaleFactor::TIME_US>);
84  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMESTAMPS, ScaleFactor::TIME_MS), Instrument::make_instrument<OpenCLTimestamps, ScaleFactor::TIME_MS>);
85  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMESTAMPS, ScaleFactor::TIME_S), Instrument::make_instrument<OpenCLTimestamps, ScaleFactor::TIME_S>);
86  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMER, ScaleFactor::NONE), Instrument::make_instrument<OpenCLTimer, ScaleFactor::NONE>);
87  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_US), Instrument::make_instrument<OpenCLTimer, ScaleFactor::TIME_US>);
88  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_MS), Instrument::make_instrument<OpenCLTimer, ScaleFactor::TIME_MS>);
89  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_S), Instrument::make_instrument<OpenCLTimer, ScaleFactor::TIME_S>);
90  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::NONE), Instrument::make_instrument<OpenCLMemoryUsage, ScaleFactor::NONE>);
91  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::SCALE_1K),
92  Instrument::make_instrument<OpenCLMemoryUsage, ScaleFactor::SCALE_1K>);
93  _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::SCALE_1M),
94  Instrument::make_instrument<OpenCLMemoryUsage, ScaleFactor::SCALE_1M>);
95 #endif /* ARM_COMPUTE_CL */
96 
97  instruments_info = std::make_unique<InstrumentsInfo>();
98 }
99 
100 std::set<InstrumentsDescription> Framework::available_instruments() const
101 {
102  std::set<InstrumentsDescription> types;
103 
104  for(const auto &instrument : _available_instruments)
105  {
106  types.emplace(instrument.first);
107  }
108 
109  return types;
110 }
111 
112 std::map<TestResult::Status, int> Framework::count_test_results() const
113 {
114  std::map<TestResult::Status, int> counts;
115 
116  for(const auto &test : _test_results)
117  {
118  ++counts[test.second.status];
119  }
120 
121  return counts;
122 }
123 
125 {
126  static Framework instance;
127  return instance;
128 }
129 
130 void Framework::init(const FrameworkConfig &config)
131 {
132  _test_filter.reset(new TestFilter(config.mode, config.name_filter, config.id_filter));
133  _num_iterations = config.num_iterations;
134  _log_level = config.log_level;
135  _cooldown_sec = config.cooldown_sec;
136 
137  _instruments = std::set<framework::InstrumentsDescription>(std::begin(config.instruments), std::end(config.instruments));
138 }
139 
140 std::string Framework::current_suite_name() const
141 {
142  return join(_test_suite_name.cbegin(), _test_suite_name.cend(), "/");
143 }
144 
145 void Framework::push_suite(std::string name)
146 {
147  _test_suite_name.emplace_back(std::move(name));
148 }
149 
151 {
152  _test_suite_name.pop_back();
153 }
154 
156 {
157  _test_info.emplace_back(std::move(info));
158 }
159 
161 {
162  _test_info.clear();
163 }
164 
166 {
167  return !_test_info.empty();
168 }
169 
170 void Framework::print_test_info(std::ostream &os) const
171 {
172  if(!_test_info.empty())
173  {
174  os << "CONTEXT:\n";
175 
176  for(const auto &str : _test_info)
177  {
178  os << " " << str << "\n";
179  }
180  }
181 }
182 
183 template <typename F>
184 void Framework::func_on_all_printers(F &&func)
185 {
186  std::for_each(std::begin(_printers), std::end(_printers), func);
187 }
188 
190 {
191  if(_log_level >= LogLevel::TESTS)
192  {
193  func_on_all_printers([&](Printer * p)
194  {
195  p->print_test_header(info);
196  });
197  }
198 }
199 
201 {
202  static_cast<void>(info);
203 }
204 
206 {
207  if(_log_level >= LogLevel::MEASUREMENTS)
208  {
209  func_on_all_printers([&](Printer * p)
210  {
211  p->print_measurements(_test_results.at(info).measurements);
212  });
213  }
214 
215  if(_log_level >= LogLevel::TESTS)
216  {
217  func_on_all_printers([](Printer * p)
218  {
219  p->print_test_footer();
220  });
221  }
222 }
223 
225 {
226  ARM_COMPUTE_ERROR_ON(_current_test_info == nullptr);
227  ARM_COMPUTE_ERROR_ON(_current_test_result == nullptr);
228 
229  const bool is_expected_failure = _current_test_info->status == TestCaseFactory::Status::EXPECTED_FAILURE;
230 
231  if(_log_level >= error.level())
232  {
233  func_on_all_printers([&](Printer * p)
234  {
235  p->print_error(error, is_expected_failure);
236  });
237  }
238 
239  _current_test_result->status = TestResult::Status::FAILED;
240 }
241 
242 void Framework::log_info(const std::string &info)
243 {
244  if(_log_level >= LogLevel::DEBUG)
245  {
246  func_on_all_printers([&](Printer * p)
247  {
248  p->print_info(info);
249  });
250  }
251 }
252 
254 {
255  return _num_iterations;
256 }
257 
259 {
260  _num_iterations = num_iterations;
261 }
262 
264 {
265  _throw_errors = throw_errors;
266 }
267 
269 {
270  return _throw_errors;
271 }
272 
274 {
275  _stop_on_error = stop_on_error;
276 }
277 
279 {
280  return _stop_on_error;
281 }
282 
284 {
285  _error_on_missing_assets = error_on_missing_assets;
286 }
287 
289 {
290  return _error_on_missing_assets;
291 }
292 
293 void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
294 {
295  if(test_factory.status() == TestCaseFactory::Status::DISABLED)
296  {
297  log_test_skipped(info);
299  return;
300  }
301 
302  log_test_start(info);
303 
304  Profiler profiler = get_profiler();
306 
307  _current_test_info = &info;
308  _current_test_result = &result;
309 
310  if(_log_level >= LogLevel::ERRORS)
311  {
312  func_on_all_printers([](Printer * p)
313  {
314  p->print_errors_header();
315  });
316  }
317 
318  const bool is_expected_failure = info.status == TestCaseFactory::Status::EXPECTED_FAILURE;
319 
320  try
321  {
322  std::unique_ptr<TestCase> test_case = test_factory.make();
323 
324  try
325  {
326  profiler.test_start();
327 
328  test_case->do_setup();
329 
330  for(int i = 0; i < _num_iterations; ++i)
331  {
332  //Start the profiler if:
333  //- there is only one iteration
334  //- it's not the first iteration of a multi-iterations run.
335  //
336  //Reason: if the CLTuner is enabled then the first run will be really messy
337  //as each kernel will be executed several times, messing up the instruments like OpenCL timers.
338  if(_num_iterations == 1 || i != 0)
339  {
340  profiler.start();
341  }
342  test_case->do_run();
343  test_case->do_sync();
344  if(_num_iterations == 1 || i != 0)
345  {
346  profiler.stop();
347  }
348  }
349 
350  test_case->do_teardown();
351 
352  profiler.test_stop();
353 
354  // Change status to success if no error has happend
355  if(result.status == TestResult::Status::NOT_RUN)
356  {
358  }
359  }
360  catch(const FileNotFound &error)
361  {
362  profiler.test_stop();
363  if(_error_on_missing_assets)
364  {
365  if(_log_level >= LogLevel::ERRORS)
366  {
367  TestError test_error(error.what(), LogLevel::ERRORS);
368  func_on_all_printers([&](Printer * p)
369  {
370  p->print_error(test_error, is_expected_failure);
371  });
372  }
373 
375 
376  if(_throw_errors)
377  {
378  throw;
379  }
380  }
381  else
382  {
383  if(_log_level >= LogLevel::DEBUG)
384  {
385  func_on_all_printers([&](Printer * p)
386  {
387  p->print_info(error.what());
388  });
389  }
390 
392  }
393  }
394  catch(const TestError &error)
395  {
396  profiler.test_stop();
397  if(_log_level >= error.level())
398  {
399  func_on_all_printers([&](Printer * p)
400  {
401  p->print_error(error, is_expected_failure);
402  });
403  }
404 
406 
407  if(_throw_errors)
408  {
409  throw;
410  }
411  }
412 #ifdef ARM_COMPUTE_CL
413  catch(const ::cl::Error &error)
414  {
415  profiler.test_stop();
416  if(_log_level >= LogLevel::ERRORS)
417  {
418  std::stringstream stream;
419  stream << "Error code: " << error.err();
420  TestError test_error(error.what(), LogLevel::ERRORS, stream.str());
421  func_on_all_printers([&](Printer * p)
422  {
423  p->print_error(test_error, is_expected_failure);
424  });
425  }
426 
428 
429  if(_throw_errors)
430  {
431  throw;
432  }
433  }
434 #endif /* ARM_COMPUTE_CL */
435  catch(const std::exception &error)
436  {
437  profiler.test_stop();
438  if(_log_level >= LogLevel::ERRORS)
439  {
440  func_on_all_printers([&](Printer * p)
441  {
442  p->print_error(error, is_expected_failure);
443  });
444  }
445 
447 
448  if(_throw_errors)
449  {
450  throw;
451  }
452  }
453  catch(...)
454  {
455  profiler.test_stop();
456  if(_log_level >= LogLevel::ERRORS)
457  {
458  func_on_all_printers([&](Printer * p)
459  {
460  p->print_error(TestError("Received unknown exception"), is_expected_failure);
461  });
462  }
463 
465 
466  if(_throw_errors)
467  {
468  throw;
469  }
470  }
471  }
472  catch(const std::exception &error)
473  {
474  if(_log_level >= LogLevel::ERRORS)
475  {
476  func_on_all_printers([&](Printer * p)
477  {
478  p->print_error(error, is_expected_failure);
479  });
480  }
481 
483 
484  if(_throw_errors)
485  {
486  throw;
487  }
488  }
489  catch(...)
490  {
491  if(_log_level >= LogLevel::ERRORS)
492  {
493  func_on_all_printers([&](Printer * p)
494  {
495  p->print_error(TestError("Received unknown exception"), is_expected_failure);
496  });
497  }
498 
500 
501  if(_throw_errors)
502  {
503  throw;
504  }
505  }
506 
507  if(_log_level >= LogLevel::ERRORS)
508  {
509  func_on_all_printers([](Printer * p)
510  {
511  p->print_errors_footer();
512  });
513  }
514 
515  _current_test_info = nullptr;
516  _current_test_result = nullptr;
517 
518  if(result.status == TestResult::Status::FAILED)
519  {
521  {
523  }
524  }
525 
527  {
528  if(_stop_on_error)
529  {
530  throw std::runtime_error("Abort on first error.");
531  }
532  }
533 
534  result.measurements = profiler.measurements();
535 
536  set_test_result(info, result);
537  log_test_end(info);
538 }
539 
541 {
542  // Clear old test results
543  _test_results.clear();
544 
545  if(_log_level >= LogLevel::TESTS)
546  {
547  func_on_all_printers([](Printer * p)
548  {
549  p->print_run_header();
550  });
551  }
552 
553  const std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now();
554 
555  int id = 0;
556  int id_run_test = 0;
557 
558  for(auto &test_factory : _test_factories)
559  {
560  const std::string test_case_name = test_factory->name();
561  const TestInfo test_info{ id, test_case_name, test_factory->mode(), test_factory->status() };
562 
563  if(_test_filter->is_selected(test_info))
564  {
565 #ifdef ARM_COMPUTE_CL
566  // Every 100 tests, reset the OpenCL context to release the allocated memory
567  if(opencl_is_available() && (id_run_test % 100) == 0)
568  {
569  auto ctx_properties = CLScheduler::get().context().getInfo<CL_CONTEXT_PROPERTIES>(nullptr);
570  auto queue_properties = CLScheduler::get().queue().getInfo<CL_QUEUE_PROPERTIES>(nullptr);
571 
572  cl::Context new_ctx = cl::Context(CL_DEVICE_TYPE_DEFAULT, ctx_properties.data());
573  cl::CommandQueue new_queue = cl::CommandQueue(new_ctx, CLKernelLibrary::get().get_device(), queue_properties);
574 
576  CLScheduler::get().set_context(new_ctx);
577  CLScheduler::get().set_queue(new_queue);
578  }
579 #endif // ARM_COMPUTE_CL
580 
581  run_test(test_info, *test_factory);
582 
583  ++id_run_test;
584 
585  // Run test delay
586  sleep_in_seconds(_cooldown_sec);
587  }
588 
589  ++id;
590  }
591 
592  const std::chrono::time_point<std::chrono::high_resolution_clock> end = std::chrono::high_resolution_clock::now();
593 
594  if(_log_level >= LogLevel::TESTS)
595  {
596  func_on_all_printers([](Printer * p)
597  {
598  p->print_run_footer();
599  });
600  }
601 
602  auto runtime = std::chrono::duration_cast<std::chrono::seconds>(end - start);
603  std::map<TestResult::Status, int> results = count_test_results();
604 
605  if(_log_level > LogLevel::NONE)
606  {
607  std::cout << "Executed " << _test_results.size() << " test(s) ("
608  << results[TestResult::Status::SUCCESS] << " passed, "
609  << results[TestResult::Status::EXPECTED_FAILURE] << " expected failures, "
610  << results[TestResult::Status::FAILED] << " failed, "
611  << results[TestResult::Status::CRASHED] << " crashed, "
612  << results[TestResult::Status::DISABLED] << " disabled) in " << runtime.count() << " second(s)\n";
613  }
614 
615  int num_successful_tests = results[TestResult::Status::SUCCESS] + results[TestResult::Status::EXPECTED_FAILURE] + results[TestResult::Status::DISABLED];
616 
617  return (static_cast<unsigned int>(num_successful_tests) == _test_results.size());
618 }
619 
621 {
622  _test_results.emplace(std::move(info), std::move(result));
623 }
624 
626 {
627  printer.print_run_header();
628 
629  for(const auto &test : _test_results)
630  {
631  printer.print_test_header(test.first);
632  printer.print_measurements(test.second.measurements);
633  printer.print_test_footer();
634  }
635 
636  printer.print_run_footer();
637 }
638 
640 {
641  Profiler profiler;
642 
643  const bool all_instruments = std::any_of(
644  _instruments.begin(),
645  _instruments.end(),
646  [](InstrumentsDescription type) -> bool { return type.first == InstrumentType::ALL; });
647 
648  auto is_selected = [&](InstrumentsDescription instrument) -> bool
649  {
650  return std::find_if(_instruments.begin(), _instruments.end(), [&](InstrumentsDescription type) -> bool {
651  const auto group = static_cast<InstrumentType>(static_cast<uint64_t>(type.first) & 0xFF00);
652  return (group == instrument.first) && (instrument.second == type.second);
653  })
654  != _instruments.end();
655  };
656 
657  for(const auto &instrument : _available_instruments)
658  {
659  if(all_instruments || is_selected(instrument.first))
660  {
661  profiler.add(instrument.second());
662  }
663  }
664 
665  return profiler;
666 }
667 
669 {
670  _printers.push_back(printer);
671 }
672 
673 std::vector<TestInfo> Framework::test_infos() const
674 {
675  std::vector<TestInfo> ids;
676 
677  int id = 0;
678 
679  for(const auto &factory : _test_factories)
680  {
681  TestInfo test_info{ id, factory->name(), factory->mode(), factory->status() };
682 
683  if(_test_filter->is_selected(test_info))
684  {
685  ids.emplace_back(std::move(test_info));
686  }
687 
688  ++id;
689  }
690 
691  return ids;
692 }
693 
695 {
696  return _log_level;
697 }
698 
700 {
701  ARM_COMPUTE_ERROR_ON(instruments_info == nullptr);
702  *instruments_info = instr_info;
703 }
704 } // namespace framework
705 } // namespace test
706 } // namespace arm_compute
void pop_suite()
Remove innermost test suite.
Definition: Framework.cpp:150
virtual std::unique_ptr< TestCase > make() const =0
Factory function to create the test case.
Framework configuration structure.
Definition: Framework.h:57
std::string join(T first, T last, const std::string &separator)
Helper function to concatenate multiple strings.
Definition: Utils.h:93
virtual void print_error(const std::exception &error, bool expected)=0
Print test error.
virtual void print_run_footer()=0
Print footer after running all tests.
virtual void print_errors_header()=0
Print header before errors.
void add(std::unique_ptr< Instrument > instrument)
Add instrument to the performance monitor.
Definition: Profiler.cpp:35
int num_iterations
Number of iterations per test.
Definition: Framework.h:63
std::pair< InstrumentType, ScaleFactor > InstrumentsDescription
Definition: Instruments.h:69
static CLScheduler & get()
Access the scheduler singleton.
Profiler class to collect benchmark numbers.
Definition: Profiler.h:45
void set_context(cl::Context context)
Accessor to set the CL context to be used by the scheduler.
virtual void print_info(const std::string &info)=0
Print test log info.
void print_test_info(std::ostream &os) const
Print test info.
Definition: Framework.cpp:170
const ActivationSelectorPtr is_selected
void set_throw_errors(bool throw_errors)
Set whether errors are caught or thrown by the framework.
Definition: Framework.cpp:263
bool stop_on_error() const
Indicates if test execution is stopped after the first failed test.
Definition: Framework.cpp:278
void log_failed_expectation(const TestError &error)
Tell the framework that the currently running test case failed a non-fatal expectation.
Definition: Framework.cpp:224
DatasetMode mode() const
Get the mode for which test case will be enabled.
Abstract printer class used by the Framework to present output.
Definition: Printer.h:43
void set_instruments_info(InstrumentsInfo instr_info)
Sets instruments info.
Definition: Framework.cpp:699
std::unique_ptr< InstrumentsInfo > instruments_info
Definition: Framework.cpp:50
void log_info(const std::string &info)
Print the debug information that has already been logged.
Definition: Framework.cpp:242
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
void test_stop()
Call test_stop() on all the added instruments.
Definition: Profiler.cpp:71
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
bool throw_errors() const
Should errors be caught or thrown by the framework.
Definition: Framework.cpp:268
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.
Definition: Framework.cpp:283
LogLevel
Severity of the information.
Definition: Exceptions.h:50
void set_test_result(TestInfo info, TestResult result)
Set the result for an executed test case.
Definition: Framework.cpp:620
decltype(strategy::transforms) typedef type
Copyright (c) 2017-2021 Arm Limited.
float cooldown_sec
Delay between tests in seconds.
Definition: Framework.h:64
static Framework & get()
Access to the singleton.
Definition: Framework.cpp:124
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
Abstract factory class to create test cases.
std::string name
Test name.
Definition: Framework.h:80
std::string name() const
Name of the test case.
LogLevel log_level
Verbosity of the output.
Definition: Framework.h:65
bool run()
Run all enabled test cases.
Definition: Framework.cpp:540
void clear_programs_cache()
Clear the library&#39;s cache of binary programs.
std::vector< framework::InstrumentsDescription > instruments
Instrument types that will be used for benchmarking.
Definition: Framework.h:59
LogLevel level() const
Severity of the error.
Definition: Exceptions.cpp:121
cl::Context & context()
Accessor for the associated CL context.
Definition: CLScheduler.cpp:34
std::vector< TestInfo > test_infos() const
List of TestInfo&#39;s.
Definition: Framework.cpp:673
std::string name_filter
Regular expression to filter tests by name.
Definition: Framework.h:60
std::unique_ptr< ParametersLibrary > parameters
Definition: Framework.cpp:46
Status status() const
Get the status of the test case.
Error class for when some external assets are missing.
Definition: Exceptions.h:67
std::set< InstrumentsDescription > available_instruments() const
Supported instrument types for benchmarking.
Definition: Framework.cpp:100
Information about a test case.
Definition: Framework.h:77
void end(TokenStream &in, bool &valid)
Definition: MLGOParser.cpp:290
LogLevel log_level() const
Get the current logging level.
Definition: Framework.cpp:694
Profiler get_profiler() const
Factory method to obtain a configured profiler.
Definition: Framework.cpp:639
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
Definition: CLScheduler.cpp:41
void log_test_start(const TestInfo &info)
Tell the framework that execution of a test starts.
Definition: Framework.cpp:189
const MeasurementsMap & measurements() const
Return measurements for all instruments.
Definition: Profiler.cpp:87
void set_queue(cl::CommandQueue queue)
Accessor to set the CL command queue to be used by the scheduler.
Definition: CLScheduler.cpp:57
const char * name
void for_each(F &&)
Base case of for_each.
Definition: Utility.h:108
Profiler::MeasurementsMap measurements
Profiling information.
Definition: TestResult.h:75
FloorUKernelPtr func
virtual void print_run_header()=0
Print header before running all tests.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void log_test_end(const TestInfo &info)
Tell the framework that a test case finished.
Definition: Framework.cpp:205
void add_test_info(std::string info)
Add info string for the next expectation/assertion.
Definition: Framework.cpp:155
bool error_on_missing_assets() const
Indicates if a test should be marked as failed when its assets are missing.
Definition: Framework.cpp:288
virtual void print_test_footer()=0
Print footer after a test.
std::string id_filter
String to match selected test ids.
Definition: Framework.h:61
bool has_test_info() const
Check if any info has been registered.
Definition: Framework.cpp:165
void set_num_iterations(int num_iterations)
Set number of iterations per test case.
Definition: Framework.cpp:258
void push_suite(std::string name)
Add a new test suite.
Definition: Framework.cpp:145
void start()
Call start() on all the added instruments.
Definition: Profiler.cpp:48
Class to store results of a test.
Definition: TestResult.h:39
Status status
Execution status.
Definition: TestResult.h:74
virtual void print_errors_footer()=0
Print footer after errors.
void sleep_in_seconds(float seconds)
Makes the calling thread to sleep for a specified number of seconds.
Definition: Utils.cpp:38
virtual void print_test_header(const TestInfo &info)=0
Print header before a test.
void add_printer(Printer *printer)
Set the printer used for the output of test results.
Definition: Framework.cpp:668
void stop()
Call stop() on all the added instruments.
Definition: Profiler.cpp:56
TestCaseFactory::Status status
Test status.
Definition: Framework.h:82
void test_start()
Call test_start() on all the added instruments.
Definition: Profiler.cpp:40
void log_test_skipped(const TestInfo &info)
Tell the framework that a test case is skipped.
Definition: Framework.cpp:200
Error class for failures during test execution.
Definition: Exceptions.h:78
void clear_test_info()
Clear the collected test info.
Definition: Framework.cpp:160
void set_stop_on_error(bool stop_on_error)
Set whether to abort execution after the first failed test.
Definition: Framework.cpp:273
int num_iterations() const
Number of iterations per test case.
Definition: Framework.cpp:253
void init(const FrameworkConfig &config)
Init the framework.
Definition: Framework.cpp:130
virtual void print_measurements(const Profiler::MeasurementsMap &measurements)=0
Print measurements for a test.
void print_test_results(Printer &printer) const
Use the specified printer to output test results from the last run.
Definition: Framework.cpp:625
bool opencl_is_available()
Check if OpenCL is available.
Definition: OpenCL.cpp:152