Dmp
dmp
A dialect for handling distributed memory parallelism (DMP).
This is xDSL only for now.
This dialect aims to provide the tools necessary to facilitate the creation and lowering of stencil (and other) computations in a manner that makes them run on node clusters.
DIM_X = 0
module-attribute
DIM_Y = 1
module-attribute
DIM_Z = 2
module-attribute
DMP = Dialect('dmp', [SwapOp], [ExchangeDeclarationAttr, ShapeAttr, RankTopoAttr, GridSlice2dAttr, GridSlice3dAttr])
module-attribute
ExchangeDeclarationAttr
Bases: ParametrizedAttribute
This declares a region to be "halo-exchanged". The semantics define that the region specified by offset and size is the received part. To get the section that should be sent, use the source_area() method to get the source area.
- offset gives the coordinates from the origin of the stencil field.
- size gives the size of the buffer to be exchanged.
- source_offset gives a translation (n-d offset) where the data should be read from that is exchanged with the other node.
- neighbor gives the offset in rank to the node this data is to be exchanged with
Example:
offset = [4, 0]
size = [10, 1]
source_offset = [0, 1]
neighbor = -1
To visualize: 0 4 14 xxxxxxxxxx 0 oooooooooo 1
Where x signifies the area that should be received,
and o the area that should be read from.
This data will be exchanged with the node of rank (my_rank -1)
Source code in xdsl/dialects/experimental/dmp.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
name = 'dmp.exchange'
class-attribute
instance-attribute
offset_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
size_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
source_offset_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
neighbor_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
offset: tuple[int, ...]
property
size: tuple[int, ...]
property
source_offset: tuple[int, ...]
property
neighbor: tuple[int, ...]
property
elem_count: int
property
dims: int
property
number of dimensions of the grid
__init__(offset: Sequence[int], size: Sequence[int], source_offset: Sequence[int], neighbor: Sequence[int])
Source code in xdsl/dialects/experimental/dmp.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
from_points(points: Sequence[tuple[int, int]], dim: int, dir_sign: Literal[1, -1], neighbor_offset: int = 1)
classmethod
Source code in xdsl/dialects/experimental/dmp.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
source_area() -> ExchangeDeclarationAttr
Since a HaloExchangeDef by default specifies the area to receive into, this method returns the area that should be read from.
Source code in xdsl/dialects/experimental/dmp.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
print_parameters(printer: Printer) -> None
Source code in xdsl/dialects/experimental/dmp.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
Source code in xdsl/dialects/experimental/dmp.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
ShapeAttr
dataclass
Bases: ParametrizedAttribute
This represents shape information that is attached to halo operations.
On the terminology used:
In each dimension, we are given four points. We abbreviate them in annotations to an, bn, cn, dn, with n being the dimension. In 2d, these create the following pattern, higher dimensional examples can be derived from this:
a1 b1 c1 d1 +--+-----------+--+ a0 | | | | +--+-----------+--+ b0 | | | | | | | | | | | | | | | | +--+-----------+--+ c0 | | | | +--+-----------+--+ d0
We can now name these points:
- a: buffer_start
- b: core_start
- c: core_end
- d: buffer_end
This class provides easy getters for these four.
We can also define some common sizes on this object:
- buff_size(n) = dn - an
- core_size(n) = cn - bn
- halo_size(n, start) = bn - an
- halo_size(n, end ) = dn - cn
Source code in xdsl/dialects/experimental/dmp.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
name = 'dmp.shape_with_halo'
class-attribute
instance-attribute
buff_lb_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
buff_ub_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
core_lb_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
core_ub_: builtin.DenseArrayBase[builtin.I64]
instance-attribute
buff_lb: tuple[int, ...]
property
buff_ub: tuple[int, ...]
property
core_lb: tuple[int, ...]
property
core_ub: tuple[int, ...]
property
dims: int
property
Number of axis of the data (len(shape))
from_index_attrs(buff_lb: stencil.IndexAttr | Sequence[int], core_lb: stencil.IndexAttr | Sequence[int], core_ub: stencil.IndexAttr | Sequence[int], buff_ub: stencil.IndexAttr | Sequence[int])
staticmethod
Source code in xdsl/dialects/experimental/dmp.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
buffer_start(dim: int) -> int
Source code in xdsl/dialects/experimental/dmp.py
308 309 310 | |
core_start(dim: int) -> int
Source code in xdsl/dialects/experimental/dmp.py
312 313 314 | |
buffer_end(dim: int) -> int
Source code in xdsl/dialects/experimental/dmp.py
316 317 318 | |
core_end(dim: int) -> int
Source code in xdsl/dialects/experimental/dmp.py
320 321 322 | |
buff_size(dim: int) -> int
Source code in xdsl/dialects/experimental/dmp.py
326 327 328 | |
core_size(dim: int) -> int
Source code in xdsl/dialects/experimental/dmp.py
330 331 332 | |
halo_size(dim: int, at_end: bool = False) -> int
Source code in xdsl/dialects/experimental/dmp.py
334 335 336 337 338 | |
print_parameters(printer: Printer) -> None
Source code in xdsl/dialects/experimental/dmp.py
342 343 344 345 346 | |
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
Parses the attribute, the format of it is:
dmp.shape_with_halo<[a0,b0,c0,d0]x[a1,b1,c1,d1]x...>
so different from the way it's stored internally.
This decision was made to improve readability.
Source code in xdsl/dialects/experimental/dmp.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
RankTopoAttr
Bases: ParametrizedAttribute
This attribute specifies the node layout used to distribute the computation.
dmp.grid<3x3> means nine ranks organized in a 3x3 grid.
This allows for higher-dimensional grids as well, e.g. dmp.grid<3x3x3> for 3-dimensional data.
Source code in xdsl/dialects/experimental/dmp.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | |
name = 'dmp.topo'
class-attribute
instance-attribute
shape: builtin.DenseArrayBase[builtin.I64]
instance-attribute
__init__(shape: Sequence[int])
Source code in xdsl/dialects/experimental/dmp.py
401 402 403 404 | |
as_tuple() -> tuple[int, ...]
Source code in xdsl/dialects/experimental/dmp.py
406 407 408 | |
node_count() -> int
Source code in xdsl/dialects/experimental/dmp.py
410 411 | |
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
Source code in xdsl/dialects/experimental/dmp.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
print_parameters(printer: Printer) -> None
Source code in xdsl/dialects/experimental/dmp.py
428 429 430 431 | |
DomainDecompositionStrategy
dataclass
Bases: ParametrizedAttribute, ABC
Source code in xdsl/dialects/experimental/dmp.py
434 435 436 437 438 439 440 441 442 | |
calc_resize(shape: tuple[int, ...]) -> tuple[int, ...]
Source code in xdsl/dialects/experimental/dmp.py
435 436 | |
halo_exchange_defs(shape: ShapeAttr) -> Iterable[ExchangeDeclarationAttr]
Source code in xdsl/dialects/experimental/dmp.py
438 439 | |
comm_layout() -> RankTopoAttr
Source code in xdsl/dialects/experimental/dmp.py
441 442 | |
GridSlice2dAttr
Bases: DomainDecompositionStrategy
Takes a grid with two or more dimensions, slices it along the first two into equally sized segments.
Source code in xdsl/dialects/experimental/dmp.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
name = 'dmp.grid_slice_2d'
class-attribute
instance-attribute
topology: RankTopoAttr
instance-attribute
diagonals: builtin.BoolAttr
instance-attribute
__init__(topo: tuple[int, ...])
Source code in xdsl/dialects/experimental/dmp.py
458 459 | |
calc_resize(shape: tuple[int, ...]) -> tuple[int, ...]
Source code in xdsl/dialects/experimental/dmp.py
466 467 468 469 470 471 472 473 474 475 476 477 478 | |
halo_exchange_defs(shape: ShapeAttr) -> Iterable[ExchangeDeclarationAttr]
Source code in xdsl/dialects/experimental/dmp.py
480 481 482 483 484 485 486 | |
comm_layout() -> RankTopoAttr
Source code in xdsl/dialects/experimental/dmp.py
488 489 | |
GridSlice3dAttr
Bases: DomainDecompositionStrategy
Takes a grid with two or more dimensions, slices it along the first three.
Source code in xdsl/dialects/experimental/dmp.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | |
name = 'dmp.grid_slice_3d'
class-attribute
instance-attribute
topology: RankTopoAttr
instance-attribute
diagonals: builtin.BoolAttr
instance-attribute
__init__(topo: tuple[int, ...])
Source code in xdsl/dialects/experimental/dmp.py
504 505 | |
calc_resize(shape: tuple[int, ...]) -> tuple[int, ...]
Source code in xdsl/dialects/experimental/dmp.py
512 513 514 515 516 517 518 519 520 521 522 523 524 | |
halo_exchange_defs(shape: ShapeAttr) -> Iterable[ExchangeDeclarationAttr]
Source code in xdsl/dialects/experimental/dmp.py
526 527 528 529 530 531 532 533 534 | |
comm_layout() -> RankTopoAttr
Source code in xdsl/dialects/experimental/dmp.py
536 537 | |
SwapOpHasShapeInferencePatterns
dataclass
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/experimental/dmp.py
642 643 644 645 646 647 648 649 650 | |
get_shape_inference_patterns()
classmethod
Source code in xdsl/dialects/experimental/dmp.py
643 644 645 646 647 648 649 650 | |
SwapOpMemoryEffect
dataclass
Bases: MemoryEffect
Side effect implementation of dmp.swap.
Source code in xdsl/dialects/experimental/dmp.py
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |
get_effects(op: Operation) -> set[EffectInstance]
classmethod
Source code in xdsl/dialects/experimental/dmp.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |
SwapOp
dataclass
Bases: IRDLOperation
Declarative swap of memref regions.
Source code in xdsl/dialects/experimental/dmp.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | |
name = 'dmp.swap'
class-attribute
instance-attribute
input_stencil = operand_def(stencil.StencilTypeConstr)
class-attribute
instance-attribute
swapped_values = opt_result_def(stencil.TempType[Attribute])
class-attribute
instance-attribute
swaps = attr_def(builtin.ArrayAttr[ExchangeDeclarationAttr])
class-attribute
instance-attribute
strategy = attr_def(DomainDecompositionStrategy)
class-attribute
instance-attribute
traits = traits_def(SwapOpHasShapeInferencePatterns(), SwapOpMemoryEffect())
class-attribute
instance-attribute
verify_() -> None
Source code in xdsl/dialects/experimental/dmp.py
691 692 693 694 695 696 697 698 699 700 701 | |
get(input_stencil: SSAValue | Operation, strategy: DomainDecompositionStrategy, swaps: builtin.ArrayAttr[ExchangeDeclarationAttr] | None = None)
staticmethod
Source code in xdsl/dialects/experimental/dmp.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | |