MATLAB使用parfor(并行计算工具箱)和带有+的自定义包 [英] MATLAB using parfor (parallel computing toolbox) and custom packages with +

查看:597
本文介绍了MATLAB使用parfor(并行计算工具箱)和带有+的自定义包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个MATLAB程序,该程序使用许多其他定制的程序包,这些程序包通常包含名称相似的文件.因此,我决定使用自定义打包方法( http: //www.mathworks.com/help/matlab/matlab_oop/scoping-classes-with-packages.html ),以便在引用我使用的各种程序包中的特定功能时有效地获得点符号.例如,我有一个名为pose的程序包,该程序包具有以下文件结构:

I am working on a MATLAB program that users many other custom-made packages, often containing similarly-named files. So I have decided to use the custom package approach (http://www.mathworks.com/help/matlab/matlab_oop/scoping-classes-with-packages.html) to effectively get dot notation when referring to specific functions within the various packages I am using. For example, I have a package called pose that has this file structure:

MATLAB % on the MATLAB path
   --- +pose
          --- detect.m
          --- MORE STUFF
   --- +tracker
          --- MORE STUFF
   --- main.m

在我的main.m文件中,有一个并行化的for循环:

In my main.m file, I have a parallelized for loop:

parfor i=start:stop
    ... BLAH BLAH
    boxes = pose.detect(stuff);
    ... BLAH BLAH
end

但是我不断收到错误消息

But I keep getting the error that

MATLAB无法确定姿势"是否是指 函数或变量. 请参见MATLAB中的Parallel for Loops,明确的变量名".

MATLAB cannot determine whether "pose" refers to a function or variable. See Parallel for Loops in MATLAB, "Unambiguous Variable Names".

查看MATLAB并行编程文档( http://www.mathworks. com/help/distcomp/programming-considerations.html ),似乎您在并行for循环内使用的所有函数在for循环内必须透明.但这似乎直接违反了MATLAB中的另一个并行编程原理,即执行parfor循环的所有工作人员必须具有与客户端相同的MATLAB搜索路径".

Looking at the MATLAB parallel programming documentation (http://www.mathworks.com/help/distcomp/programming-considerations.html), it seems like all functions that you use inside a parallel for loop must be transparent inside the for loop. But this seems in direct violation of the other parallel programming principle in MATLAB, which is that "All workers executing a parfor-loop must have the same MATLAB search path as the client".

有人知道如何调和吗?

推荐答案

找到了答案!

我从此网页 http://www.mathworks.com/help/distcomp/share-code-with-the-workers.html ,方法是将path命令放入工作程序启动文件中: matlabroot\toolbox\local\startup.m

I did the solution from this webpage http://www.mathworks.com/help/distcomp/share-code-with-the-workers.html by putting the path command in the worker startup file: matlabroot\toolbox\local\startup.m

所以我添加了行path('/custom_dir/MATLAB/', path);,它的工作效果很好.

So I added the line path('/custom_dir/MATLAB/', path);, and it worked great.

这篇关于MATLAB使用parfor(并行计算工具箱)和带有+的自定义包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆