magu_
magu_

Reputation: 4856

Multithreading in Matlab

I have the following program flow, with a big Datablock D

S1 -> S2 -> S3 -> S4

Where S1 and S4 both read and write D. S2 and S3 both only read D.

Now I would like to create the following program flow in matab

  S1 ->  S2  -> Wait for S2 and S3 to finish -> S4
     |       |
     +-> S3 -+

where S2 and S3 are executed in parallel. My Question is how to achieve that without copying D, since this is shouldn't be necessary (no locking required) and it is big.

Upvotes: 1

Views: 74

Answers (1)

Daniel
Daniel

Reputation: 36710

Using Matlab-Code that is not possible. There is no multi-threading in matlab.

There exists the parallel computing toolbox, but this toolbox uses multiple processes, which requires copying at least the used parts of D to the workers.

The only possibility for multi threading i am aware of is implementing S2 and S3 as one mex-function (C or C++ code), using OpenMP or similar.

Upvotes: 1

Related Questions