Parallel communication using parfor with appdesigner

Hi!
I have an app built with appdesigner. With this app, I am communicating with two different devices on two different ports (and two different protocols).
I use a timer for the communication. As the communication is the most time-consuming part of the app, I would like to speed it up a bit. I thought to do that by running the communication with the two devices with parallel computing, something like
q = parallel.pool.DataQueue;
r = parallel.pool.DataQueue;
afterEach(q, @app.read_SASA);
afterEach(r, @app.read_CAN);
parfor i = 1:1
if i == 1
%%%%%%% read_SASA %%%%%%%%%%%
send(q,1);
else
%%%%% read_CAN %%%%%
send(r,1);
end
end
where the two functions in the form
function results = read_SASA(app,data)
"some code here"
end
function results = read_CAN(app,data)
"some other code here"
end
The functions, if used outside of the parfor, work just fine.
On the other hand, if I use the "parfor" for running a basic function like "disp", it does not work, it gets stuck.
Is there a problem with using parfor inside timers in apps which I am not aware of?
Thanks in advance
Marco

댓글 수: 1

Interesting Marco. It makes sense that a for-loop would work, since the time object should be run off of the main execution thread. But when adding parfor, I'm not sure if it can run on anything other than the main execution thread. What do you mean "it gets stuck"? disp doesn't display something, MATLAB hangs, MATLAB errors out?
Another consideration is to swap parfor/DataQueue with parfeval/fetchNext and see if that works.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2020년 11월 6일

댓글:

2020년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by