Problem with zero-length data using parfor (transfer problem?)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I use parfor to perform some computations (mostly to speed it up). Specifically, I perform the operation for several values of and .
In code, I wrote this as
parfor ii=parIdx,
Y(:,:,ii) = Alpha(ii)*X(:,:,ii)*getR(ii);
end
The variable Y has been instantiated beforehand, as well as parIdx. getR calculates the matrix for the i-th index.
I know this code works in serial (i.e. using the non-parallel for) because I have done this exact computation multiple times without failing, across all my dataset. After changing, I obtained this error
Error using distcomp.remoteparfor/getCompleteIntervals (line 246)
Index exceeds the number of array elements (0).
Error in [...] % I removed this; It's not important anyway
parfor ii=parIdx, Y(:,:,ii) = Alpha(ii)*X(:,:,ii)*getR(ii); end
The error suggests that one of the elements is zero in size, but I know that this cannot be true (because it should have thrown this in serial). I tried running the code again, and to my surprise, no error showed up!
Is this something to be expected? Or am I doing something wrong?
P.S. This line is within a function. I don't know if this is useful to mention or not.
Réponses (1)
maitehar
le 19 Jan 2021
Hello, it's been a year, but, could you figure out what was it? I'm having the same issue, runing my code on HPC. So I'm sometimes concerned the issue lays in the computer set up (which means I need support ti fix it). If it's an issue in my code is always better, since I should be able to fix it myself.
Warm regards,
Maite
2 commentaires
Eric Machorro
le 22 Août 2021
I would appreciate an answer this question as well. I am having the same problem.
Eric Machorro
le 22 Août 2021
I did some further research on this ... in particular https://www.mathworks.com/matlabcentral/answers/33344-does-parfor-support-global-variables?s_tid=answers_rc1-1_p1_BOTH has useful commentary here.
My specific issue seems to stem from the fact that globally defined variables do not transfer welll after initiating a parallel process. They seem to often 'reset' to unitialized variables w/in the spawned sub-processes.
In your case however, there isn't any evidence that you're using global variables.
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!