Azzera filtri
Azzera filtri

parfor fails with loop indices being uint64

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Jan
Jan il 27 Ott 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 il 27 Ott 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

Accedi per commentare.

Risposta accettata

Edric Ellis
Edric Ellis il 30 Ott 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 Commento
Eli4ph
Eli4ph il 23 Gen 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Parallel for-Loops (parfor) in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by