How to run 3 programs simultaneously?

2 visualizaciones (últimos 30 días)
Sampath reddy
Sampath reddy el 14 de Mzo. de 2012
I have to run three functions or programs on a quad core processor such that function1 is run on core1 of the processor and function2 on core2 and function3 on core3, all simultaneously in one matlab session. Can any one help??

Respuesta aceptada

Thomas
Thomas el 14 de Mzo. de 2012
I do not think there is a way to control which matlab processes run on a particular core. Matlab has a lot of inbuilt function that inherently now use multi-threading.
Though you could instantiate three MATLAB instances ( hopefully they run on different cores. haven't tried it) with the
-maxNumCompThreads
set to 1 so that each instance uses only 1 core and then run your function in each instance.
href=""<http://www.mathworks.com/help/techdoc/ref/maxnumcompthreads.html</a>>
  5 comentarios
Thomas
Thomas el 14 de Mzo. de 2012
Make sure your functions putting the output.. try
doc function
Sampath reddy
Sampath reddy el 14 de Mzo. de 2012
in the help it says we cannot get returned values from parfor sessions, is there a way to store the variable data on pc in text or some other format and calling back in the matlab?? Or any other way to return the values to workspace???

Iniciar sesión para comentar.

Más respuestas (1)

Jason Ross
Jason Ross el 14 de Mzo. de 2012
Short answer:
There is no way to control processor affinity. The tasks are handed off to the operating system, which places them as they see fit.
If you wish to control what goes on in each lab, use the spmd construct and labIndex. There is an example of how to do this under "Defining an spmd Statement" on this page:
Long answer:
There are various utilities that are very OS-specific that will let you set processor affinity for a given process. It would be somehow possible to place things if you really wanted to, but the effort would likely be in vain, as modern operating systems are quite good at doing this already, and you'd end up with code that was very tightly coupled with your specific hardware and operating system -- for what could actually be a performance loss.
  2 comentarios
Sampath reddy
Sampath reddy el 14 de Mzo. de 2012
It is not necessary that function1 is to be run on core1 or anything like that but, the three functions are to be run on three different cores simultaneously.
If u know how to do so please mention the code how to do so.
Jason Ross
Jason Ross el 14 de Mzo. de 2012
There is an example in the documentation link I provided that shows how to do this.
To be entirely pedantic and boring, I'm making an assumption that the operating system will choose to place each lab on one core -- hopefully it will. But it's not an ironclad guarantee. The only thing that can be guaranteed is that the tasks for lab1 will go to lab1, the tasks for lab2 will go to lab2 and so on.

Iniciar sesión para comentar.

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by