Problem with zero-length data using parfor (transfer problem?)

1 回表示 (過去 30 日間)
Muhammad Haziq Kamarul Azman
Muhammad Haziq Kamarul Azman 2019 年 3 月 8 日
コメント済み: Eric Machorro 2021 年 8 月 22 日
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.

回答 (1 件)

maitehar
maitehar 2021 年 1 月 19 日
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 件のコメント
Eric Machorro
Eric Machorro 2021 年 8 月 22 日
I would appreciate an answer this question as well. I am having the same problem.
Eric Machorro
Eric Machorro 2021 年 8 月 22 日
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.

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by