# Segmentation error during parfor loop (remote linux server)

조회 수: 9(최근 30일)
stefano grazian 2022년 7월 6일
답변: Edric Ellis 2022년 7월 8일
I am using a Linux server with 64 GB RAM and 16 CPUs to run multiple repetitions of a MATLAB function in parallel (by using the "parfor" command); let's define this function as [Output]=myfunc(a,b,c). In particular, for "n" iterations, I have to calculate the Output of a "population" of 16 "agents", in which each agent has slightly different values of a,b,c.
Specific agents (i.e values of a,b,c) cause a worker to crash due to segmentation violation (I attach the related crash dump file).
If I run only one of these agents in a parallel pool with just one worker I get the same outcome, whereas if I don't use "parfor" the code works without any problem. Moreover, if I perform the same simulation on my Windows PC I get no error even when using the parallel pool.

댓글을 달려면 로그인하십시오.

### 답변(2개)

Daniel Duarte 2022년 7월 6일
Hello Stefano,
The main requirement of parfor is to allow Matlab to work with sections of the problem, in a vectorised fashion. Given a population of agents pop(i), we need to vectorise the output as output(i). This way we allow the parfor loop to work in parallel on each section of the problem.
A possible parfor application would be:
% initialize inputs and output
Output=zeros(16,1);
for i=1:16
pop(i).a = rand;
pop(i).b = rand;
pop(i).c = rand;
end
% implement parfor
parfor i=1:16
Output(i)=sumABC(pop(i).a,pop(i).b,pop(i).c)
end
Output
function sum = sumABC(A,B,C)
sum = A+B+C;
end
See more details at:
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Edric Ellis 2022년 7월 8일
The crash dump suggests the workers are crashing inside ipqpdense. This problem should be fixed if you upgrade to R2020a or later.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Parallel for-Loops (parfor) in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by