Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 1 | /* |
Anthony Barbier | e8a4983 | 2018-01-18 10:04:05 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 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 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 26 | #include "support/ToolchainSupport.h" |
| 27 | |
| 28 | #include <chrono> |
| 29 | #include <iostream> |
| 30 | #include <sstream> |
| 31 | #include <type_traits> |
| 32 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | namespace test |
| 36 | { |
| 37 | namespace framework |
| 38 | { |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 39 | Framework::Framework() |
| 40 | { |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 41 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::NONE), Instrument::make_instrument<WallClockTimer, ScaleFactor::NONE>); |
| 42 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::TIME_MS), Instrument::make_instrument<WallClockTimer, ScaleFactor::TIME_MS>); |
| 43 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::TIME_S), Instrument::make_instrument<WallClockTimer, ScaleFactor::TIME_S>); |
Anthony Barbier | e8a4983 | 2018-01-18 10:04:05 +0000 | [diff] [blame] | 44 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMER, ScaleFactor::NONE), Instrument::make_instrument<SchedulerTimer, ScaleFactor::NONE>); |
| 45 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMER, ScaleFactor::TIME_MS), Instrument::make_instrument<SchedulerTimer, ScaleFactor::TIME_MS>); |
| 46 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::SCHEDULER_TIMER, ScaleFactor::TIME_S), Instrument::make_instrument<SchedulerTimer, ScaleFactor::TIME_S>); |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 47 | #ifdef PMU_ENABLED |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 48 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::PMU, ScaleFactor::NONE), Instrument::make_instrument<PMUCounter, ScaleFactor::NONE>); |
| 49 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::PMU, ScaleFactor::SCALE_1K), Instrument::make_instrument<PMUCounter, ScaleFactor::SCALE_1K>); |
| 50 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::PMU, ScaleFactor::SCALE_1M), Instrument::make_instrument<PMUCounter, ScaleFactor::SCALE_1M>); |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 51 | #endif /* PMU_ENABLED */ |
Moritz Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 52 | #ifdef MALI_ENABLED |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 53 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::MALI, ScaleFactor::NONE), Instrument::make_instrument<MaliCounter, ScaleFactor::NONE>); |
| 54 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::MALI, ScaleFactor::SCALE_1K), Instrument::make_instrument<MaliCounter, ScaleFactor::SCALE_1K>); |
| 55 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::MALI, ScaleFactor::SCALE_1M), Instrument::make_instrument<MaliCounter, ScaleFactor::SCALE_1M>); |
Moritz Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 56 | #endif /* MALI_ENABLED */ |
Anthony Barbier | e8895f8 | 2017-11-23 16:58:52 +0000 | [diff] [blame] | 57 | #ifdef ARM_COMPUTE_CL |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 58 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMER, ScaleFactor::NONE), Instrument::make_instrument<OpenCLTimer, ScaleFactor::NONE>); |
| 59 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_US), Instrument::make_instrument<OpenCLTimer, ScaleFactor::TIME_US>); |
| 60 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_MS), Instrument::make_instrument<OpenCLTimer, ScaleFactor::TIME_MS>); |
| 61 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_S), Instrument::make_instrument<OpenCLTimer, ScaleFactor::TIME_S>); |
Anthony Barbier | 35aa6a3 | 2018-04-23 16:12:12 +0100 | [diff] [blame^] | 62 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::NONE), Instrument::make_instrument<OpenCLMemoryUsage, ScaleFactor::NONE>); |
| 63 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::SCALE_1K), |
| 64 | Instrument::make_instrument<OpenCLMemoryUsage, ScaleFactor::SCALE_1K>); |
| 65 | _available_instruments.emplace(std::pair<InstrumentType, ScaleFactor>(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::SCALE_1M), |
| 66 | Instrument::make_instrument<OpenCLMemoryUsage, ScaleFactor::SCALE_1M>); |
Anthony Barbier | e8895f8 | 2017-11-23 16:58:52 +0000 | [diff] [blame] | 67 | #endif /* ARM_COMPUTE_CL */ |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 68 | } |
| 69 | |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 70 | std::set<InstrumentsDescription> Framework::available_instruments() const |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 71 | { |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 72 | std::set<InstrumentsDescription> types; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 73 | |
| 74 | for(const auto &instrument : _available_instruments) |
| 75 | { |
| 76 | types.emplace(instrument.first); |
| 77 | } |
| 78 | |
| 79 | return types; |
| 80 | } |
| 81 | |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 82 | std::map<TestResult::Status, int> Framework::count_test_results() const |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 83 | { |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 84 | std::map<TestResult::Status, int> counts; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 85 | |
| 86 | for(const auto &test : _test_results) |
| 87 | { |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 88 | ++counts[test.second.status]; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 89 | } |
| 90 | |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 91 | return counts; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | Framework &Framework::get() |
| 95 | { |
| 96 | static Framework instance; |
| 97 | return instance; |
| 98 | } |
| 99 | |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 100 | void Framework::init(const std::vector<framework::InstrumentsDescription> &instruments, int num_iterations, DatasetMode mode, const std::string &name_filter, const std::string &id_filter, |
| 101 | LogLevel log_level) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 102 | { |
Moritz Pflanzer | ec2de0f | 2017-07-27 14:43:46 +0100 | [diff] [blame] | 103 | _test_filter = TestFilter(mode, name_filter, id_filter); |
| 104 | _num_iterations = num_iterations; |
| 105 | _log_level = log_level; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 106 | |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 107 | _instruments = std::set<framework::InstrumentsDescription>(instruments.begin(), instruments.end()); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | std::string Framework::current_suite_name() const |
| 111 | { |
| 112 | return join(_test_suite_name.cbegin(), _test_suite_name.cend(), "/"); |
| 113 | } |
| 114 | |
| 115 | void Framework::push_suite(std::string name) |
| 116 | { |
| 117 | _test_suite_name.emplace_back(std::move(name)); |
| 118 | } |
| 119 | |
| 120 | void Framework::pop_suite() |
| 121 | { |
| 122 | _test_suite_name.pop_back(); |
| 123 | } |
| 124 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 125 | void Framework::add_test_info(std::string info) |
| 126 | { |
| 127 | _test_info.emplace_back(std::move(info)); |
| 128 | } |
| 129 | |
| 130 | void Framework::clear_test_info() |
| 131 | { |
| 132 | _test_info.clear(); |
| 133 | } |
| 134 | |
| 135 | bool Framework::has_test_info() const |
| 136 | { |
| 137 | return !_test_info.empty(); |
| 138 | } |
| 139 | |
| 140 | void Framework::print_test_info(std::ostream &os) const |
| 141 | { |
Moritz Pflanzer | 8df3faf | 2017-07-28 13:57:53 +0100 | [diff] [blame] | 142 | if(!_test_info.empty()) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 143 | { |
Moritz Pflanzer | 8df3faf | 2017-07-28 13:57:53 +0100 | [diff] [blame] | 144 | os << "CONTEXT:\n"; |
| 145 | |
| 146 | for(const auto &str : _test_info) |
| 147 | { |
| 148 | os << " " << str << "\n"; |
| 149 | } |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 153 | template <typename F> |
| 154 | void Framework::func_on_all_printers(F &&func) |
| 155 | { |
| 156 | std::for_each(std::begin(_printers), std::end(_printers), func); |
| 157 | } |
| 158 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 159 | void Framework::log_test_start(const TestInfo &info) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 160 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 161 | if(_log_level >= LogLevel::TESTS) |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 162 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 163 | func_on_all_printers([&](Printer * p) |
| 164 | { |
| 165 | p->print_test_header(info); |
| 166 | }); |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 167 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 170 | void Framework::log_test_skipped(const TestInfo &info) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 171 | { |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 172 | static_cast<void>(info); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 173 | } |
| 174 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 175 | void Framework::log_test_end(const TestInfo &info) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 176 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 177 | if(_log_level >= LogLevel::MEASUREMENTS) |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 178 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 179 | func_on_all_printers([&](Printer * p) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 180 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 181 | p->print_measurements(_test_results.at(info).measurements); |
| 182 | }); |
| 183 | } |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 184 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 185 | if(_log_level >= LogLevel::TESTS) |
| 186 | { |
| 187 | func_on_all_printers([](Printer * p) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 188 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 189 | p->print_test_footer(); |
| 190 | }); |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 191 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 192 | } |
| 193 | |
Moritz Pflanzer | 24a8246 | 2017-08-04 11:34:44 +0100 | [diff] [blame] | 194 | void Framework::log_failed_expectation(const TestError &error) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 195 | { |
Moritz Pflanzer | 0ce0844 | 2017-09-16 11:11:27 +0100 | [diff] [blame] | 196 | ARM_COMPUTE_ERROR_ON(_current_test_info == nullptr); |
| 197 | ARM_COMPUTE_ERROR_ON(_current_test_result == nullptr); |
| 198 | |
| 199 | const bool is_expected_failure = _current_test_info->status == TestCaseFactory::Status::EXPECTED_FAILURE; |
| 200 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 201 | if(_log_level >= error.level()) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 202 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 203 | func_on_all_printers([&](Printer * p) |
| 204 | { |
| 205 | p->print_error(error, is_expected_failure); |
| 206 | }); |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 207 | } |
Moritz Pflanzer | e1103a8 | 2017-07-18 12:20:45 +0100 | [diff] [blame] | 208 | |
Moritz Pflanzer | 0ce0844 | 2017-09-16 11:11:27 +0100 | [diff] [blame] | 209 | _current_test_result->status = TestResult::Status::FAILED; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 210 | } |
| 211 | |
steniu01 | 172c58d | 2017-08-31 13:49:08 +0100 | [diff] [blame] | 212 | void Framework::log_info(const std::string &info) |
| 213 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 214 | if(_log_level >= LogLevel::DEBUG) |
steniu01 | 172c58d | 2017-08-31 13:49:08 +0100 | [diff] [blame] | 215 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 216 | func_on_all_printers([&](Printer * p) |
| 217 | { |
| 218 | p->print_info(info); |
| 219 | }); |
steniu01 | 172c58d | 2017-08-31 13:49:08 +0100 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 223 | int Framework::num_iterations() const |
| 224 | { |
| 225 | return _num_iterations; |
| 226 | } |
| 227 | |
| 228 | void Framework::set_num_iterations(int num_iterations) |
| 229 | { |
| 230 | _num_iterations = num_iterations; |
| 231 | } |
| 232 | |
| 233 | void Framework::set_throw_errors(bool throw_errors) |
| 234 | { |
| 235 | _throw_errors = throw_errors; |
| 236 | } |
| 237 | |
| 238 | bool Framework::throw_errors() const |
| 239 | { |
| 240 | return _throw_errors; |
| 241 | } |
| 242 | |
Moritz Pflanzer | fa81165 | 2017-07-26 17:00:37 +0100 | [diff] [blame] | 243 | void Framework::set_stop_on_error(bool stop_on_error) |
| 244 | { |
| 245 | _stop_on_error = stop_on_error; |
| 246 | } |
| 247 | |
| 248 | bool Framework::stop_on_error() const |
| 249 | { |
| 250 | return _stop_on_error; |
| 251 | } |
| 252 | |
Anthony Barbier | f6705ec | 2017-09-28 12:01:10 +0100 | [diff] [blame] | 253 | void Framework::set_error_on_missing_assets(bool error_on_missing_assets) |
| 254 | { |
| 255 | _error_on_missing_assets = error_on_missing_assets; |
| 256 | } |
| 257 | |
| 258 | bool Framework::error_on_missing_assets() const |
| 259 | { |
| 260 | return _error_on_missing_assets; |
| 261 | } |
| 262 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 263 | void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 264 | { |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 265 | if(test_factory.status() == TestCaseFactory::Status::DISABLED) |
| 266 | { |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 267 | log_test_skipped(info); |
| 268 | set_test_result(info, TestResult(TestResult::Status::DISABLED)); |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 269 | return; |
| 270 | } |
| 271 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 272 | log_test_start(info); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 273 | |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 274 | Profiler profiler = get_profiler(); |
Moritz Pflanzer | e33eb64 | 2017-07-31 14:48:45 +0100 | [diff] [blame] | 275 | TestResult result(TestResult::Status::NOT_RUN); |
Moritz Pflanzer | e1103a8 | 2017-07-18 12:20:45 +0100 | [diff] [blame] | 276 | |
Moritz Pflanzer | 0ce0844 | 2017-09-16 11:11:27 +0100 | [diff] [blame] | 277 | _current_test_info = &info; |
Moritz Pflanzer | e1103a8 | 2017-07-18 12:20:45 +0100 | [diff] [blame] | 278 | _current_test_result = &result; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 279 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 280 | if(_log_level >= LogLevel::ERRORS) |
Moritz Pflanzer | 24a8246 | 2017-08-04 11:34:44 +0100 | [diff] [blame] | 281 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 282 | func_on_all_printers([](Printer * p) |
| 283 | { |
| 284 | p->print_errors_header(); |
| 285 | }); |
Moritz Pflanzer | 24a8246 | 2017-08-04 11:34:44 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Moritz Pflanzer | 0ce0844 | 2017-09-16 11:11:27 +0100 | [diff] [blame] | 288 | const bool is_expected_failure = info.status == TestCaseFactory::Status::EXPECTED_FAILURE; |
Moritz Pflanzer | 5b61fd3 | 2017-09-12 15:51:33 +0100 | [diff] [blame] | 289 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 290 | try |
| 291 | { |
| 292 | std::unique_ptr<TestCase> test_case = test_factory.make(); |
| 293 | |
| 294 | try |
| 295 | { |
Anthony Barbier | 9fb0cac | 2018-04-20 15:46:21 +0100 | [diff] [blame] | 296 | profiler.test_start(); |
| 297 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 298 | test_case->do_setup(); |
| 299 | |
| 300 | for(int i = 0; i < _num_iterations; ++i) |
| 301 | { |
Anthony Barbier | 6194145 | 2017-11-21 17:49:07 +0000 | [diff] [blame] | 302 | //Start the profiler if: |
| 303 | //- there is only one iteration |
| 304 | //- it's not the first iteration of a multi-iterations run. |
| 305 | // |
| 306 | //Reason: if the CLTuner is enabled then the first run will be really messy |
| 307 | //as each kernel will be executed several times, messing up the instruments like OpenCL timers. |
| 308 | if(_num_iterations == 1 || i != 0) |
Anthony Barbier | 2f8e077 | 2017-11-15 13:06:46 +0000 | [diff] [blame] | 309 | { |
| 310 | profiler.start(); |
| 311 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 312 | test_case->do_run(); |
Joel Liang | 1c5ffd6 | 2017-12-28 10:09:51 +0800 | [diff] [blame] | 313 | test_case->do_sync(); |
Anthony Barbier | 6194145 | 2017-11-21 17:49:07 +0000 | [diff] [blame] | 314 | if(_num_iterations == 1 || i != 0) |
Anthony Barbier | 2f8e077 | 2017-11-15 13:06:46 +0000 | [diff] [blame] | 315 | { |
| 316 | profiler.stop(); |
| 317 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | test_case->do_teardown(); |
Moritz Pflanzer | e33eb64 | 2017-07-31 14:48:45 +0100 | [diff] [blame] | 321 | |
Anthony Barbier | 9fb0cac | 2018-04-20 15:46:21 +0100 | [diff] [blame] | 322 | profiler.test_stop(); |
| 323 | |
Moritz Pflanzer | e33eb64 | 2017-07-31 14:48:45 +0100 | [diff] [blame] | 324 | // Change status to success if no error has happend |
| 325 | if(result.status == TestResult::Status::NOT_RUN) |
| 326 | { |
| 327 | result.status = TestResult::Status::SUCCESS; |
| 328 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 329 | } |
Anthony Barbier | f6705ec | 2017-09-28 12:01:10 +0100 | [diff] [blame] | 330 | catch(const FileNotFound &error) |
| 331 | { |
| 332 | if(_error_on_missing_assets) |
| 333 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 334 | if(_log_level >= LogLevel::ERRORS) |
Anthony Barbier | f6705ec | 2017-09-28 12:01:10 +0100 | [diff] [blame] | 335 | { |
| 336 | TestError test_error(error.what(), LogLevel::ERRORS); |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 337 | func_on_all_printers([&](Printer * p) |
| 338 | { |
| 339 | p->print_error(test_error, is_expected_failure); |
| 340 | }); |
Anthony Barbier | f6705ec | 2017-09-28 12:01:10 +0100 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | result.status = TestResult::Status::FAILED; |
| 344 | |
| 345 | if(_throw_errors) |
| 346 | { |
| 347 | throw; |
| 348 | } |
| 349 | } |
| 350 | else |
| 351 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 352 | if(_log_level >= LogLevel::DEBUG) |
Anthony Barbier | f6705ec | 2017-09-28 12:01:10 +0100 | [diff] [blame] | 353 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 354 | func_on_all_printers([&](Printer * p) |
| 355 | { |
| 356 | p->print_info(error.what()); |
| 357 | }); |
Anthony Barbier | f6705ec | 2017-09-28 12:01:10 +0100 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | result.status = TestResult::Status::NOT_RUN; |
| 361 | } |
| 362 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 363 | catch(const TestError &error) |
| 364 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 365 | if(_log_level >= error.level()) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 366 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 367 | func_on_all_printers([&](Printer * p) |
| 368 | { |
| 369 | p->print_error(error, is_expected_failure); |
| 370 | }); |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 371 | } |
| 372 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 373 | result.status = TestResult::Status::FAILED; |
| 374 | |
| 375 | if(_throw_errors) |
| 376 | { |
| 377 | throw; |
| 378 | } |
| 379 | } |
Moritz Pflanzer | 47752c9 | 2017-07-18 13:38:47 +0100 | [diff] [blame] | 380 | #ifdef ARM_COMPUTE_CL |
| 381 | catch(const ::cl::Error &error) |
| 382 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 383 | if(_log_level >= LogLevel::ERRORS) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 384 | { |
Moritz Pflanzer | 24a8246 | 2017-08-04 11:34:44 +0100 | [diff] [blame] | 385 | std::stringstream stream; |
| 386 | stream << "Error code: " << error.err(); |
Moritz Pflanzer | 5b61fd3 | 2017-09-12 15:51:33 +0100 | [diff] [blame] | 387 | TestError test_error(error.what(), LogLevel::ERRORS, stream.str()); |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 388 | func_on_all_printers([&](Printer * p) |
| 389 | { |
| 390 | p->print_error(test_error, is_expected_failure); |
| 391 | }); |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 392 | } |
| 393 | |
Moritz Pflanzer | 47752c9 | 2017-07-18 13:38:47 +0100 | [diff] [blame] | 394 | result.status = TestResult::Status::FAILED; |
| 395 | |
| 396 | if(_throw_errors) |
| 397 | { |
| 398 | throw; |
| 399 | } |
| 400 | } |
| 401 | #endif /* ARM_COMPUTE_CL */ |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 402 | catch(const std::exception &error) |
| 403 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 404 | if(_log_level >= LogLevel::ERRORS) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 405 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 406 | func_on_all_printers([&](Printer * p) |
| 407 | { |
| 408 | p->print_error(error, is_expected_failure); |
| 409 | }); |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 410 | } |
| 411 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 412 | result.status = TestResult::Status::CRASHED; |
| 413 | |
| 414 | if(_throw_errors) |
| 415 | { |
| 416 | throw; |
| 417 | } |
| 418 | } |
| 419 | catch(...) |
| 420 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 421 | if(_log_level >= LogLevel::ERRORS) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 422 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 423 | func_on_all_printers([&](Printer * p) |
| 424 | { |
| 425 | p->print_error(TestError("Received unknown exception"), is_expected_failure); |
| 426 | }); |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 427 | } |
| 428 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 429 | result.status = TestResult::Status::CRASHED; |
| 430 | |
| 431 | if(_throw_errors) |
| 432 | { |
| 433 | throw; |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | catch(const std::exception &error) |
| 438 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 439 | if(_log_level >= LogLevel::ERRORS) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 440 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 441 | func_on_all_printers([&](Printer * p) |
| 442 | { |
| 443 | p->print_error(error, is_expected_failure); |
| 444 | }); |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 445 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 446 | |
Moritz Pflanzer | e33eb64 | 2017-07-31 14:48:45 +0100 | [diff] [blame] | 447 | result.status = TestResult::Status::CRASHED; |
| 448 | |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 449 | if(_throw_errors) |
| 450 | { |
| 451 | throw; |
| 452 | } |
| 453 | } |
| 454 | catch(...) |
| 455 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 456 | if(_log_level >= LogLevel::ERRORS) |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 457 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 458 | func_on_all_printers([&](Printer * p) |
| 459 | { |
| 460 | p->print_error(TestError("Received unknown exception"), is_expected_failure); |
| 461 | }); |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 462 | } |
| 463 | |
Moritz Pflanzer | e1103a8 | 2017-07-18 12:20:45 +0100 | [diff] [blame] | 464 | result.status = TestResult::Status::CRASHED; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 465 | |
| 466 | if(_throw_errors) |
| 467 | { |
| 468 | throw; |
| 469 | } |
| 470 | } |
| 471 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 472 | if(_log_level >= LogLevel::ERRORS) |
Moritz Pflanzer | 24a8246 | 2017-08-04 11:34:44 +0100 | [diff] [blame] | 473 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 474 | func_on_all_printers([](Printer * p) |
| 475 | { |
| 476 | p->print_errors_footer(); |
| 477 | }); |
Moritz Pflanzer | 24a8246 | 2017-08-04 11:34:44 +0100 | [diff] [blame] | 478 | } |
| 479 | |
Moritz Pflanzer | 0ce0844 | 2017-09-16 11:11:27 +0100 | [diff] [blame] | 480 | _current_test_info = nullptr; |
Moritz Pflanzer | e1103a8 | 2017-07-18 12:20:45 +0100 | [diff] [blame] | 481 | _current_test_result = nullptr; |
| 482 | |
Moritz Pflanzer | fa81165 | 2017-07-26 17:00:37 +0100 | [diff] [blame] | 483 | if(result.status == TestResult::Status::FAILED) |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 484 | { |
Moritz Pflanzer | fa81165 | 2017-07-26 17:00:37 +0100 | [diff] [blame] | 485 | if(info.status == TestCaseFactory::Status::EXPECTED_FAILURE) |
| 486 | { |
| 487 | result.status = TestResult::Status::EXPECTED_FAILURE; |
| 488 | } |
Moritz Pflanzer | e33eb64 | 2017-07-31 14:48:45 +0100 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | if(result.status == TestResult::Status::FAILED || result.status == TestResult::Status::CRASHED) |
| 492 | { |
| 493 | if(_stop_on_error) |
Moritz Pflanzer | fa81165 | 2017-07-26 17:00:37 +0100 | [diff] [blame] | 494 | { |
| 495 | throw std::runtime_error("Abort on first error."); |
| 496 | } |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 497 | } |
| 498 | |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 499 | result.measurements = profiler.measurements(); |
| 500 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 501 | set_test_result(info, result); |
| 502 | log_test_end(info); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | bool Framework::run() |
| 506 | { |
| 507 | // Clear old test results |
| 508 | _test_results.clear(); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 509 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 510 | if(_log_level >= LogLevel::TESTS) |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 511 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 512 | func_on_all_printers([](Printer * p) |
| 513 | { |
| 514 | p->print_run_header(); |
| 515 | }); |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 516 | } |
| 517 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 518 | const std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now(); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 519 | |
| 520 | int id = 0; |
| 521 | |
| 522 | for(auto &test_factory : _test_factories) |
| 523 | { |
| 524 | const std::string test_case_name = test_factory->name(); |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 525 | const TestInfo test_info{ id, test_case_name, test_factory->mode(), test_factory->status() }; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 526 | |
Moritz Pflanzer | ec2de0f | 2017-07-27 14:43:46 +0100 | [diff] [blame] | 527 | if(_test_filter.is_selected(test_info)) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 528 | { |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 529 | run_test(test_info, *test_factory); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | ++id; |
| 533 | } |
| 534 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 535 | const std::chrono::time_point<std::chrono::high_resolution_clock> end = std::chrono::high_resolution_clock::now(); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 536 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 537 | if(_log_level >= LogLevel::TESTS) |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 538 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 539 | func_on_all_printers([](Printer * p) |
| 540 | { |
| 541 | p->print_run_footer(); |
| 542 | }); |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 543 | } |
| 544 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 545 | auto runtime = std::chrono::duration_cast<std::chrono::seconds>(end - start); |
| 546 | std::map<TestResult::Status, int> results = count_test_results(); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 547 | |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 548 | if(_log_level > LogLevel::NONE) |
| 549 | { |
Moritz Pflanzer | 8df3faf | 2017-07-28 13:57:53 +0100 | [diff] [blame] | 550 | std::cout << "Executed " << _test_results.size() << " test(s) (" |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 551 | << results[TestResult::Status::SUCCESS] << " passed, " |
| 552 | << results[TestResult::Status::EXPECTED_FAILURE] << " expected failures, " |
| 553 | << results[TestResult::Status::FAILED] << " failed, " |
| 554 | << results[TestResult::Status::CRASHED] << " crashed, " |
| 555 | << results[TestResult::Status::DISABLED] << " disabled) in " << runtime.count() << " second(s)\n"; |
Moritz Pflanzer | 2ac5040 | 2017-07-24 15:52:54 +0100 | [diff] [blame] | 556 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 557 | |
steniu01 | 3e05e4e | 2017-08-25 17:18:01 +0100 | [diff] [blame] | 558 | int num_successful_tests = results[TestResult::Status::SUCCESS] + results[TestResult::Status::EXPECTED_FAILURE] + results[TestResult::Status::DISABLED]; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 559 | |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 560 | return (static_cast<unsigned int>(num_successful_tests) == _test_results.size()); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 561 | } |
| 562 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 563 | void Framework::set_test_result(TestInfo info, TestResult result) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 564 | { |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 565 | _test_results.emplace(std::move(info), std::move(result)); |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 566 | } |
| 567 | |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 568 | void Framework::print_test_results(Printer &printer) const |
| 569 | { |
| 570 | printer.print_run_header(); |
| 571 | |
| 572 | for(const auto &test : _test_results) |
| 573 | { |
| 574 | printer.print_test_header(test.first); |
| 575 | printer.print_measurements(test.second.measurements); |
| 576 | printer.print_test_footer(); |
| 577 | } |
| 578 | |
| 579 | printer.print_run_footer(); |
| 580 | } |
| 581 | |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 582 | Profiler Framework::get_profiler() const |
| 583 | { |
| 584 | Profiler profiler; |
| 585 | |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 586 | const bool all_instruments = std::any_of( |
| 587 | _instruments.begin(), |
| 588 | _instruments.end(), |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 589 | [](InstrumentsDescription type) -> bool { return type.first == InstrumentType::ALL; }); |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 590 | |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 591 | auto is_selected = [&](InstrumentsDescription instrument) -> bool |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 592 | { |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 593 | return std::find_if(_instruments.begin(), _instruments.end(), [&](InstrumentsDescription type) -> bool { |
| 594 | const auto group = static_cast<InstrumentType>(static_cast<uint64_t>(type.first) & 0xFF00); |
| 595 | return (group == instrument.first) && (instrument.second == type.second); |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 596 | }) |
| 597 | != _instruments.end(); |
| 598 | }; |
| 599 | |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 600 | for(const auto &instrument : _available_instruments) |
| 601 | { |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 602 | if(all_instruments || is_selected(instrument.first)) |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 603 | { |
| 604 | profiler.add(instrument.second()); |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | return profiler; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 609 | } |
| 610 | |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 611 | void Framework::add_printer(Printer *printer) |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 612 | { |
Giorgio Arena | 2d09993 | 2017-10-25 15:47:08 +0100 | [diff] [blame] | 613 | _printers.push_back(printer); |
Moritz Pflanzer | 80fffae | 2017-07-05 11:02:37 +0100 | [diff] [blame] | 614 | } |
| 615 | |
Moritz Pflanzer | 542002c | 2017-07-26 16:03:58 +0100 | [diff] [blame] | 616 | std::vector<TestInfo> Framework::test_infos() const |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 617 | { |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 618 | std::vector<TestInfo> ids; |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 619 | |
| 620 | int id = 0; |
| 621 | |
| 622 | for(const auto &factory : _test_factories) |
| 623 | { |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 624 | TestInfo test_info{ id, factory->name(), factory->mode(), factory->status() }; |
| 625 | |
Moritz Pflanzer | ec2de0f | 2017-07-27 14:43:46 +0100 | [diff] [blame] | 626 | if(_test_filter.is_selected(test_info)) |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 627 | { |
Moritz Pflanzer | bf234e0 | 2017-07-24 15:04:14 +0100 | [diff] [blame] | 628 | ids.emplace_back(std::move(test_info)); |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | ++id; |
| 632 | } |
| 633 | |
| 634 | return ids; |
| 635 | } |
steniu01 | 172c58d | 2017-08-31 13:49:08 +0100 | [diff] [blame] | 636 | |
| 637 | LogLevel Framework::log_level() const |
| 638 | { |
| 639 | return _log_level; |
| 640 | } |
Moritz Pflanzer | fc95ed2 | 2017-07-05 11:07:07 +0100 | [diff] [blame] | 641 | } // namespace framework |
| 642 | } // namespace test |
| 643 | } // namespace arm_compute |