blob: ffe7cb681d3adbe758c50a3501b0065d11ce3c4d [file] [log] [blame]
Moritz Pflanzera4f711b2017-07-05 11:02:23 +01001/*
2 * Copyright (c) 2017 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#ifndef ARM_COMPUTE_TEST_INSTRUMENTS
25#define ARM_COMPUTE_TEST_INSTRUMENTS
26
Moritz Pflanzer45634b42017-08-30 12:48:18 +010027#include "MaliCounter.h"
Anthony Barbier6e433492017-11-09 15:52:00 +000028#include "OpenCLTimer.h"
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010029#include "PMUCounter.h"
30#include "WallClockTimer.h"
31
32#include <sstream>
33#include <string>
34
35namespace arm_compute
36{
37namespace test
38{
39namespace framework
40{
41enum class InstrumentType : unsigned int
42{
43 ALL = ~0U,
44 NONE = 0,
Moritz Pflanzer09e4f982017-08-30 12:47:06 +010045 WALL_CLOCK_TIMER = 0x0100,
46 PMU = 0x0200,
47 PMU_CYCLE_COUNTER = 0x0201,
48 PMU_INSTRUCTION_COUNTER = 0x0202,
Moritz Pflanzer45634b42017-08-30 12:48:18 +010049 MALI = 0x0300,
Anthony Barbier6e433492017-11-09 15:52:00 +000050 OPENCL_TIMER = 0x0400,
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010051};
52
53InstrumentType instrument_type_from_name(const std::string &name);
54
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010055inline ::std::stringstream &operator>>(::std::stringstream &stream, InstrumentType &instrument)
56{
57 std::string value;
58 stream >> value;
59 instrument = instrument_type_from_name(value);
60 return stream;
61}
62
63inline ::std::stringstream &operator<<(::std::stringstream &stream, InstrumentType instrument)
64{
65 switch(instrument)
66 {
67 case InstrumentType::WALL_CLOCK_TIMER:
68 stream << "WALL_CLOCK_TIMER";
69 break;
Moritz Pflanzer09e4f982017-08-30 12:47:06 +010070 case InstrumentType::PMU:
71 stream << "PMU";
72 break;
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010073 case InstrumentType::PMU_CYCLE_COUNTER:
74 stream << "PMU_CYCLE_COUNTER";
75 break;
76 case InstrumentType::PMU_INSTRUCTION_COUNTER:
77 stream << "PMU_INSTRUCTION_COUNTER";
78 break;
Moritz Pflanzer45634b42017-08-30 12:48:18 +010079 case InstrumentType::MALI:
80 stream << "MALI";
81 break;
Anthony Barbier6e433492017-11-09 15:52:00 +000082 case InstrumentType::OPENCL_TIMER:
83 stream << "OPENCL_TIMER";
84 break;
Moritz Pflanzera4f711b2017-07-05 11:02:23 +010085 case InstrumentType::ALL:
86 stream << "ALL";
87 break;
88 case InstrumentType::NONE:
89 stream << "NONE";
90 break;
91 default:
92 throw std::invalid_argument("Unsupported instrument type");
93 }
94
95 return stream;
96}
97} // namespace framework
98} // namespace test
99} // namespace arm_compute
100#endif /* ARM_COMPUTE_TEST_INSTRUMENTS */