You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/darray.md
+248Lines changed: 248 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -211,6 +211,254 @@ across the workers in the Julia cluster in a relatively even distribution;
211
211
future operations on a `DArray` may produce a different distribution from the
212
212
one chosen by previous calls.
213
213
214
+
### Explicit Processor Mapping of DArray Blocks
215
+
216
+
This feature allows you to control how `DArray` blocks (chunks) are assigned to specific processors within the cluster. Controlling data locality is crucial for optimizing the performance of distributed algorithms.
217
+
218
+
You can specify the mapping using the optional `assignment` argument in the `DArray` constructor functions (`DArray`, `DVector`, and `DMatrix`), the `distribute` function, and also directly within constructor-like functions such as `rand`, `randn`, `sprand`, `ones`, and `zeros` using the `assignment` optional keyword argument.
219
+
220
+
The `assignment` argument accepts the following values:
221
+
222
+
*`:arbitrary`**(Default)**:
223
+
224
+
* If `assignment` is not provided or is set to symbol `:arbitrary`, Dagger's scheduler assigns blocks to processors automatically. This is the default behavior.
225
+
226
+
*`:blockrow`:
227
+
228
+
* Divides the matrix blocks row-wise (vertically in the terminal). Each processor gets a contiguous chunk of row blocks.
229
+
230
+
*`:blockcol`:
231
+
232
+
* Divides the matrix blocks column-wise (horizontally in the terminal). Each processor gets a contiguous chunk of column blocks.
233
+
234
+
*`:cyclicrow`:
235
+
236
+
* Assigns row-blocks to processors in a round-robin fashion. Blocks are distributed one row-block at a time. Useful for parallel row-wise tasks.
237
+
238
+
*`:cycliccol`:
239
+
240
+
* Assigns column-blocks to processors in a round-robin fashion. Blocks are distributed one column-block at a time. Useful for parallel column-wise tasks.
241
+
242
+
* Any other symbol used for `assignment` results in an error.
243
+
244
+
*`AbstractArray{<:Int, N}`:
245
+
246
+
* Provide an integer **N**-dimensional array of worker IDs. The dimension **N** must match the number of dimensions of the `DArray`.
247
+
* Dagger maps blocks to worker IDs in a block-cyclic manner according to this processor-array. The block at index `(i,j,...)` is assigned to the first CPU thread of the worker with ID `assignment[mod1(i, size(assignment,1)), mod1(j, size(assignment,2)), ...]`. This pattern repeats block-cyclically across all dimensions.
248
+
249
+
*`AbstractArray{<:Processor, N}`:
250
+
251
+
* Provide an **N**-dimensional array of `Processor` objects. The dimension **N** must match the number of dimensions of the `DArray` blocks.
252
+
* Blocks are mapped in a block-cyclic manner according to the `Processor` objects in the assignment array. The block at index `(i,j,...)` is assigned to the processor at `assignment[mod1(i, size(assignment,1)), mod1(j, size(assignment,2)), ...]`. This pattern repeats block-cyclically across all dimensions.
253
+
254
+
#### Examples and Usage
255
+
256
+
The `assignment` argument works similarly for `DArray`, `DVector`, and `DMatrix`, as well as the `distribute` function. The key difference lies in the dimensionality of the resulting distributed array. For functions like `rand`, `randn`, `sprand`, `ones`, and `zeros`, `assignment` is an keyword argument.
257
+
258
+
*`DArray`: For N-dimensional distributed arrays.
259
+
260
+
*`DVector`: Specifically for 1-dimensional distributed arrays.
261
+
262
+
*`DMatrix`: Specifically for 2-dimensional distributed arrays.
263
+
264
+
*`distribute`: General function to distribute arrays of any dimensionality.
265
+
266
+
*`rand`, `randn`, `sprand`, `ones`, `zeros`: Functions to create DArrays with initial values, also supporting `assignment`.
267
+
268
+
Here are some examples using a setup with one master process and three worker processes.
269
+
270
+
First, let's create some sample arrays for `distribute` (and constructor functions):
This creates distributed arrays with the specified block sizes, and assigns the blocks to processors arbitrarily. For example, the assignment for`Ad` might look like this:
This creates distributed arrays with the specified block sizes, and assigns contiguous row-blocks to processors evenly. For example, the assignment for`Ad` (and `Od`) will look like this:
This creates distributed arrays with the specified block sizes, and assigns contiguous column-blocks to processors evenly. For example, the assignment for`Ad` (and `Rd`) will look like this:
This creates distributed arrays with the specified block sizes, and assigns row-blocks to processors in round-robin fashion. For example, the assignment for`Ad` (and `Zd`) will look like this:
This creates distributed arrays with the specified block sizes, and assigns column-blocks to processors in round-robin fashion. For example, the assignment for`Ad` (and `Od`) will look like this:
The assignment is an integer matrix of worker IDs, the blocks are assigned in block-cyclic manner to the first CPU thread of each worker. The assignment for`Ad` (and `Rd`) would be:
The assignment is a matrix of `Processor` objects, the blocks are assigned in block-cyclic manner to each processor. The assignment for`Ad` (and `Rd`) would be:
0 commit comments