Stencil global to local
stencil_global_to_local
¶
ChangeStoreOpSizes
dataclass
¶
Bases: RewritePattern
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
strategy: dmp.DomainDecompositionStrategy
instance-attribute
¶
__init__(strategy: dmp.DomainDecompositionStrategy) -> None
¶
match_and_rewrite(op: stencil.StoreOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
AddHaloExchangeOps
dataclass
¶
Bases: RewritePattern
This rewrite adds a stencil.halo_exchange after each stencil.load op
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
strategy: dmp.DomainDecompositionStrategy
instance-attribute
¶
__init__(strategy: dmp.DomainDecompositionStrategy) -> None
¶
match_and_rewrite(op: stencil.LoadOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
LowerHaloExchangeToMpi
dataclass
¶
Bases: RewritePattern
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
init: bool
instance-attribute
¶
debug_prints: bool = False
class-attribute
instance-attribute
¶
__init__(init: bool, debug_prints: bool = False) -> None
¶
match_and_rewrite(op: dmp.SwapOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
MpiLoopInvariantCodeMotion
¶
THIS IS NOT A REWRITE PATTERN!
This is a two-stage rewrite that modifies operations in a manner that is incompatible with the PatternRewriter!
It implements a custom rewrite_module() method directly on the class.
This rewrite moves all memref.allo, mpi.comm.rank, mpi.allocate and mpi.unwrap_memref ops and moves them "up" until it hits a func.func, and then places them before the op they appear in.
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 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 490 491 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 538 539 540 541 542 543 | |
seen_ops: set[Operation] = set()
instance-attribute
¶
has_init: set[func.FuncOp] = set()
instance-attribute
¶
__init__()
¶
rewrite(op: memref.AllocOp | mpi.CommRankOp | mpi.AllocateTypeOp | mpi.UnwrapMemRefOp | mpi.InitOp, rewriter: Rewriter)
¶
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
get_matcher(worklist: list[memref.AllocOp | mpi.CommRankOp | mpi.AllocateTypeOp | mpi.UnwrapMemRefOp | mpi.InitOp]) -> Callable[[Operation], None]
¶
Returns a match() function that adds methods to a worklist if they satisfy some criteria.
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
rewrite_module(op: builtin.ModuleOp)
¶
Apply the rewrite to a module.
We do a two-stage rewrite because we are modifying
the operations we loop on them, which would throw of op.walk.
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
DmpDecompositionPass
dataclass
¶
Bases: ModulePass, ABC
Represents a pass that takes a strategy as input
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
__init__() -> None
¶
DistributeStencilPass
dataclass
¶
Bases: DmpDecompositionPass
Decompose a stencil to apply to a local domain.
This pass applies stencil shape inference!
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
name = 'distribute-stencil'
class-attribute
instance-attribute
¶
STRATEGIES: dict[str, type[dmp.GridSlice2dAttr | dmp.GridSlice3dAttr]] = {'2d-grid': dmp.GridSlice2dAttr, '3d-grid': dmp.GridSlice3dAttr}
class-attribute
¶
slices: tuple[int, ...]
instance-attribute
¶
Number of slices to decompose the input into
strategy: str
instance-attribute
¶
Name of the decomposition strategy to use, see STRATEGIES property for options
restrict_domain: bool = True
class-attribute
instance-attribute
¶
Apply the domain restriction (i.e. change the stencil.apply to operate on the local domain. If false, it assumes that the generated code is already local)
__init__(slices: tuple[int, ...], strategy: str, restrict_domain: bool = True) -> None
¶
apply(ctx: Context, op: builtin.ModuleOp) -> None
¶
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
DmpToMpiPass
dataclass
¶
Bases: ModulePass
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
name = 'dmp-to-mpi'
class-attribute
instance-attribute
¶
mpi_init: bool = True
class-attribute
instance-attribute
¶
generate_debug_prints: bool = False
class-attribute
instance-attribute
¶
__init__(mpi_init: bool = True, generate_debug_prints: bool = False) -> None
¶
apply(ctx: Context, op: builtin.ModuleOp) -> None
¶
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
generate_mpi_calls_for(source: SSAValue, exchanges: list[dmp.ExchangeDeclarationAttr], dtype: Attribute, grid: dmp.RankTopoAttr, emit_init: bool = True, emit_debug: bool = False) -> Iterable[Operation]
¶
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
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 | |
generate_memcpy(field: SSAValue, ex: dmp.ExchangeDeclarationAttr, buffer: SSAValue, receive: bool = False) -> list[Operation]
¶
This function generates a memcpy routine to copy over the parts
specified by the field from field into buffer.
If receive=True, it instead copy from buffer into the parts of
field as specified by ex
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
can_loop_invariant_code_move(op: Operation)
¶
This function walks the def-use chain up to see if all the args are "constant enough" to move outside the loop.
This check is very conservative, but that means it definitely works!
Source code in xdsl/transforms/experimental/dmp/stencil_global_to_local.py
collect_args_recursive(op: Operation) -> Iterable[Operation]
¶
Collect the def-use chain "upwards" of an operation. Check with can_loop_invariant_code_move prior to using this!