Hi all,
I'm trying to share information between workers. I want to share a counter of the loop (parfor) and the elapsed time of the iteration (both of them allow me to see the progress of the script).
I've managed to use the parallel.pool.DataQueue along with afterEach in order to share the counter between workers but I can't seem to make it work with the elapsed time.
My code:
D = parallel.pool.DataQueue;afterEach(D, @nUpdateWaitbar);counter = 0;parfor ... time = tic; %compute something..
elapsedTime = toc(time); send(D,counter);endfunction nUpdateWaitbar(~) counter = counter + 1; %do something with counter - works fine.
%do somthing with elapsedTime - doesn't work.
end
I've tried to use parallel.pool.PollableDataQueue to share the elapsedTime:
D = parallel.pool.DataQueue;shareTime = parallel.pool.PollableDataQueue;afterEach(D, @nUpdateWaitbar);counter = 0;parfor ... time = tic; %compute something.. elapsedTime = toc(time); send(shareTime,elapsedTime); send(D,counter);endfunction nUpdateWaitbar(~) elapsedTime = poll(shareTime); counter = counter + 1; %do something with counter - works fine. %do somthing with elapsedTime - doesn't work.end
But unfortunately it didn't work.
Any ideas?
Thanks in advance!
Best Answer