nod-ai / iree-amd-aie

IREE plugin repository for the AMD AIE accelerator
Apache License 2.0
69 stars 30 forks source link

Add pass to assign tiles to logical objectFifos #915

Closed jtuyls closed 3 hours ago

jtuyls commented 11 hours ago

Adds a pass that assigns tiles to logical objectFifos based on tile usage by trying to to distribute logical objectFifos as evenly as possible across available tiles. The new pass is based on the tile assignment logic that was originally part of DistributeCoresAndObjectFifos and refactors the latter pass to use the extracted functions to keep the logic the same for now.

Note that I am not completely removing the tile assignment functions from DistributeCoresAndObjectFifos for two reasons:

Until the output of DistributeCoresAndObjectFifos before tile assignment is stable, the tile assignment utility functions should be called within the pass itself and not be separated out.

newling commented 8 hours ago

If you want to semi-ensure that 2 passes are always run back-to-back, you can use the aievec approach of adding to the pipeline with a helper function: https://github.com/nod-ai/iree-amd-aie/blob/59d991ee1c63d89ca5a31fd18d10c7b74f938e62/compiler/plugins/target/AMD-AIE/aievec/Passes.h#L97

(minus) doesn't technically ensure a user doesn't misuse the pass (plus) integrates all code into the main pipeline just once (plus) easier for us to see what transformation happened in the different non-trivial functions with --mlir-print-ir-before-all

jtuyls commented 7 hours ago

If you want to semi-ensure that 2 passes are always run back-to-back, you can use the aievec approach of adding to the pipeline with a helper function:

https://github.com/nod-ai/iree-amd-aie/blob/59d991ee1c63d89ca5a31fd18d10c7b74f938e62/compiler/plugins/target/AMD-AIE/aievec/Passes.h#L97

(minus) doesn't technically ensure a user doesn't misuse the pass (plus) integrates all code into the main pipeline just once (plus) easier for us to see what transformation happened in the different non-trivial functions with --mlir-print-ir-before-all

Yeah, but the disadvantage is a real issue for me. A pass not being stable on itself is just an invite for bugs and misuse. The workaround hides the real underlying problem that needs to be tackled, which is ensuring that the output without tile assignment is stable on itself. I have some ideas for this, but I don't think it's a priority right now because the pass has held up pretty well as it stands and if needed, you can easily debug it with --debug-only.