Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +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 | a4f711b | 2017-07-05 11:02:23 +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 | #ifndef ARM_COMPUTE_TEST_INSTRUMENTS |
| 25 | #define ARM_COMPUTE_TEST_INSTRUMENTS |
| 26 | |
Moritz Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 27 | #include "MaliCounter.h" |
Anthony Barbier | 35aa6a3 | 2018-04-23 16:12:12 +0100 | [diff] [blame^] | 28 | #include "OpenCLMemoryUsage.h" |
Anthony Barbier | 6e43349 | 2017-11-09 15:52:00 +0000 | [diff] [blame] | 29 | #include "OpenCLTimer.h" |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 30 | #include "PMUCounter.h" |
Anthony Barbier | e8a4983 | 2018-01-18 10:04:05 +0000 | [diff] [blame] | 31 | #include "SchedulerTimer.h" |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 32 | #include "WallClockTimer.h" |
| 33 | |
| 34 | #include <sstream> |
| 35 | #include <string> |
| 36 | |
| 37 | namespace arm_compute |
| 38 | { |
| 39 | namespace test |
| 40 | { |
| 41 | namespace framework |
| 42 | { |
| 43 | enum class InstrumentType : unsigned int |
| 44 | { |
| 45 | ALL = ~0U, |
| 46 | NONE = 0, |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 47 | WALL_CLOCK_TIMER = 0x0100, |
| 48 | PMU = 0x0200, |
| 49 | PMU_CYCLE_COUNTER = 0x0201, |
| 50 | PMU_INSTRUCTION_COUNTER = 0x0202, |
Moritz Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 51 | MALI = 0x0300, |
Anthony Barbier | 6e43349 | 2017-11-09 15:52:00 +0000 | [diff] [blame] | 52 | OPENCL_TIMER = 0x0400, |
Anthony Barbier | e8a4983 | 2018-01-18 10:04:05 +0000 | [diff] [blame] | 53 | SCHEDULER_TIMER = 0x0500, |
Anthony Barbier | 35aa6a3 | 2018-04-23 16:12:12 +0100 | [diff] [blame^] | 54 | OPENCL_MEMORY_USAGE = 0x0600, |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 55 | }; |
| 56 | |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 57 | using InstrumentsDescription = std::pair<InstrumentType, ScaleFactor>; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 58 | |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 59 | InstrumentsDescription instrument_type_from_name(const std::string &name); |
| 60 | |
| 61 | inline ::std::stringstream &operator>>(::std::stringstream &stream, InstrumentsDescription &instrument) |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 62 | { |
| 63 | std::string value; |
| 64 | stream >> value; |
| 65 | instrument = instrument_type_from_name(value); |
| 66 | return stream; |
| 67 | } |
| 68 | |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 69 | inline ::std::stringstream &operator<<(::std::stringstream &stream, InstrumentsDescription instrument) |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 70 | { |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 71 | switch(instrument.first) |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 72 | { |
| 73 | case InstrumentType::WALL_CLOCK_TIMER: |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 74 | switch(instrument.second) |
| 75 | { |
| 76 | case ScaleFactor::NONE: |
| 77 | stream << "WALL_CLOCK_TIMER"; |
| 78 | break; |
| 79 | case ScaleFactor::TIME_MS: |
| 80 | stream << "WALL_CLOCK_TIMER_MS"; |
| 81 | break; |
| 82 | case ScaleFactor::TIME_S: |
| 83 | stream << "WALL_CLOCK_TIMER_S"; |
| 84 | break; |
| 85 | default: |
| 86 | throw std::invalid_argument("Unsupported instrument scale"); |
| 87 | } |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 88 | break; |
Anthony Barbier | e8a4983 | 2018-01-18 10:04:05 +0000 | [diff] [blame] | 89 | case InstrumentType::SCHEDULER_TIMER: |
| 90 | switch(instrument.second) |
| 91 | { |
| 92 | case ScaleFactor::NONE: |
| 93 | stream << "SCHEDULER_TIMER"; |
| 94 | break; |
| 95 | case ScaleFactor::TIME_MS: |
| 96 | stream << "SCHEDULER_TIMER_MS"; |
| 97 | break; |
| 98 | case ScaleFactor::TIME_S: |
| 99 | stream << "SCHEDULER_TIMER_S"; |
| 100 | break; |
| 101 | default: |
| 102 | throw std::invalid_argument("Unsupported instrument scale"); |
| 103 | } |
| 104 | break; |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 105 | case InstrumentType::PMU: |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 106 | switch(instrument.second) |
| 107 | { |
| 108 | case ScaleFactor::NONE: |
| 109 | stream << "PMU"; |
| 110 | break; |
| 111 | case ScaleFactor::SCALE_1K: |
| 112 | stream << "PMU_K"; |
| 113 | break; |
| 114 | case ScaleFactor::SCALE_1M: |
| 115 | stream << "PMU_M"; |
| 116 | break; |
| 117 | default: |
| 118 | throw std::invalid_argument("Unsupported instrument scale"); |
| 119 | } |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 120 | break; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 121 | case InstrumentType::PMU_CYCLE_COUNTER: |
| 122 | stream << "PMU_CYCLE_COUNTER"; |
| 123 | break; |
| 124 | case InstrumentType::PMU_INSTRUCTION_COUNTER: |
| 125 | stream << "PMU_INSTRUCTION_COUNTER"; |
| 126 | break; |
Moritz Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 127 | case InstrumentType::MALI: |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 128 | switch(instrument.second) |
| 129 | { |
| 130 | case ScaleFactor::NONE: |
| 131 | stream << "MALI"; |
| 132 | break; |
| 133 | case ScaleFactor::SCALE_1K: |
| 134 | stream << "MALI_K"; |
| 135 | break; |
| 136 | case ScaleFactor::SCALE_1M: |
| 137 | stream << "MALI_M"; |
| 138 | break; |
| 139 | default: |
| 140 | throw std::invalid_argument("Unsupported instrument scale"); |
| 141 | } |
Moritz Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 142 | break; |
Anthony Barbier | 6e43349 | 2017-11-09 15:52:00 +0000 | [diff] [blame] | 143 | case InstrumentType::OPENCL_TIMER: |
Giorgio Arena | ce58a9f | 2017-10-31 17:59:17 +0000 | [diff] [blame] | 144 | switch(instrument.second) |
| 145 | { |
| 146 | case ScaleFactor::NONE: |
| 147 | stream << "OPENCL_TIMER"; |
| 148 | break; |
| 149 | case ScaleFactor::TIME_US: |
| 150 | stream << "OPENCL_TIMER_US"; |
| 151 | break; |
| 152 | case ScaleFactor::TIME_MS: |
| 153 | stream << "OPENCL_TIMER_MS"; |
| 154 | break; |
| 155 | case ScaleFactor::TIME_S: |
| 156 | stream << "OPENCL_TIMER_S"; |
| 157 | break; |
| 158 | default: |
| 159 | throw std::invalid_argument("Unsupported instrument scale"); |
| 160 | } |
Anthony Barbier | 6e43349 | 2017-11-09 15:52:00 +0000 | [diff] [blame] | 161 | break; |
Anthony Barbier | 35aa6a3 | 2018-04-23 16:12:12 +0100 | [diff] [blame^] | 162 | case InstrumentType::OPENCL_MEMORY_USAGE: |
| 163 | switch(instrument.second) |
| 164 | { |
| 165 | case ScaleFactor::NONE: |
| 166 | stream << "OPENCL_MEMORY_USAGE"; |
| 167 | break; |
| 168 | case ScaleFactor::SCALE_1K: |
| 169 | stream << "OPENCL_MEMORY_USAGE_K"; |
| 170 | break; |
| 171 | case ScaleFactor::SCALE_1M: |
| 172 | stream << "OPENCL_MEMORY_USAGE_M"; |
| 173 | break; |
| 174 | default: |
| 175 | throw std::invalid_argument("Unsupported instrument scale"); |
| 176 | } |
| 177 | break; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 178 | case InstrumentType::ALL: |
| 179 | stream << "ALL"; |
| 180 | break; |
| 181 | case InstrumentType::NONE: |
| 182 | stream << "NONE"; |
| 183 | break; |
| 184 | default: |
| 185 | throw std::invalid_argument("Unsupported instrument type"); |
| 186 | } |
| 187 | |
| 188 | return stream; |
| 189 | } |
| 190 | } // namespace framework |
| 191 | } // namespace test |
| 192 | } // namespace arm_compute |
| 193 | #endif /* ARM_COMPUTE_TEST_INSTRUMENTS */ |