How to run 3 programs simultaneously?

조회 수: 2 (최근 30일)
Sampath reddy
Sampath reddy 2012년 3월 14일
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??

채택된 답변

Thomas
Thomas 2012년 3월 14일
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
Thomas
Thomas 2012년 3월 14일
Make sure your functions putting the output.. try
doc function
Sampath reddy
Sampath reddy 2012년 3월 14일
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???

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

추가 답변 (1개)

Jason Ross
Jason Ross 2012년 3월 14일
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
Sampath reddy
Sampath reddy 2012년 3월 14일
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 2012년 3월 14일
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.

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

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by