codistributor2dbc.defaultWorkerGrid - Default computational grid for 2-D block-cyclic distributed arrays - MATLAB (original) (raw)
Main Content
Default computational grid for 2-D block-cyclic distributed arrays
Syntax
Description
[grid](#mw%5Fad95224d-e388-4c9c-b372-64ade7fa9aae) = codistributor2dbc.defaultWorkerGrid
returns a vector defining a computational grid of nrow-by-ncol
workers such that the product is the number of workers running in the current spmd block or communicating job. To get the number of workers running in the current spmd block, use the spmdSize function. The grid defined by codistributor2dbc.defaultWorkerGrid
is as close to a square as possible. The following rules define the nrow
andncol
of the grid:
- If the number of workers running in the current
spmd
block is a perfect square,nrow = ncol = sqrt(`spmdSize`)
. - If the number of workers running in the current
spmd
block is an odd power of 2, thennrow = ncol/2 = sqrt(`spmdSize`/2)
. nrow <= ncol
.- If the number of workers running in the current
spmd
block is a prime number,nrow = 1
,ncol =`spmdSize`
. nrow
is the greatest integer less than or equal tosqrt(`spmdSize`)
for whichncol =`spmdSize`/nrow
is also an integer.
Examples
Use codistributor2dbc.defaultWorkerGrid
to get the layout of the default computational grid for 2-D block-cyclic distributed arrays in anspmd
block.
Create a parallel pool with four workers.
When you execute an spmd
block after creating a parallel pool, by default, all available workers in the pool run the code inside the spmd block.
View the computational grid layout of the default distribution scheme for the current spmd
block.
spmd grid = codistributor2dbc.defaultWorkerGrid end
Worker 3:
grid =
2 2
Worker 4:
grid =
2 2
Worker 1:
grid =
2 2
Worker 2:
grid =
2 2
Output Arguments
Default computational grid for 2-D block-cyclic distributed arrays in anspmd
block, returned as a vector of nrow-by-ncol
workers. The product of nrow
*nrow
is the number of workers running the current spmd block or communicating job.
Version History
Introduced in R2009b
The codistributor2dbc.defaultLabGrid
function is now calledcodistributor2dbc.defaultWorkerGrid
. The behavior remains the same. There are no plans to remove support forcodistributor2dbc.defaultLabGrid
.