| Contents | Index |
labBarrier
labBarrier blocks execution of a parallel algorithm until all labs have reached the call to labBarrier. This is useful for coordinating access to shared resources such as file I/O.
For a demonstration that uses labSend, labReceive, labBarrier, and labSendReceive, see the demo Profiling Explicit Parallel Communication.
In this example, all labs know the shared data filename.
fname = 'c:\data\datafile.mat';
Lab 1 writes some data to the file, which all other labs will read.
if labindex == 1
data = randn(100, 1);
save(fname, 'data');
pause(5) %allow time for file to become available to other labs
end
All labs wait until all have reached the barrier; this ensures that no lab attempts to load the file until lab 1 writes to it.
labBarrier; load(fname);
labBroadcast | labReceive | labSend | labSendReceive

See how to solve large problems with minimal effort and reduce simulation time.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |