/* * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "Instruments.h" #include "../Utils.h" #include #include namespace arm_compute { namespace test { namespace framework { InstrumentsDescription instrument_type_from_name(const std::string &name) { static const std::map types = { { "all", std::pair(InstrumentType::ALL, ScaleFactor::NONE) }, { "none", std::pair(InstrumentType::NONE, ScaleFactor::NONE) }, { "wall_clock", std::pair(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::NONE) }, { "wall_clock_timer", std::pair(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::NONE) }, { "wall_clock_timer_ms", std::pair(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::TIME_MS) }, { "wall_clock_timer_s", std::pair(InstrumentType::WALL_CLOCK_TIMER, ScaleFactor::TIME_S) }, { "wall_clock_timestamps", std::pair(InstrumentType::WALL_CLOCK_TIMESTAMPS, ScaleFactor::NONE) }, { "wall_clock_timestamps_ms", std::pair(InstrumentType::WALL_CLOCK_TIMESTAMPS, ScaleFactor::TIME_MS) }, { "wall_clock_timestamps_s", std::pair(InstrumentType::WALL_CLOCK_TIMESTAMPS, ScaleFactor::TIME_S) }, { "scheduler_timestamps", std::pair(InstrumentType::SCHEDULER_TIMESTAMPS, ScaleFactor::NONE) }, { "scheduler_timestamps_ms", std::pair(InstrumentType::SCHEDULER_TIMESTAMPS, ScaleFactor::TIME_MS) }, { "scheduler_timestamps_s", std::pair(InstrumentType::SCHEDULER_TIMESTAMPS, ScaleFactor::TIME_S) }, { "scheduler_timer", std::pair(InstrumentType::SCHEDULER_TIMER, ScaleFactor::NONE) }, { "scheduler_timer_ms", std::pair(InstrumentType::SCHEDULER_TIMER, ScaleFactor::TIME_MS) }, { "scheduler_timer_s", std::pair(InstrumentType::SCHEDULER_TIMER, ScaleFactor::TIME_S) }, { "pmu", std::pair(InstrumentType::PMU, ScaleFactor::NONE) }, { "pmu_k", std::pair(InstrumentType::PMU, ScaleFactor::SCALE_1K) }, { "pmu_m", std::pair(InstrumentType::PMU, ScaleFactor::SCALE_1M) }, { "pmu_cycles", std::pair(InstrumentType::PMU_CYCLE_COUNTER, ScaleFactor::NONE) }, { "pmu_instructions", std::pair(InstrumentType::PMU_INSTRUCTION_COUNTER, ScaleFactor::NONE) }, { "mali", std::pair(InstrumentType::MALI, ScaleFactor::NONE) }, { "mali_k", std::pair(InstrumentType::MALI, ScaleFactor::SCALE_1K) }, { "mali_m", std::pair(InstrumentType::MALI, ScaleFactor::SCALE_1M) }, { "opencl_timestamps", std::pair(InstrumentType::OPENCL_TIMESTAMPS, ScaleFactor::NONE) }, { "opencl_timestamps_us", std::pair(InstrumentType::OPENCL_TIMESTAMPS, ScaleFactor::TIME_US) }, { "opencl_timestamps_ms", std::pair(InstrumentType::OPENCL_TIMESTAMPS, ScaleFactor::TIME_MS) }, { "opencl_timestamps_s", std::pair(InstrumentType::OPENCL_TIMESTAMPS, ScaleFactor::TIME_S) }, { "opencl_timer", std::pair(InstrumentType::OPENCL_TIMER, ScaleFactor::NONE) }, { "opencl_timer_us", std::pair(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_US) }, { "opencl_timer_ms", std::pair(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_MS) }, { "opencl_timer_s", std::pair(InstrumentType::OPENCL_TIMER, ScaleFactor::TIME_S) }, { "opencl_memory_usage", std::pair(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::NONE) }, { "opencl_memory_usage_k", std::pair(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::SCALE_1K) }, { "opencl_memory_usage_m", std::pair(InstrumentType::OPENCL_MEMORY_USAGE, ScaleFactor::SCALE_1M) }, }; try { return types.at(tolower(name)); } catch(const std::out_of_range &) { throw std::invalid_argument(name); } } } // namespace framework } // namespace test } // namespace arm_compute