Can I use parfor within parfeval in MatlabR2019b and if yes, how?

44 views (last 30 days)
I'm encountering an issue with my MATLAB R2019b GUI project. I'm trying to display two sets of 4DCT (Four-Dimensional Computed Tomography) images simultaneously. Each set contains 10 CT volumes. While displaying the first case(two sets), I want to asynchronously load additional sets in the background. My approach involves using parfeval(@select_data, x, data{idx}) for each 4DCT, where select_data is a function utilizing parfor to read the 10 DICOM volumes.
When I run select_data independently, it performs well, utilizing all available workers efficiently (e.g., 12 workers). However, when I use parfeval, only one additional worker is utilized, leading to slower loading times (about 30-40 seconds per 4DCT). Also it causes lag in the main thread, even though I expect multiple workers to be employed for the loading process and the rest available for my main.
Here are the server specs I have access to:
CPU(s): 24
Thread(s) per core: 2
Core(s) per socket: 6
Socket(s): 2
Memory: 70GB
I've attempted to limit the number of workers to 8 in the parpool, leaving 4 cores free to handle the main GUI thread, but the lag persists.
It's possible that the issue lies with the usage of parfor within parfeval, which might not be leveraging all available workers as expected?
  6 Comments
Edric Ellis
Edric Ellis on 5 Apr 2024 at 10:06
I'm still not 100% sure I understand where the problem is in your code. Here are some thoughts:
  • Only use fetchOutputs if you need the output of a specific Future "right now". This will block for it to complete
  • You might be able to use fetchNext if you want to retrieve outputs in the order that they complete. However, this will only change the ordering of when you get the results, it will not change how long it takes until the final result is available.
  • There are various ways that you can trigger actions on completion of Futures. For instance, you could use afterAll to trigger an action when all elements of your futures array has finished. This approach leaves your client completely idle while the workers are busy.
max_hid
max_hid on 5 Apr 2024 at 12:44
Edited: max_hid on 5 Apr 2024 at 14:10
Big Update:
I think I managed to find a way to make it work like intented by only fetching in the moment I switch my case, I need to validate this further next Wednesday and will post my solution afterwards and also update on Stackoverflow.
Until then thank you very much, have a great weekend

Sign in to comment.

Answers (0)

Categories

Find more on Parallel Computing Fundamentals in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!