User`s guide
Working with Codistributed Arrays
5-7
number is not evenly divisible by the number of workers, MATLAB partitions the array
as evenly as possible.
MATLAB provides codistributor object properties called Dimension and Partition
that you can use to determine the exact distribution of an array. See “Indexing
into a Codistributed Array” on page 5-14 for more information on indexing with
codistributed arrays.
Distribution of Other Data Types
You can distribute arrays of any MATLAB built-in data type, and also numeric arrays
that are complex or sparse, but not arrays of function handles or object types.
Creating a Codistributed Array
You can create a codistributed array in any of the following ways:
• “Partitioning a Larger Array” on page 5-7 — Start with a large array that is
replicated on all workers, and partition it so that the pieces are distributed across
the workers. This is most useful when you have sufficient memory to store the initial
replicated array.
• “Building from Smaller Arrays” on page 5-8 — Start with smaller variant
or replicated arrays stored on each worker, and combine them so that each array
becomes a segment of a larger codistributed array. This method reduces memory
requiremenets as it lets you build a codistributed array from smaller pieces.
• “Using MATLAB Constructor Functions” on page 5-9 — Use any of the MATLAB
constructor functions like rand or zeros with the a codistributor object argument.
These functions offer a quick means of constructing a codistributed array of any size
in just one step.
Partitioning a Larger Array
If you have a large array already in memory that you want MATLAB to process more
quickly, you can partition it into smaller segments and distribute these segments to all of
the workers using the codistributed function. Each worker then has an array that is a
fraction the size of the original, thus reducing the time required to access the data that is
local to each worker.
As a simple example, the following line of code creates a 4-by-8 replicated matrix on each
worker assigned to the variable A: