How to run 3 programs simultaneously?
2 views (last 30 days)
Show older comments
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??
0 Comments
Accepted Answer
Thomas
on 14 Mar 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 Comments
More Answers (1)
Jason Ross
on 14 Mar 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 Comments
Jason Ross
on 14 Mar 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.
See Also
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!