How can I run two function in parallel?
Ältere Kommentare anzeigen
I want to run two function in parallel for execution time minimization. Is it possible in matlab. I have two function func1 and func2. The func2 depends on func1. func2 takes 2.5 second and func2 takes 1.5 second for execution. i want to run func1 and func2 simultaneously for reducing execution time. If the two function run simultaneously, then func2 have to wait only for 1s (may be)............
5 Kommentare
Pawel Ladosz
am 14 Aug. 2016
Hi,
What do you mean by func2 depends func1? func2 takes output of func1 and manipulates it?
K M Ibrahim Khalilullah
am 15 Aug. 2016
Walter Roberson
am 15 Aug. 2016
Does func2 require only a partly computed value? If func2 requires the completely computed output of func1 then it must be run in serial with func1 and you cannot save any time by using parallel computing.
K M Ibrahim Khalilullah
am 15 Aug. 2016
Pawel Ladosz
am 15 Aug. 2016
I don't see how this could happen, unless you can run parts of func2 without the output of func1. In that case you could try and split func2 into two more functions, one of which could be run parallel with func1.
Antworten (1)
Walter Roberson
am 15 Aug. 2016
1 Stimme
Use spmd . You can transfer data from one worker to the other using labSend() and labReceive()
3 Kommentare
G Newton
am 15 Aug. 2016
but ones i was runing function in parallel then its remove the variables after excutions?
Walter Roberson
am 15 Aug. 2016
Yes, as usual, the local workspace of a function will be destroyed when the function returns.
K M Ibrahim Khalilullah
am 16 Aug. 2016
Bearbeitet: K M Ibrahim Khalilullah
am 16 Aug. 2016
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!