Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 1 | /* |
| 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 Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 27 | #include "MaliCounter.h" |
Anthony Barbier | 6e43349 | 2017-11-09 15:52:00 +0000 | [diff] [blame] | 28 | #include "OpenCLTimer.h" |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 29 | #include "PMUCounter.h" |
| 30 | #include "WallClockTimer.h" |
| 31 | |
| 32 | #include <sstream> |
| 33 | #include <string> |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace test |
| 38 | { |
| 39 | namespace framework |
| 40 | { |
| 41 | enum class InstrumentType : unsigned int |
| 42 | { |
| 43 | ALL = ~0U, |
| 44 | NONE = 0, |
Moritz Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 45 | WALL_CLOCK_TIMER = 0x0100, |
| 46 | PMU = 0x0200, |
| 47 | PMU_CYCLE_COUNTER = 0x0201, |
| 48 | PMU_INSTRUCTION_COUNTER = 0x0202, |
Moritz Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 49 | MALI = 0x0300, |
Anthony Barbier | 6e43349 | 2017-11-09 15:52:00 +0000 | [diff] [blame] | 50 | OPENCL_TIMER = 0x0400, |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | InstrumentType instrument_type_from_name(const std::string &name); |
| 54 | |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 55 | inline ::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 | |
| 63 | inline ::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 Pflanzer | 09e4f98 | 2017-08-30 12:47:06 +0100 | [diff] [blame] | 70 | case InstrumentType::PMU: |
| 71 | stream << "PMU"; |
| 72 | break; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 73 | 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 Pflanzer | 45634b4 | 2017-08-30 12:48:18 +0100 | [diff] [blame] | 79 | case InstrumentType::MALI: |
| 80 | stream << "MALI"; |
| 81 | break; |
Anthony Barbier | 6e43349 | 2017-11-09 15:52:00 +0000 | [diff] [blame] | 82 | case InstrumentType::OPENCL_TIMER: |
| 83 | stream << "OPENCL_TIMER"; |
| 84 | break; |
Moritz Pflanzer | a4f711b | 2017-07-05 11:02:23 +0100 | [diff] [blame] | 85 | 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 */ |