summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-04-08 09:54:53 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2022-04-08 12:30:28 +0100
commit4cc4021d356c174f780be2b7ef96910e36c8dd7b (patch)
treec2a790b914577873a368982a07a9491f6743443e /docs
parent11b75cc7dc140119dee490f425e25a004122703b (diff)
downloadml-embedded-evaluation-kit-4cc4021d356c174f780be2b7ef96910e36c8dd7b.tar.gz
MLECO-3070: Further HAL cleanup.
Cleaning up HAL sources by removing unnecessary redirections with function pointers. The "platform packages" under HAL are now streamlined enough to not need any major HAL wrapping (as was the case before). This allows us to have a very thin HAL layer that sits on top of the platform and compnent packs. Also helps in getting rid of "hal platform" pointer being passed around in the code to use any HAL functionality. Change-Id: I04b2057f972aad7a5cfb4a396bcdf147c9f9ef1c Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/documentation.md4
-rw-r--r--docs/sections/customizing.md80
2 files changed, 19 insertions, 65 deletions
diff --git a/docs/documentation.md b/docs/documentation.md
index 3e7a5c4..b391092 100644
--- a/docs/documentation.md
+++ b/docs/documentation.md
@@ -170,7 +170,7 @@ hal
├── include
│ ├── hal.h
│ ├── hal_lcd.h
-│ └── timer.h
+│ └── hal_pmu.h
└── source
├── components
│ ├── cmsis_device
@@ -180,7 +180,7 @@ hal
│ ├── platform_pmu
│ └── stdout
├── hal.c
- ├── hal_timer.c
+ ├── hal_pmu.c
└── platform
├── mps3
├── native
diff --git a/docs/sections/customizing.md b/docs/sections/customizing.md
index 604e708..5b822db 100644
--- a/docs/sections/customizing.md
+++ b/docs/sections/customizing.md
@@ -91,53 +91,15 @@ use-cases, sources are in the `use-case` subfolder.
The HAL is represented by the following interfaces. To access them, include the `hal.h` header.
-- `hal_platform` structure: Defines a platform context to be used by the application.
-
- | Attribute name | Description |
- |--------------------|----------------------------------------------------------------------------------------------|
- | `inited` | Initialization flag. Is set after the `platform_init()` function is called. |
- | `plat_name` | Platform name. it is set to `mps3-bare` for MPS3 build and `FVP` for Fast Model build. |
- | `timer` | Pointer to platform timer implementation (see `platform_timer`) |
- | `platform_init` | Pointer to platform initialization function. |
- | `platform_release` | Pointer to platform release function |
-
-- `hal_init` function: Initializes the HAL structure based on the compile-time configuration. This must be called before
- any other function in this API.
-
- | Parameter name | Description|
- |------------------|-----------------------------------------------------|
- | `platform` | Pointer to a pre-allocated `hal_platform` struct. |
- | `timer` | Pointer to a pre-allocated timer module |
- | `return` | Zero returned if successful, an error code is returned if unsuccessful. |
-
- `hal_platform_init` function: Initializes the HAL platform and every module on the platform that the application
requires to run.
- | Parameter name | Description |
- | ----------------| ------------------------------------------------------------------- |
- | `platform` | Pointer to a pre-allocated and initialized `hal_platform` struct. |
- | `return` | zero if successful, error code otherwise. |
+ | Parameter name | Description |
+ |--------------------------------------| ------------------------------------------------------------------- |
+ | `return` | true if successful, false otherwise. |
- `hal_platform_release` function Releases the HAL platform and any acquired resources.
- | Parameter name | Description |
- | ----------------| ------------------------------------------------------------------- |
- | `platform` | Pointer to a pre-allocated and initialized `hal_platform` struct. |
-
-- `platform_timer` structure: The structure to hold a platform-specific timer implementation.
-
- | Attribute name | Description |
- |---------------------|------------------------------------------------|
- | `inited` | Initialization flag. It is set after the timer is initialized by the `hal_platform_init` function. |
- | `reset` | Pointer to a function to reset a timer. |
- | `get_time_counter` | Pointer to a function to get current time counter. |
- | `get_duration_ms` | Pointer to a function to calculate duration between two time-counters in milliseconds. |
- | `get_duration_us` | Pointer to a function to calculate duration between two time-counters in microseconds |
- | `get_cpu_cycle_diff` | Pointer to a function to calculate duration between two time-counters in *Cortex-M55* cycles. |
- | `get_npu_cycle_diff` | Pointer to a function to calculate duration between two time-counters in *Ethos-U* cycles. Available only when project is configured with `ETHOS_U_NPU_ENABLED` set. |
- | `start_profiling` | If necessary, wraps the `get_time_counter` function with another profiling initialization, if necessary. |
- | `stop_profiling` | If necessary, wraps the `get_time_counter` function along with more instructions when profiling ends. |
-
An example of the API initialization in the main function:
```C++
@@ -146,20 +108,13 @@ An example of the API initialization in the main function:
int main ()
{
-
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
...
- hal_platform_release(&platform);
-
+ hal_platform_release();
return 0;
-
}
```
@@ -168,13 +123,12 @@ int main ()
Code samples application main function delegates the use-case logic execution to the main loop function that must be
implemented for each custom ML scenario.
-Main loop function takes the initialized `hal_platform` structure pointer as an argument.
-
The main loop function has external linkage and the main executable for the use-case references the function defined in
the use-case code.
```C++
-void main_loop(hal_platform& platform){
+void main_loop()
+{
...
@@ -198,17 +152,16 @@ For example:
#include "hal.h"
#include "AppContext.hpp"
-void main_loop(hal_platform& platform) {
-
+void main_loop()
+{
/* Instantiate application context */
arm::app::ApplicationContext caseContext;
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<uint32_t>("counter", 0);
/* loop */
- while (true) {
- // do something, pass application context down the call stack
- }
+ while (true) {
+ // do something, pass application context down the call stack
+ }
}
```
@@ -230,7 +183,8 @@ It uses platform timer to get system timing information.
An example of it in use:
```C++
-Profiler profiler{&platform, "Inference"};
+/* A named profiler instance */
+Profiler profiler{"Inference"};
profiler.StartProfiling();
// Code running inference to profile
@@ -331,7 +285,7 @@ Now define the `main_loop` function with the signature described in [Main loop f
#include "hal.h"
#include "log_macros.h"
-void main_loop(hal_platform& platform) {
+void main_loop() {
printf("Hello world!");
}
```
@@ -474,7 +428,7 @@ The following code adds inference invocation to the main loop function:
#include "HelloWorldModel.hpp"
#include "log_macros.h"
- void main_loop(hal_platform& platform) {
+ void main_loop() {
/* model wrapper object */
arm::app::HelloWorldModel model;
@@ -549,7 +503,7 @@ To add profiling for the *Ethos-U*, include a `Profiler.hpp` header and invoke b
For example:
```C++
-Profiler profiler{&platform, "Inference"};
+Profiler profiler{"Inference"};
profiler.StartProfiling();
model.RunInference();