필터 지우기
필터 지우기

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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by