For addAttache​dFiles(myP​ool,'mydir​'), how to add the Subfolders of 'mydir' recursively to the search path of worker?

2 次查看(过去 30 天)
In the client I opened several workers by MDSC with MJS cluster "MyMJScluster" using multiple computers as node PC.
parpool('MyMJScluster')
Because the node PC does not have the necessary code to execute the spmd block, I need to attach all code files under several folders to them.
poolobj = gcp('nocreate')
addAttachedFiles(poolobj,{'D:\code\myCodeFolder1', 'E:\codeMatlab\myCodeFolder2',})
Then I run a function which has a spmd block.
spmd
% code that use all files in {'D:\code\myCodeFolder1', 'E:\codeMatlab\myCodeFolder2',}
End
These folders not only has .m file, .p file and .mex file, but also has other files such as .txt, .pzfx , .mat, .exe, .dll that need to be accessed in worker by using “which” to find the local path and then run or read them. Most of all the above files are located in subfolders and even sub-sub-sub folders.
The problem is that for addAttachedFiles, although those entries listed in the addAttachedFiles are added to the top of the command search path in the worker session, subfolders of the entries are not added to the path, even though they are included in the folder structure of workwer. This cause the problem that worker cannot find those files automatically.
Is there a way to add the paths recursively for these folders to Matlab search path on the worker?
Thanks.
  1 个评论
raym
raym 2018-9-11
By the way, if in this function I have three spmd block to run under same workers, can I just attach the folders only once at the lines after parpool and before the first spmd block?

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2018-9-11
genpath() and split at the : characters to get the cell array to attach.
regexp(genpath(FOLDER), ':', 'split')

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by