Effacer les filtres
Effacer les filtres

parfor fails with loop indices being uint64

1 vue (au cours des 30 derniers jours)
Eli4ph
Eli4ph le 27 Oct 2017
Commenté : Eli4ph le 23 Jan 2018
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 commentaires
Jan
Jan le 27 Oct 2017
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 le 27 Oct 2017
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

Connectez-vous pour commenter.

Réponse acceptée

Edric Ellis
Edric Ellis le 30 Oct 2017
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 commentaire
Eli4ph
Eli4ph le 23 Jan 2018
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by