Run two functions on two cores .. in a dual core processor..

I want to run two functions on two cores of my dual core processor. The functions are independent of each other.Is it possible to do so? If not what other applications or softwares are there to do such parallel processing?

Answers (2)

Yes, you can run two independent functions on independent cores. The easiest way is probably to start to sessions of MATLAB. See my answer here: http://www.mathworks.com/matlabcentral/answers/31056-run-two-functions-in-parallel
"... you could try running two MATLAB sessions. If you are on Windows you could use ActiveX to communication between the sessions. You might be able to stick everything in a parfor loop to handle the communications and the MATLAB sessions behind the scenes."
This is a very general question.
  1. You can run two instances of Matlab in parallel.
  2. The Parallel Computing Toolbox allows to run different jobs on different cores inside one Matlab session.
  3. Different threads can be started in nearly every programming language. Under Windows the API allows spawning threads, under Linux pthreads is a reliable library.

9 Comments

Can you suggest whre from to learn the programming of this kind??
It depends on what you want to achieve. It matters if you only want to run a small student project, or if you want to create a professional software package for flight control.
So waht exactly is "programming of this kind"?
Perhaps you should ask Google for "programming multi-thread".
I want to run two independent control loops on two cores in parallel.
@Sampath, I would start with running two independent instances of MATLAB. If that doesn't meet your needs, then provide additional information about the problem.
I want to run two independent functions of a program in parallel so that execution time is fast and use the results later in the program.
For now we can assume that the functions are one adding an array and other subtracting an array.
But the functions i'm using are far time consuming than the above functions.
Please help.
All of Jan's suggestions still apply to your situation.
Perhaps you should look at http://www.mathworks.com/help/toolbox/distcomp/spmd.html
The functions are not single program multiple data.. it is different programs single data.. i want these different programs to run in parallel.
Do you have the program already? If so, in which programming language is it written? How long does it run?
It would be a waste of time, if you spend more time in the parallelization than will be saved finally.
spmd code outline:
if labindex is 1, call function 1
else, call function 2
end
This is a single program, but the effect is completely different for the two parallel processes.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 4 Mar 2012

Community Treasure Hunt

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

Start Hunting!