Convert stencil to csl stencil
convert_stencil_to_csl_stencil
¶
ConvertAccessOpPattern
dataclass
¶
Bases: RewritePattern
Rebuilds stencil.access by csl_stencil.access which operates on prefetched accesses.
stencil.access operates on stencil.temp types found at arg_index csl_stencil.access operates on memref< num_neighbors x tensor< buf_size x data_type >> found at last arg index
Note: This is intended to be called in a nested pattern rewriter, such that the above precondition is met.
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
__init__() -> None
¶
match_and_rewrite(op: stencil.AccessOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
ConvertSwapToPrefetchPattern
dataclass
¶
Bases: RewritePattern
Translates dmp.swap to csl_stencil.prefetch
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
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 216 217 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 | |
num_chunks: int = 1
class-attribute
instance-attribute
¶
__init__(num_chunks: int = 1) -> None
¶
match_and_rewrite(op: dmp.SwapOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
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 216 217 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 | |
SplitVarithOpPattern
dataclass
¶
Bases: RewritePattern
Splits a varith op into two, depending on whether the operands holds stencil accesses to buf (only)
or any other accesses.
This pass is intended to be run with buf set to the block arg indicating data received from neighbours.
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
buf: BlockArgument
instance-attribute
¶
__init__(buf: BlockArgument) -> None
¶
match_and_rewrite(op: varith.VarithOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
ConvertApplyOpPattern
dataclass
¶
Bases: RewritePattern
Fuses a csl_stencil.prefetch and a stencil.apply to build a csl_stencil.apply.
If there are several candidate prefetch ops, the one with the largest result buffer size is selected. The selection is greedy, and could in the future be expanded into a more global selection optimising for minimal prefetch overhead across multiple apply ops.
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 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 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 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |
num_chunks: int = 1
class-attribute
instance-attribute
¶
Number of chunks into which communication and computation should be split.
Effectively, the number of times csl_stencil.apply.receive_chunk will be executed
and the tensor sizes it handles.
Higher values may increase compute overhead but reduce size of communication buffers
when lowered.
__init__(num_chunks: int = 1) -> None
¶
match_and_rewrite(op: stencil.ApplyOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
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 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 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |
PromoteCoefficients
¶
Bases: RewritePattern
Promotes constant coefficients to attributes. When a csl_stencil.access is immediately multiplied by
an arith.constant as the sole use of the accessed data, the constant is promoted to a coefficient property
in the csl_stencil.apply op.
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
match_and_rewrite(op: csl_stencil.AccessOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
TransformPrefetch
¶
Bases: RewritePattern
Rewrites a prefetch into a communicate-only csl_stencil.apply
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
match_and_rewrite(op: csl_stencil.PrefetchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
ConvertStencilToCslStencilPass
dataclass
¶
Bases: ModulePass
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
name = 'convert-stencil-to-csl-stencil'
class-attribute
instance-attribute
¶
num_chunks: int = 1
class-attribute
instance-attribute
¶
__init__(num_chunks: int = 1) -> None
¶
apply(ctx: Context, op: ModuleOp) -> None
¶
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
get_stencil_access_operands(op: Operand) -> set[Operand]
¶
Returns the symbols of all stencil accessess by op and all its dependencies.
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
split_ops(ops: Sequence[Operation], buf: BlockArgument, rewriter: PatternRewriter) -> tuple[Sequence[Operation], Sequence[Operation]]
¶
Returns a split of ops into an (a,b) tuple, such that:
acontains neighbour accesses tobufplus the minumum set of instructions to reduce the accessed data to 1 thingbcontains everything else
If no valid split can be found, return (ops, []).
This function does not attempt to arithmetically re-structure the computation to obtain a good split. To do this,
RestructureSymmetricReductionPattern() may be executed first.
Source code in xdsl/transforms/convert_stencil_to_csl_stencil.py
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 | |