Running more parallel lightweight threads/processes/functions than available workers
조회 수: 12 (최근 30일)
이전 댓글 표시
Parallel computing question: What architectural approaches are available in MATLAB when the number of desired parallel processes exceeds the number of workers allowed in a parallel pool? I'd like to setup a flexible set of signal processing chains for post processing raw radar data (no real-time requirements). I have multiple streams (channels) of incoming raw data packetized into messages by each radar transmission event. Each stream needs to pass through a multi-step signal processing chain where the output of one step feeds the input of one or more others. Each source stream needs to go through a different progression of steps. Some processing steps need to collect input messages from multiple sources. I envision a config file defining all the processors that are needed and identify which source streams they need as input and which output streams they will produce. This is a classic publish/subscribe network. Perhaps there is a master process the instantiates and registers the processors and passes the messages between them. I also envision the processors are continuously running, waiting for a next message to process. One reason for this approach is that some steps may require multiple messages from one or more source streams before they can produce an output message (simplistic example would be a sliding median over N-events). Access to a stream's history could enable this, but would be inefficient. Perhaps a class object with storage and the processor as a method would work, or a function with persistent memory. The problem I'm having is understanding how to get this to work within the confines of MATLAB's parallel processing construct when the total number of signal processor elements is far greater than the number of workers allowed in a parallel pool. They are individually lightweight processes, but I need a lot of them running in parallel and preferrably utilizing the resources of my computer efficiently. Broad stroke solution approaches are welcome.
댓글 수: 0
답변 (1개)
Nithin
2025년 10월 31일
No, you cannot run more parallel threads, processes, or functions simultaneously than there are available workers in MATLAB's parallel pool. However, you can schedule more tasks than you have workers, and MATLAB will queue them executing as many in parallel as you have workers and running the rest as soon as workers become available.
To implement the required architecture and work within MATLAB’s constraint that only as many tasks as there are workers can run in parallel, you can use a master scheduler with "parfeval" to flexibly manage a much larger logical network of processing elements.
In this approach, you create a master process that reads your configuration file to build a dependency graph representing all processors and their required inputs and outputs. The master process maintains a queue of tasks that are ready to run, meaning all their input data is available. As workers become free, the master submits new processing tasks to the parallel pool using "parfeval", which allows you to queue far more tasks than there are workers.
Each processor can be implemented as a stateless function or a stateful object, handling any required history or multi-message logic internally. When a task completes, the master collects its output, updates the dependency graph, and checks whether any downstream processors now have all their inputs satisfied, queuing those for execution. This design efficiently utilizes available workers, dynamically schedules processing steps, and allows you to model complex publish/subscribe or DAG-style processing chains, even when the number of logical processors far exceeds the number of available parallel workers.
In summary, this approach maximizes resource utilization while supporting flexible, scalable processing chains in MATLAB. For more information, refer to the following documentation: https://www.mathworks.com/help/matlab/ref/parfeval.html
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!