parallelization and mex-compiled code

1 回表示 (過去 30 日間)
martin
martin 2014 年 2 月 6 日
コメント済み: martin 2014 年 2 月 9 日
I want to optimize a mex-compiled function (fortran-90 source) defined over an 1D interval by computing its values on a sufficiently fine sampling. It works fine with a for-loop but when I try parfor (for speed) I get crashes in the mex-compiled code (getting a error from one of the workers). Is this a documented problem, and does anyone have suggestions how to localize what goes wrong?
I run MatlabR2013a and Ubuntu 13.10 on a 16 core (32 virtual) machine and I get 12 workers when I do matlabpool.
  1 件のコメント
Matt J
Matt J 2014 年 2 月 6 日
No, there is no general prohibition against using mex files with parfor. Show us the plain for-loop and the parfor version.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2014 年 2 月 6 日
編集済み: Matt J 2014 年 2 月 6 日
You should try running a plain for-loop first, but with the iterations in random order, i.e., instead of
for i=1:n
...
end
run as
for i=randperm(n)
...
end
This is a good way to test whether your code is independent of the order of the iterations (a basic requirement of parfor) before the Parallel Computing Toolbox even gets involved.
  5 件のコメント
Matt J
Matt J 2014 年 2 月 6 日
Can you try it on a different machine to see if it's hardware problem? I don't see anything wrong with the code.
martin
martin 2014 年 2 月 9 日
Thanks for your input, I will try another machine asap. Just an additional observation: The program crashes on the fortran90 statement "call mxCopyPtrToReal8(inptr_xdim,realxdim,1)" i.e a standardconstruction right out of the manualmapges for mex

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel Computing Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by