Parallel Computing: Execute GUI and programm parallel

Hello, I would like to start a GUI (GUIDE) and parallel execute another job. Is there any solution how to realise that problem. When I start the GUI for example in a parfor no User-Interface pops up.

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de En. de 2017
It is not possible to do graphics from inside a worker.
There is a demonstration around, written by one of the Mathworks people, that deals with collecting results from multiple workers as they come in, and graphing the results. Unfortunately I do not seem to find that at the moment. It might have used parfeval.
The point is that with some care you can transfer data back to a controlling routine that plots data that has been generated by the workers; however, it does not allow multiple workers to draw graphics.

6 comentarios

Ronron
Ronron el 19 de En. de 2017
What if the GUI is independant of the other workers. That means, I have got my GUI and after starting it I want to start another programm, but the GUI should still be there and react to interactions.
Typically, a GUIDE GUI will not block -- you will have access to the command line. You can start other functions, including other GUIs. However, people who write GUIs sometimes make assumptions that they are the only GUI running, so sometimes GUIs can interfere with each other.
If you have access to the command line while you are running a GUI, then yes you can run a function that uses parfor.
One thing to keep in mind is that GUI callbacks can only occur under one of these circumstances:
  • MATLAB is waiting for interaction at the command line (including if the program used keyboard())
  • figure() is called
  • pause() or drawnow() are called
  • uiwait() or waitfor() are called
If you are running code that uses parfor() or spmd(), then the thread that is controlling the workers does not execute any of those functions periodically, and any execution of those on the workers does not affect the main display. You might end up waiting a fair while for a callback to be processed. You just might be able to reduce that by having a timer callback that does a drawnow() -- I have never experimented with that.
Because of this, if you want to run parallel routines while leaving a GUI active, you are better off using parfeval() or batch(), as those leave a thread in control that can periodically call drawnow() while it waits for the workers to finish.
Ronron
Ronron el 15 de Feb. de 2017
Editada: Ronron el 15 de Feb. de 2017
Hey Roberson, Thanks for the answer. I tried it out with parfeval() and it is possible to run stuff parallel while the GUI is active. I've got another problem to solve and maybe you can help out.
My function executed in parfeval should get as input an object of the class "MAPort". The class is from a library - loaded using the NET.Assembly().
Unfortunatley the object can't be loaded. I get the following warning message.
"Warning: Cannot load an object of class 'MAPort': No matching constructor signature found."
As I run the function normally (not by using parfeval), I don't get this message.
I hope you can help me! Thanks already. Ronja
Use parfevalOnAll to load the .Net class on all of the workers
That means calling parfevalOnAll before calling the actual function?
I tried the following.
T = parfevalOnAll(@loadNetAssembly,0);
try
import ASAM.HILAPI.dSPACE.MAPort.*;
import ASAM.HILAPI.Implementation.Common.ValueContainer.*;
catch e
error(e.message)
end
F = parfeval(@batchTest,0, myview);
And the function loadNetAssembly looks the following.
function loadNetAssembly()
NET.addAssembly('dSPACE.HILAPI.MAPort');
NET.addAssembly('dSPACE.HILAPI.Common');
NET.addAssembly('ASAM.HILAPI.Implementation');
NET.addAssembly('ASAM.HILAPI.Interfaces');
import ASAM.HILAPI.dSPACE.MAPort.*;
import ASAM.HILAPI.Implementation.Common.ValueContainer.*;
I still get the same error. Sorry if I didn't unserstand it right.
I am not familiar with how NET and import works, sorry. Perhaps you need to attach files to the pool ? https://www.mathworks.com/help/distcomp/addattachedfiles.html

Iniciar sesión para comentar.

Categorías

Preguntada:

el 19 de En. de 2017

Comentada:

el 15 de Feb. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by