- at each iteration of your parfor loop, you log your progress into a file and then, if MATLAB or Windows crashes, you read that file.
- you use the DataQueue class to send back data to your main MATLAB process and you log the information in a file (see this documentation).
Saving and resuming the parfor states
조회 수: 11 (최근 30일)
이전 댓글 표시
Is it possible to save the states of parfor loop, stop/break and restart from the same state. For example, in may case some time Windows crashes and I can not run the simulaiton from the same state, I have to run from initial level. In a simple for loop, I can save the variable i and ourval then I can run the for loop. In the code shown below, I have only variable i chaning in the parfor. Can I save parfor states after some interval and after restarting Matlab I can have all the variables in the wokspace resume parfor from same states.
% cubeL=51;
% XYZw=[90 100 108];
% P_labs, xyz nx3 matrix
% some_function is a function
ourval=zeros(size(xyz));
parfor i=1:cubeL*cubeL*cubeL
ourval(i,:)= some_function(xyz(i,:),P_labs,rgb,XYZw);
endd
댓글 수: 0
채택된 답변
Nicolas B.
2019년 8월 26일
Hi Imran,
I would suggest 2 solutions:
Does it helps you?
댓글 수: 2
Nicolas B.
2019년 8월 27일
Hi,
I haven't much time so I haven't tested your code. However, when calling a parfor loop, you must already have created the data at the right size (no resizing in parfor for common data). So try to create ourval before parfor.
For the code 2, try to write send(q, num2str(i)) in the loop instead of what you have. If what I suspect is right, I think that it should call disp(i) at the end of each loop.
I let you try. If I find time this afternoon, I will try to run your code.
Regards
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!