summaryrefslogtreecommitdiff
path: root/source/hal/source/components/npu/include/ethosu_profiler.h
blob: 093c07f47e41105838f9f2456c83859f16c8c766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright (c) 2022 Arm Limited. All rights reserved.
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef ETHOS_U_PROFILER_H
#define ETHOS_U_PROFILER_H

#include "pmu_ethosu.h"

#define ETHOSU_DERIVED_NCOUNTERS     1      /**< Number of counters derived from event counters */
#define ETHOSU_PROFILER_NUM_COUNTERS ( \
            ETHOSU_DERIVED_NCOUNTERS + \
            ETHOSU_PMU_NCOUNTERS +     \
            1 /* total CCNT */)

typedef struct npu_event_counter_ {
    enum ethosu_pmu_event_type event_type;
    uint32_t event_mask;
    uint32_t counter_value;
    const char* unit;
    const char* name;
} npu_evt_counter;

typedef struct npu_derived_counter_ {
    uint32_t counter_value;
    const char* unit;
    const char* name;
} npu_derived_counter;

typedef struct ethosu_pmu_counters_ {
    uint64_t                npu_total_ccnt;     /**< Total NPU cycles */
    npu_evt_counter         npu_evt_counters[ETHOSU_PMU_NCOUNTERS];
    npu_derived_counter     npu_derived_counters[ETHOSU_DERIVED_NCOUNTERS];
    uint32_t                num_total_counters; /**< Total number of counters */
} ethosu_pmu_counters;

/**
 * @brief  Initialise the Arm Ethos-U NPU performance monitoring unit.
 */
void ethosu_pmu_init(void);

/**
 * @brief  Resets the Arm Ethos-U NPU PMU counters.
 */
void ethosu_pmu_reset_counters(void);

/**
 * @brief Get the Arm Ethos-U NPU PMU counters
 * @return ethosu_pmu_counters
 */
ethosu_pmu_counters ethosu_get_pmu_counters(void);

#endif /* ETHOS_U_PROFILER_H */