Kristofer Jonsson | b5f7cfe | 2021-03-10 17:13:52 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2021 Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the License); you may |
| 7 | * not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | /**************************************************************************** |
| 20 | * Includes |
| 21 | ****************************************************************************/ |
| 22 | |
| 23 | #include "command_stream.hpp" |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | |
| 27 | using namespace std; |
| 28 | using namespace EthosU::CommandStream; |
| 29 | |
| 30 | /**************************************************************************** |
| 31 | * Data |
| 32 | ****************************************************************************/ |
| 33 | |
| 34 | __attribute__((section(".sram.data"), aligned(16))) char commandStream[] = { |
| 35 | DRIVER_ACTION_MAGIC() |
| 36 | DRIVER_ACTION_NOP() |
| 37 | DRIVER_ACTION_NOP() |
| 38 | DRIVER_ACTION_COMMAND_STREAM(1) |
| 39 | |
| 40 | NPU_OP_STOP(0) |
| 41 | }; |
| 42 | |
| 43 | /**************************************************************************** |
| 44 | * Functions |
| 45 | ****************************************************************************/ |
| 46 | |
| 47 | int main() { |
| 48 | CommandStream cs( |
| 49 | DataPointer(commandStream, sizeof(commandStream)), |
| 50 | BasePointers(), |
| 51 | PmuEvents({ |
| 52 | ETHOSU_PMU_CYCLE, |
| 53 | ETHOSU_PMU_NPU_IDLE, |
| 54 | ETHOSU_PMU_NPU_ACTIVE |
| 55 | }) |
| 56 | ); |
| 57 | |
| 58 | const size_t repeat = 1000; |
| 59 | |
| 60 | // Clear PMU |
| 61 | cs.getPmu().clear(); |
| 62 | |
| 63 | // Run inference |
| 64 | int ret = cs.run(repeat); |
| 65 | uint64_t cycleCount = cs.getPmu().getCycleCount(); |
| 66 | |
| 67 | // Print PMU counters |
| 68 | cs.getPmu().print(); |
| 69 | printf("cycleCount=%llu, cycleCountPerJob=%llu\n", cycleCount, cycleCount / repeat); |
| 70 | |
| 71 | return ret; |
| 72 | } |