Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Problem with parfor
Date: Fri, 23 Oct 2009 07:22:19 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 26
Message-ID: <hbrljb$7os$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256282539 7964 172.30.248.35 (23 Oct 2009 07:22:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 23 Oct 2009 07:22:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2055496
Xref: news.mathworks.com comp.soft-sys.matlab:579499


Hi everyone,

Long-time reader, first time poster.

I am currently trying to improve the performance of a program I am working on by carrying out operations in parallel. The basic code that I am using for this operation is something like:

for i = 1:Mdivs
    parfor j = 1:Ndivs
                pic = fun1(img1((i-1)*step+1:min([factor+(i-1)*step,M]),(j-1)*step+1:min(factor+(j-1)*step,N),:));
        motion(i,j,:) = fun2(pic);
    end
end

fun1 takes an RGB image, processes it and returns a grayscale image. fun2 processes the grayscale image and returns a two-element vector (1x1x2 in size actually), which I store at the appropriate location in motion. step,factor,M and N are of class double. They are used to extract a subimage from the image img1.

The problem that I have is that the code behaves very erratically. Sometimes, the execution is perfect, but at other times I get the following error message:-

Error using ==> parallel_function at 594
Subscripted assignment dimension mismatch.

Error in ==> control2 at 22
    parfor j = 1:Ndivs
 
I have spent a long time trying to figure out any pattern in the instances which cause the error, but have come up with squat. Any suggestions at all would be very helpful.

Thanks and cheers!