nitin
nitin

Reputation: 175

parallel computing with matlab for dependent loops

I have a kinetic monte carlo code. Now its kinetic and hence each loop updates the current state to a future state, making it to be a dependent for loop.

I want to use parallel computing feature of matlab, but it seems the famous 'parfor' command only works for independent loops.

So my question, is it possible to use parallel computing in matlab to parallelize code where loops are not independent?

Upvotes: 1

Views: 419

Answers (1)

Thomas Ibbotson
Thomas Ibbotson

Reputation: 745

Usually these kinds of calculations are done on a grid, and the grid is distributed across the workers, each worker having its own part of the grid to calculate. This can't be done independently in general because the value at one point on the grid will depend on neighbouring points. These boundary values are communicated between the workers using some mechanism such as message passing or shared memory.

In MATLAB you can either use spmd or communicating jobs with the labSend and labReceive functions or you can use distributed arrays.

Upvotes: 3

Related Questions