フィルターのクリア

parfor fails with loop indices being uint64

1 回表示 (過去 30 日間)
Eli4ph
Eli4ph 2017 年 10 月 27 日
コメント済み: Eli4ph 2018 年 1 月 23 日
Documentation on parfor says that the loop indices can be of type uint64.
But with the following code, parfor fails. Either setting N to uint64(100) or changing the type of N to double/uint32 makes the code work. Is this a bug?
N = uint64(50);
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% fail
N = uint64(100);
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% work
N = uint32(50);
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% work
N = 50;
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% work
The error report is
An UndefinedFunction error was thrown on the workers for 'A'.
This might be because the file containing 'A' is not
accessible on the workers. Use addAttachedFiles(pool, files)
to specify the required files to be attached. See the
documentation for 'parallel.Pool/addAttachedFiles' for more
details.
Caused by:
Undefined function or variable 'A'.
  4 件のコメント
Jan
Jan 2017 年 10 月 27 日
The question is still not clear: What does "fail" and "work" exactly? Please post again:
N = uint64(50);
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% Does it work?
N = 50;
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end
% Does it work?
Which Matlab version are you using?
Rik
Rik 2017 年 10 月 27 日
On R2017b (on 64 bit W10), the code below results in the mentioned error as well.
N = uint64(100);
A = zeros(3,N);
parfor r = 1:N
A(:,r) = rand(3,1);
end

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

採用された回答

Edric Ellis
Edric Ellis 2017 年 10 月 30 日
This is indeed a bug in the implementation of parfor. Thanks for reporting this, we'll endeavour to fix this in a future release of MATLAB / Parallel Computing Toolbox. For now, I'm afraid the only workaround is to avoid using uint64 loop bounds for parfor.
  1 件のコメント
Eli4ph
Eli4ph 2018 年 1 月 23 日
Could you explain a bit more? Does this bug affect other functions provided by MATLAB, in particular integer arithmetic (plus/minus and multiplication/division/remainder). Due to this bug, I feel unsafe about doing things with integral type. However now I have to pass data from MATLAB to C++ MEX file. Sorry to bother you again.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by