Stop a worker and continue the parallel pool in matlab

0

I have a code with a simple parfor in matlab that calls the workers.

parfor valor= 1:fim

        [output, out] = Computacao(dado1, dado2, int32(valor));
end

In the function that is called I have an if for a condition in which if I found an error it should stop, however I wanted it to stop only one worker for the value = 3 for example, and all others were computed normally. p>

I tried it as follows:

if or(((aaa+4/3*sss)./ddd) < 0, mu < 0)

    problemaaa = 1;
    fprintf('PROBLEM FOUND');
    error('deuruim');

end

But when he finds the error he does not just calculate the index with error, for all computations in progress. Is there a way I can only kill the worker from that index that encountered the error and continue normally?

    
asked by anonymous 25.05.2018 / 01:58

1 answer

0

It was not very clear to me, but I think you just want to skip to the next iteration if something specific happens, so you can use continue , it will keep trying the next conditions, a basic example would be this:

for n = 1:50
    if mod(n,7)
        continue
    end
    disp(['Divisible by 7: ' num2str(n)])
end

Result:

Divisible by 7: 7
Divisible by 7: 14
Divisible by 7: 21
Divisible by 7: 28
Divisible by 7: 35
Divisible by 7: 42
Divisible by 7: 49

In the example the algorithm jumps to the next iteration if the number is not divisible by 7 , you can do the same when your worker has the value = 3, instead of error put a continue / p>

if or(((aaa+4/3*sss)./ddd) < 0, mu < 0)

    problemaaa = 1;
    fprintf('PROBLEM FOUND');
    continue

end

I hope I understand your problem ...

    
25.05.2018 / 17:58