aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorJonny Svärd <jonny.svaerd@arm.com>2023-12-18 17:19:15 +0100
committerJonny Svärd <jonny.svaerd@arm.com>2023-12-19 12:54:45 +0100
commita2732ecd9cb5f5ad76b34a01b4c9b03297c845b8 (patch)
treeb8bb840b5b4bedaa5196c12ebd3933c5359e646b /README.md
parent0189cd2b334b2d88302d13d6003c50a642db0bb5 (diff)
downloadethos-u-core-driver-a2732ecd9cb5f5ad76b34a01b4c9b03297c845b8.tar.gz
Support timeout for interrupt semaphore24.02-rc124.02
Introduce ETHOSU_INFERENCE_TIMEOUT CMake variable to set an arbitrary timeout value that will be sent as argument to ethosu_semaphore_take() for the interrupt semaphore. Adding the ability to have a timeout for an inference. (Defaults to no timeout/wait forever.) Implement a placeholder mutex for the baremetal example and add error checks for mutex_create() call. Change-Id: Ia74391620340a27c23dc3d15f9ba742c674c8bfa Signed-off-by: Jonny Svärd <jonny.svaerd@arm.com>
Diffstat (limited to 'README.md')
-rw-r--r--README.md30
1 files changed, 25 insertions, 5 deletions
diff --git a/README.md b/README.md
index 9e077b3..6be63bc 100644
--- a/README.md
+++ b/README.md
@@ -160,6 +160,23 @@ environemnts where multi-threading is possible, e.g., RTOS, the user is
responsible to provide implementation for mutexes and semaphores to be used by
the driver.
+The mutex and semaphores are used as synchronisation mechanisms and unless
+specified, the timeout is required to be 'forever'.
+
+The driver allows for an RTOS to set a timeout for the NPU interrupt semaphore.
+The timeout can be set with the CMake variable `ETHOSU_INFERENCE_TIMEOUT`, which
+is then used as `timeout` argument for the interrupt semaphore take call. Note
+that the unit is implementation defined, the value is shipped as is to the
+`ethosu_semaphore_take()` function and an override implementation should cast it
+to the appropriate type and/or convert it to the unit desired.
+
+A macro `ETHOSU_SEMAPHORE_WAIT_FOREVER` is defined in the driver header file,
+and should be made sure to map to the RTOS' equivalent of
+'no timeout/wait forever'. Inference timeout value defaults to this if left
+unset. The macro is used internally in the driver for the available NPU's, thus
+the driver does NOT support setting a timeout other than forever when waiting
+for an NPU to become available (global ethosu_semaphore).
+
The mutex and semaphore APIs are defined as weak linked functions that can be
overridden by the user. The APIs are the usual ones and described below:
@@ -167,16 +184,16 @@ overridden by the user. The APIs are the usual ones and described below:
// create a mutex by returning back a handle
void *ethosu_mutex_create(void);
// lock the given mutex
-void ethosu_mutex_lock(void *mutex);
+int ethosu_mutex_lock(void *mutex);
// unlock the given mutex
-void ethosu_mutex_unlock(void *mutex);
+int ethosu_mutex_unlock(void *mutex);
// create a (binary) semaphore by returning back a handle
void *ethosu_semaphore_create(void);
-// take from the given semaphore
-void ethosu_semaphore_take(void *sem);
+// take from the given semaphore, accepting a timeout (unit impl. defined)
+int ethosu_semaphore_take(void *sem, uint64_t timeout);
// give from the given semaphore
-void ethosu_semaphore_give(void *sem);
+int ethosu_semaphore_give(void *sem);
```
## Begin/End inference callbacks
@@ -187,6 +204,9 @@ To avoid memory leaks, any allocations done in the ethosu_inference_begin() must
be balanced by a corresponding free of the memory in the ethosu_inference_end()
callback.
+The end callback will always be called if the begin callback has been called,
+including in the event of an interrupt semaphore take timeout.
+
```[C]
void ethosu_inference_begin(struct ethosu_driver *drv, void *user_arg);
void ethosu_inference_end(struct ethosu_driver *drv, void *user_arg);