User`s guide

Partition a Datastore in Parallel
6-67
Rather than let the software calculate the number of partitions, you can explicitly set
this value, so that the data can be appropriately partitioned to fit your algorithm. For
example, to parallelize data from within an spmd block, you can specify the number of
workers (numlabs) as the number of partitions to use. The following function uses an
spmd block to perform a parallel read, and explicitly sets the number of partitions equal
to the number of workers. To run this example, copy and save the function.
function [total,count] = spmdSumAndCountArrivalDelay(ds)
spmd
subds = partition(ds,numlabs,labindex);
[total,count] = sumAndCountArrivalDelay(subds);
end
total = sum([total{:}]);
count = sum([count{:}]);
end
Now the MATLAB code calls the function that uses an spmd block.
reset(ds);
tic
[total,count] = spmdSumAndCountArrivalDelay(ds)
spmdtime = toc
mean = total/count
Analyzing and transferring files to the workers ...done.
total =
17211680
count =
2417320
spmdtime =
10.4095