Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mpipe_workqueue.h File Reference

Shared P4WQ pool for element-level work parallelism. More...

#include <zephyr/sys/p4wq.h>

Go to the source code of this file.

Variables

struct k_p4wq *const mpipe_p4wq
 Shared mpipe P4WQ pool instance.

Detailed Description

Shared P4WQ pool for element-level work parallelism.

Provides a shared P4WQ (Pooled Parallel Preemptible Priority-based Work Queue) pool that elements can use to offload and parallelize work items (e.g., tile-based AI inference, DCT transforms, etc.).

Elements use the native Zephyr P4WQ API directly (k_p4wq_submit, k_p4wq_wait) with the shared mpipe_p4wq instance, without wrapping the API.

Example usage in an element with parallel tile processing:

static void tile_handler(struct k_p4wq_work *work) {
// process one tile...
}
static bool my_chain_fn(struct mpipe_pad *pad, struct net_buf *in,
struct net_buf **out) {
struct k_p4wq_work tile_work[4];
for (int i = 0; i < 4; i++) {
tile_work[i].handler = tile_handler;
tile_work[i].priority = 7;
tile_work[i].deadline = 0;
tile_work[i].sync = true;
k_sem_init(&tile_work[i].done_sem, 0, 1);
k_p4wq_submit(mpipe_p4wq, &tile_work[i]);
}
for (int i = 0; i < 4; i++) {
k_p4wq_wait(&tile_work[i], K_FOREVER);
}
// assemble output...
*out = result;
return true;
}
#define K_FOREVER
Generate infinite timeout delay.
Definition kernel.h:1712
struct k_p4wq *const mpipe_p4wq
Shared mpipe P4WQ pool instance.
int k_sem_init(struct k_sem *sem, unsigned int initial_count, unsigned int limit)
Initialize a semaphore.
Shared P4WQ pool for element-level work parallelism.
void k_p4wq_submit(struct k_p4wq *queue, struct k_p4wq_work *item)
Submit work item to a P4 queue.
int k_p4wq_wait(struct k_p4wq_work *work, k_timeout_t timeout)
Regain ownership of the work item, wait for completion if it's synchronous.
P4 Queue Work Item.
Definition p4wq.h:36
struct k_sem done_sem
Definition p4wq.h:42
Pad structure.
Definition mpipe_pad.h:128
Network buffer representation.
Definition net_buf.h:1054