From a08e9d43eee72bb3143c9dad304c966e700be810 Mon Sep 17 00:00:00 2001 From: Kristofer Jonsson Date: Wed, 28 Apr 2021 12:32:28 +0200 Subject: Documenting startup and multi NPU Adding documentation and sequence diagrams for startup and multi NPU. Change-Id: I4a4a43e8bea089b6325f7d8285434017cbda25ec --- docs/multinpu.puml | 82 ++++++++++++++++++++++++++++++++++++++++++++++ docs/multinpu.svg | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ docs/startup.puml | 71 ++++++++++++++++++++++++++++++++++++++++ docs/startup.svg | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 332 insertions(+) create mode 100644 docs/multinpu.puml create mode 100644 docs/multinpu.svg create mode 100644 docs/startup.puml create mode 100644 docs/startup.svg (limited to 'docs') diff --git a/docs/multinpu.puml b/docs/multinpu.puml new file mode 100644 index 0000000..e5248b1 --- /dev/null +++ b/docs/multinpu.puml @@ -0,0 +1,82 @@ +@startuml + +skinparam backgroundColor #EEEBDC + +box "Application" #00C1DE +participant "main()" as app +end box + +box "Tensorflow" #FF6B00 +participant "TFLu" as tflu +participant "Ethos-U custom op" as custom +end box + +box "Ethos-U driver" #95D600 +participant "Driver" as driver +end box + +box "Hardware" #FFC700 +participant "Cortex-M" as cortexm +participant "Ethos-U" as ethosu +end box + +app -> tflu++: Invoke() + tflu -> custom++: Eval() + custom -> driver++: ethosu_reserve_driver() + loop Find and reserve driver + driver -> app++: ethosu_mutex_lock() + return + + driver -> driver: ethosu_find_and_reserve_driver() + + driver -> app++: ethosu_mutex_unlock() + return + + alt Found free driver + note over driver + Return free driver + end note + else No driver available + driver -> app++: ethosu_semaphore_take() + note over app + Block on semaphore + end note + return + end + end loop + return + + custom -> driver++: ethosu_invoke() + driver -\\ ethosu: Configure NPU and trigger inference + + driver -> driver++: wait_for_irq() + note over driver + Driver sleeping waiting for IRQ + end note + + ethosu -\\ cortexm: IRQ + cortexm -\\ driver: ethosu_irq_handler() + + note over driver + Driver woken up by IRQ handler + end note + return + return + + custom -> driver++: ethosu_release_driver() + driver -> app++: ethosu_mutex_lock() + return + + driver -> app++: ethosu_semaphore_give() + note over app + Wake up threads blocking on the semaphore + end note + return + + driver -> app++: ethosu_mutex_unlock() + return + return + return +return + +@enduml diff --git a/docs/multinpu.svg b/docs/multinpu.svg new file mode 100644 index 0000000..bc3b6b0 --- /dev/null +++ b/docs/multinpu.svg @@ -0,0 +1,95 @@ +ApplicationTensorflowEthos-U driverHardwaremain()main()TFLuTFLuEthos-U custom opEthos-U custom opDriverDriverCortex-MCortex-MEthos-UEthos-UInvoke()Eval()ethosu_reserve_driver()loop[Find and reserve driver]ethosu_mutex_lock()ethosu_find_and_reserve_driver()ethosu_mutex_unlock()alt[Found free driver]Return free driver[No driver available]ethosu_semaphore_take()Block on semaphoreethosu_invoke()Configure NPU and trigger inferencewait_for_irq()Driver sleeping waiting for IRQIRQethosu_irq_handler()Driver woken up by IRQ handlerethosu_release_driver()ethosu_mutex_lock()ethosu_semaphore_give()Wake up threads blocking on the semaphoreethosu_mutex_unlock() \ No newline at end of file diff --git a/docs/startup.puml b/docs/startup.puml new file mode 100644 index 0000000..f9cb528 --- /dev/null +++ b/docs/startup.puml @@ -0,0 +1,71 @@ +@startuml + +skinparam backgroundColor #EEEBDC + +box "Hardware" #FFC700 +participant "Cortex-M" as cortexm +participant "Ethos-U" as ethosu +end box + +box "CMSIS Device" #0091BD +participant "__VECTOR_TABLE" as ivec +participant "Reset_Handler()" as reset +end box + +box "Compiler" #FF6B00 +participant "Runtime" as runtime +end box + +box "Target" #95D600 +participant "common" as common +participant "corstone-300" as target +end box + +box "Drivers" #00C1DE +participant "NPU" as driver +participant "UART" as uart +participant "MPU" as mpu +end box + +box "Application" #7D868C +participant "main()" as main +end box + +cortexm -> ivec++: + ivec -> reset++: Reset_Handler() + reset -> reset++: SystemInit() + deactivate reset + + reset -> runtime++: __main() + note over runtime + Scatter loading + Initializing stack and heap + end note + + note over runtime + Calling constructors + end note + + runtime -> common++: init() [constructor] + note over common + The constructor is called after stack and heap have been initialized, + but before the main() function is called + end note + + common -> target++: targetSetup() + target -> uart++: uart_init() + return + + target -> driver++: ethosu_init() + return + + target -> mpu++: loadAndEnableConfig() + return + return + return + + runtime -> main++: main() + note over main + Running application + end note +@enduml diff --git a/docs/startup.svg b/docs/startup.svg new file mode 100644 index 0000000..a2c9f52 --- /dev/null +++ b/docs/startup.svg @@ -0,0 +1,84 @@ +HardwareCMSIS DeviceCompilerTargetDriversApplicationCortex-MCortex-MEthos-UEthos-U__VECTOR_TABLE__VECTOR_TABLEReset_Handler()Reset_Handler()RuntimeRuntimecommoncommoncorstone-300corstone-300NPUNPUUARTUARTMPUMPUmain()main()Reset_Handler()SystemInit()__main()Scatter loadingInitializing stack and heapCalling constructorsinit() [constructor]The constructor is called after stack and heap have been initialized,but before the main() function is calledtargetSetup()uart_init()ethosu_init()loadAndEnableConfig()main()Running application \ No newline at end of file -- cgit v1.2.1