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 | ****************************************************************************/ |
Anton Moberg | 908a07c | 2021-04-08 09:50:57 +0200 | [diff] [blame] | 33 | // clang-format off |
Kristofer Jonsson | b5f7cfe | 2021-03-10 17:13:52 +0100 | [diff] [blame] | 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) |
Anton Moberg | 908a07c | 2021-04-08 09:50:57 +0200 | [diff] [blame] | 41 | }; // clang-format on |
Kristofer Jonsson | b5f7cfe | 2021-03-10 17:13:52 +0100 | [diff] [blame] | 42 | |
| 43 | /**************************************************************************** |
| 44 | * Functions |
| 45 | ****************************************************************************/ |
| 46 | |
| 47 | int main() { |
Anton Moberg | 908a07c | 2021-04-08 09:50:57 +0200 | [diff] [blame] | 48 | CommandStream cs(DataPointer(commandStream, sizeof(commandStream)), |
| 49 | BasePointers(), |
| 50 | PmuEvents({ETHOSU_PMU_CYCLE, ETHOSU_PMU_NPU_IDLE, ETHOSU_PMU_NPU_ACTIVE})); |
Kristofer Jonsson | b5f7cfe | 2021-03-10 17:13:52 +0100 | [diff] [blame] | 51 | |
| 52 | const size_t repeat = 1000; |
| 53 | |
| 54 | // Clear PMU |
| 55 | cs.getPmu().clear(); |
| 56 | |
| 57 | // Run inference |
Anton Moberg | 908a07c | 2021-04-08 09:50:57 +0200 | [diff] [blame] | 58 | int ret = cs.run(repeat); |
Kristofer Jonsson | b5f7cfe | 2021-03-10 17:13:52 +0100 | [diff] [blame] | 59 | uint64_t cycleCount = cs.getPmu().getCycleCount(); |
| 60 | |
| 61 | // Print PMU counters |
| 62 | cs.getPmu().print(); |
| 63 | printf("cycleCount=%llu, cycleCountPerJob=%llu\n", cycleCount, cycleCount / repeat); |
| 64 | |
| 65 | return ret; |
| 66 | } |