blob: 370db8d4dce69fd9174ca429fe9a16de5af11d6e [file] [log] [blame]
Moritz Pflanzera4f711b2017-07-05 11:02:23 +01001/*
Anthony Barbiere8a49832018-01-18 10:04:05 +00002 * Copyright (c) 2017-2018 ARM Limited.
Moritz Pflanzera4f711b2017-07-05 11:02:23 +01003 *
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
Georgios Pinitas421405b2018-10-26 19:05:32 +010027#if !defined(BARE_METAL)
Moritz Pflanzer45634b42017-08-30 12:48:18 +010028#include "MaliCounter.h"
Anthony Barbier35aa6a32018-04-23 16:12:12 +010029#include "OpenCLMemoryUsage.h"
Anthony Barbier6e433492017-11-09 15:52:00 +000030#include "OpenCLTimer.h"
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010031#include "PMUCounter.h"
Georgios Pinitas421405b2018-10-26 19:05:32 +010032#endif /* !defined(BARE_METAL) */
Anthony Barbiere8a49832018-01-18 10:04:05 +000033#include "SchedulerTimer.h"
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010034#include "WallClockTimer.h"
35
36#include <sstream>
37#include <string>
38
39namespace arm_compute
40{
41namespace test
42{
43namespace framework
44{
45enum class InstrumentType : unsigned int
46{
47 ALL = ~0U,
48 NONE = 0,
Moritz Pflanzer09e4f982017-08-30 12:47:06 +010049 WALL_CLOCK_TIMER = 0x0100,
50 PMU = 0x0200,
51 PMU_CYCLE_COUNTER = 0x0201,
52 PMU_INSTRUCTION_COUNTER = 0x0202,
Moritz Pflanzer45634b42017-08-30 12:48:18 +010053 MALI = 0x0300,
Anthony Barbier6e433492017-11-09 15:52:00 +000054 OPENCL_TIMER = 0x0400,
Anthony Barbiere8a49832018-01-18 10:04:05 +000055 SCHEDULER_TIMER = 0x0500,
Anthony Barbier35aa6a32018-04-23 16:12:12 +010056 OPENCL_MEMORY_USAGE = 0x0600,
Anthony Barbier72f4ae52018-11-07 17:33:54 +000057 WALL_CLOCK_TIMESTAMPS = 0x0700,
58 OPENCL_TIMESTAMPS = 0x0800,
59 SCHEDULER_TIMESTAMPS = 0x0900,
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010060};
61
Giorgio Arenace58a9f2017-10-31 17:59:17 +000062using InstrumentsDescription = std::pair<InstrumentType, ScaleFactor>;
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010063
Giorgio Arenace58a9f2017-10-31 17:59:17 +000064InstrumentsDescription instrument_type_from_name(const std::string &name);
65
66inline ::std::stringstream &operator>>(::std::stringstream &stream, InstrumentsDescription &instrument)
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010067{
68 std::string value;
69 stream >> value;
70 instrument = instrument_type_from_name(value);
71 return stream;
72}
73
Giorgio Arenace58a9f2017-10-31 17:59:17 +000074inline ::std::stringstream &operator<<(::std::stringstream &stream, InstrumentsDescription instrument)
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010075{
Giorgio Arenace58a9f2017-10-31 17:59:17 +000076 switch(instrument.first)
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010077 {
Anthony Barbier72f4ae52018-11-07 17:33:54 +000078 case InstrumentType::WALL_CLOCK_TIMESTAMPS:
79 switch(instrument.second)
80 {
81 case ScaleFactor::NONE:
82 stream << "WALL_CLOCK_TIMESTAMPS";
83 break;
84 case ScaleFactor::TIME_MS:
85 stream << "WALL_CLOCK_TIMESTAMPS_MS";
86 break;
87 case ScaleFactor::TIME_S:
88 stream << "WALL_CLOCK_TIMESTAMPS_S";
89 break;
90 default:
91 throw std::invalid_argument("Unsupported instrument scale");
92 }
93 break;
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010094 case InstrumentType::WALL_CLOCK_TIMER:
Giorgio Arenace58a9f2017-10-31 17:59:17 +000095 switch(instrument.second)
96 {
97 case ScaleFactor::NONE:
98 stream << "WALL_CLOCK_TIMER";
99 break;
100 case ScaleFactor::TIME_MS:
101 stream << "WALL_CLOCK_TIMER_MS";
102 break;
103 case ScaleFactor::TIME_S:
104 stream << "WALL_CLOCK_TIMER_S";
105 break;
106 default:
107 throw std::invalid_argument("Unsupported instrument scale");
108 }
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100109 break;
Anthony Barbier72f4ae52018-11-07 17:33:54 +0000110 case InstrumentType::SCHEDULER_TIMESTAMPS:
111 switch(instrument.second)
112 {
113 case ScaleFactor::NONE:
114 stream << "SCHEDULER_TIMESTAMPS";
115 break;
116 case ScaleFactor::TIME_MS:
117 stream << "SCHEDULER_TIMESTAMPS_MS";
118 break;
119 case ScaleFactor::TIME_S:
120 stream << "SCHEDULER_TIMESTAMPS_S";
121 break;
122 default:
123 throw std::invalid_argument("Unsupported instrument scale");
124 }
125 break;
Anthony Barbiere8a49832018-01-18 10:04:05 +0000126 case InstrumentType::SCHEDULER_TIMER:
127 switch(instrument.second)
128 {
129 case ScaleFactor::NONE:
130 stream << "SCHEDULER_TIMER";
131 break;
132 case ScaleFactor::TIME_MS:
133 stream << "SCHEDULER_TIMER_MS";
134 break;
135 case ScaleFactor::TIME_S:
136 stream << "SCHEDULER_TIMER_S";
137 break;
138 default:
139 throw std::invalid_argument("Unsupported instrument scale");
140 }
141 break;
Moritz Pflanzer09e4f982017-08-30 12:47:06 +0100142 case InstrumentType::PMU:
Giorgio Arenace58a9f2017-10-31 17:59:17 +0000143 switch(instrument.second)
144 {
145 case ScaleFactor::NONE:
146 stream << "PMU";
147 break;
148 case ScaleFactor::SCALE_1K:
149 stream << "PMU_K";
150 break;
151 case ScaleFactor::SCALE_1M:
152 stream << "PMU_M";
153 break;
154 default:
155 throw std::invalid_argument("Unsupported instrument scale");
156 }
Moritz Pflanzer09e4f982017-08-30 12:47:06 +0100157 break;
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100158 case InstrumentType::PMU_CYCLE_COUNTER:
159 stream << "PMU_CYCLE_COUNTER";
160 break;
161 case InstrumentType::PMU_INSTRUCTION_COUNTER:
162 stream << "PMU_INSTRUCTION_COUNTER";
163 break;
Moritz Pflanzer45634b42017-08-30 12:48:18 +0100164 case InstrumentType::MALI:
Giorgio Arenace58a9f2017-10-31 17:59:17 +0000165 switch(instrument.second)
166 {
167 case ScaleFactor::NONE:
168 stream << "MALI";
169 break;
170 case ScaleFactor::SCALE_1K:
171 stream << "MALI_K";
172 break;
173 case ScaleFactor::SCALE_1M:
174 stream << "MALI_M";
175 break;
176 default:
177 throw std::invalid_argument("Unsupported instrument scale");
178 }
Moritz Pflanzer45634b42017-08-30 12:48:18 +0100179 break;
Anthony Barbier72f4ae52018-11-07 17:33:54 +0000180 case InstrumentType::OPENCL_TIMESTAMPS:
181 switch(instrument.second)
182 {
183 case ScaleFactor::NONE:
184 stream << "OPENCL_TIMESTAMPS";
185 break;
186 case ScaleFactor::TIME_US:
187 stream << "OPENCL_TIMESTAMPS_US";
188 break;
189 case ScaleFactor::TIME_MS:
190 stream << "OPENCL_TIMESTAMPS_MS";
191 break;
192 case ScaleFactor::TIME_S:
193 stream << "OPENCL_TIMESTAMPS_S";
194 break;
195 default:
196 throw std::invalid_argument("Unsupported instrument scale");
197 }
198 break;
Anthony Barbier6e433492017-11-09 15:52:00 +0000199 case InstrumentType::OPENCL_TIMER:
Giorgio Arenace58a9f2017-10-31 17:59:17 +0000200 switch(instrument.second)
201 {
202 case ScaleFactor::NONE:
203 stream << "OPENCL_TIMER";
204 break;
205 case ScaleFactor::TIME_US:
206 stream << "OPENCL_TIMER_US";
207 break;
208 case ScaleFactor::TIME_MS:
209 stream << "OPENCL_TIMER_MS";
210 break;
211 case ScaleFactor::TIME_S:
212 stream << "OPENCL_TIMER_S";
213 break;
214 default:
215 throw std::invalid_argument("Unsupported instrument scale");
216 }
Anthony Barbier6e433492017-11-09 15:52:00 +0000217 break;
Anthony Barbier35aa6a32018-04-23 16:12:12 +0100218 case InstrumentType::OPENCL_MEMORY_USAGE:
219 switch(instrument.second)
220 {
221 case ScaleFactor::NONE:
222 stream << "OPENCL_MEMORY_USAGE";
223 break;
224 case ScaleFactor::SCALE_1K:
225 stream << "OPENCL_MEMORY_USAGE_K";
226 break;
227 case ScaleFactor::SCALE_1M:
228 stream << "OPENCL_MEMORY_USAGE_M";
229 break;
230 default:
231 throw std::invalid_argument("Unsupported instrument scale");
232 }
233 break;
Moritz Pflanzera4f711b2017-07-05 11:02:23 +0100234 case InstrumentType::ALL:
235 stream << "ALL";
236 break;
237 case InstrumentType::NONE:
238 stream << "NONE";
239 break;
240 default:
241 throw std::invalid_argument("Unsupported instrument type");
242 }
243
244 return stream;
245}
246} // namespace framework
247} // namespace test
248} // namespace arm_compute
249#endif /* ARM_COMPUTE_TEST_INSTRUMENTS */