How to pass data between parfeval

조회 수: 12 (최근 30일)
Cai Li
Cai Li 2017년 7월 29일
댓글: Cai Li 2017년 9월 20일
I'd like to run two jobs on the background using parfeval while I hope they can communicate between each other by passing the data from one job to another. For example, job A generates a data and the job B receives it. How should this work out?

채택된 답변

Walter Roberson
Walter Roberson 2017년 7월 29일
Possibly a pollable queue https://www.mathworks.com/help/distcomp/send.html -- but I cannot tell from the documentation whether it only works for parfor or if it works for parfeval as well.
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 7월 31일
If you look at DataQueue and PollableDataQueue https://www.mathworks.com/help/distcomp/parallel.pool.dataqueue.html they say,
"You can construct the queue on the workers and send it back to the client to enable communication in the reverse direction. However, you cannot send a queue from one worker to another. Use spmd, labSend, or labReceive instead."
You would need to use the client as the switchboard for this to work.
For worker-to-worker communications you would need labSend / labReceive. You might also be able to use MPI; see https://www.mathworks.com/matlabcentral/linkexchange/links/840-parallel-programming-with-mpi
Cai Li
Cai Li 2017년 9월 20일
Hi Walter,
Thanks for your comments. Sorry for such late response, took some time to write the code. I tried using client as a switchboard while I think it simply cannot pass data from client to the worker through queue. As for labSend and labReceive, I think it doesn't work in perfeval. For some reason, I have to use perceval to run my script on the background. Instead, I figured out a way to pass the data by simply saving it to a file in one worker and reading the file in another worker, which is surprisingly fast (at least for me) Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by