parfor fails with loop indices being uint64
1 次查看(过去 30 天)
显示 更早的评论
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
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
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
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!