Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022 Arm Limited. All rights reserved. |
| 3 | * SPDX-License-Identifier: Apache-2.0 |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | #ifndef ETHOS_U_PROFILER_H |
| 18 | #define ETHOS_U_PROFILER_H |
| 19 | |
| 20 | #include "pmu_ethosu.h" |
| 21 | |
| 22 | #define ETHOSU_DERIVED_NCOUNTERS 1 /**< Number of counters derived from event counters */ |
| 23 | #define ETHOSU_PROFILER_NUM_COUNTERS ( \ |
| 24 | ETHOSU_DERIVED_NCOUNTERS + \ |
| 25 | ETHOSU_PMU_NCOUNTERS + \ |
| 26 | 1 /* total CCNT */) |
| 27 | |
| 28 | typedef struct npu_event_counter_ { |
| 29 | enum ethosu_pmu_event_type event_type; |
| 30 | uint32_t event_mask; |
| 31 | uint32_t counter_value; |
| 32 | char* unit; |
| 33 | char* name; |
| 34 | } npu_evt_counter; |
| 35 | |
| 36 | typedef struct npu_derived_counter_ { |
| 37 | uint32_t counter_value; |
| 38 | char* unit; |
| 39 | char* name; |
| 40 | } npu_derived_counter; |
| 41 | |
| 42 | typedef struct ethosu_pmu_counters_ { |
| 43 | uint64_t npu_total_ccnt; /**< Total NPU cycles */ |
| 44 | npu_evt_counter npu_evt_counters[ETHOSU_PMU_NCOUNTERS]; |
| 45 | npu_derived_counter npu_derived_counters[ETHOSU_DERIVED_NCOUNTERS]; |
| 46 | uint32_t num_total_counters; /**< Total number of counters */ |
| 47 | } ethosu_pmu_counters; |
| 48 | |
| 49 | /** |
| 50 | * @brief Initialise the Arm Ethos-U NPU performance monitoring unit. |
| 51 | */ |
| 52 | void ethosu_pmu_init(void); |
| 53 | |
| 54 | /** |
| 55 | * @brief Resets the Arm Ethos-U NPU PMU counters. |
| 56 | */ |
| 57 | void ethosu_pmu_reset_counters(void); |
| 58 | |
| 59 | /** |
| 60 | * @brief Get the Arm Ethos-U NPU PMU counters |
| 61 | * @return ethosu_pmu_counters |
| 62 | */ |
| 63 | ethosu_pmu_counters ethosu_get_pmu_counters(void); |
| 64 | |
| 65 | #endif /* ETHOS_U_PROFILER_H */ |