Is it possible to use the 'save' function on thread-based workers in MATLAB Parallel Computing Toolbox?

When executing a function containing the 'save' command on parallel workers launched with 'parpool('threads')', the following error occurs:
Use of function save is not supported on a thread-based worker.
I am using Parallel Computing Toolbox R2023a on Windows 11. I launch parallel workers using 'parpool('threads')' and execute a function with 'parfeval'. This function includes the 'save' command to save a .mat file, but the above error is thrown. I understand this is expected behavior, so I have already considered using 'parpool('processes')' instead. Are there any other possible workarounds?  
In my application, workers are launched from App Designer. One possible approach is to return the data from the worker to App Designer and then save it, but since the data size is large, this does not seem appropriate.  
I believe 'parpool('processes')' is the best solution, but I would like to confirm if there are any other options.

 采纳的回答

Cause:
The 'save' function is not supported on thread-based workers in MATLAB releases prior to R2024a. This is a product limitation.
Workaround:
- Use 'parpool('processes')' instead of 'parpool('threads')'.  
- Alternatively, return the data from the worker to the main MATLAB client (such as App Designer) and perform the save operation there. However, this may not be practical if the data is very large.
Permanent Solution:
- Upgrade MATLAB to R2024a or later, where the 'save' function is supported on thread-based workers (see [MATLAB documentation](https://uk.mathworks.com/help/matlab/ref/save.html#refsect-extended-capabilities)).
- If upgrading is not possible and neither workaround is suitable, consider filing an enhancement request to MathWorks, as feature priorities are influenced by customer requests.

1 个评论

I have never heard of Mathworks providing enhancements to older Mathworks versions -- as would be required here if upgrading is not possible.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息

产品

版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by