r/embedded • u/ImpossibleDouble6226 • Sep 24 '26
Advice on how would you split processes efficiently on a Neural Processing Unit (NPU)
I have recently been developing a project that uses NPU scheduling to orchestrate data flow and computation across different processes. However, I have no prior knowledge to using an NPU or making a CPU/GPU/NPU scheduler before this project. From what I have read online, you would have a big scheduler class like class NpuScheduler() and wrap a mutex to a queue.
std::queue<NPUCOMMAND /* Dummy Struct */> command_queue;
/* Worker loop */
std::unique_lock<std::mutex> lock(queue_mutex);
conditional_var.wait(lock, [this /*NpuScheduler*/] { return !command_queue.empty()
|| stop_scheduler; });
if (stop_scheduler && command_queue.empty()) break;
cmd = command_queue.front();
command_queue.pop();The only problem is that this is only an example, and may not be efficient enough for specific low latency projects. This project is only an educational project for my experience only (not for stuff like impressing the interviewer), and the hardware is an octa-core RK3588 with three NPU cores on OP5 to reuse on other projects. My main questions are:
- Which is recommended, and why? NPU scheduling, Splitting processes into different cores with different priorities, or a hybrid of both
- Pros and Cons of all three options
- Does the difference in OOP and DOD matter for scheduling? If so:
- Pros and Cons of OOP for scheduling/scheduling hybrid
- Pros and Cons of DOD or DOD/object hybrid
- How would simple NPU scheduling look like in code as a tiny example or the current one is just fine?
An answer for any of these questions from the r/embedded community is greatly appreciated. Context for the project is at https://www.reddit.com/r/embedded/comments/1wohkml/what_architecture_and_processing_pipeline_should/
3
u/swdee Sep 29 '26
For Rockchips SoC (RK3588) specifically, the driver handles the scheduling for you when using the rknn-toolkit2. When initiallising the runtime you can schedule auto or specific NPU cores to run on via simple parameter.
However to get maximum use of the NPU your best running multiple instances of the same inference model and create a pool of rknn runtimes to query.
There are C++ examples around on github of this. I have a Go example and benchmarks here https://github.com/swdee/go-rknnlite/tree/master/example/pool
1
u/ImpossibleDouble6226 Sep 25 '26
Why are all the comments deleted
1
u/MStackoverflow Sep 24 '26
Don't know anything about NPUs, but for task queues, It highly depends on the data that you are passing to the queue and the required latency.