Skip to content

Remove usage of nested PassManager from the compiler #1036

Closed

Description

@benvanik

To make debugging easier I think it'd be good to remove the nested pass manager used during executable translation... somehow.

Right now, all executables for all targets are translated in a single parent pass (https://github.com/google/iree/blob/master/iree/compiler/Dialect/HAL/Transforms/TranslateExecutables.cpp#L76) which then requires the various targets to initiate their own pass run (https://github.com/google/iree/blob/master/iree/compiler/Dialect/HAL/Target/VMLA/VMLATarget.cpp#L70-L75).

If we instead move the logic for deriving target backends to the transform pipeline setup (https://github.com/google/iree/blob/master/iree/compiler/Dialect/HAL/Transforms/Passes.cpp#L33) we could have the target registration function populate a nested pass manager (nest<IREE::HAL::ExecutableOp>()) with the passes it requires.

This should make getting end-to-end reproducers easier.

Right now the target functions may do a bit of extra prep that we should remove or move to passes (https://github.com/google/iree/blob/master/iree/compiler/Dialect/HAL/Target/VMLA/VMLATarget.cpp#L59-L67) before running their core passes (https://github.com/google/iree/blob/master/iree/compiler/Dialect/HAL/Target/VMLA/VMLATarget.cpp#L71-L72) and finally serializing their contents (https://github.com/google/iree/blob/master/iree/compiler/Dialect/HAL/Target/VMLA/VMLATarget.cpp#L77-L111).

If instead each target had a serialization pass that took the contents and packed them into the flatbuffer then we don't need to run anything outside of the nested pass.

Initial tasks (unblocked):

  • Change ExecutableTargetRegistration (maybe to an interface with a populatePasses method to make future work around target specialization easier)
  • Move LLVM/VMLA/SPIR-V serialization to their own passes in their respective dialects
  • File a bug with upstream because mlir::translateModuleToLLVMIR does the same pass manager nesting - it shouldn't (only impacts llvmjit backend)
  • Move RewriteLegacyIO pass into the target pass pipelines (not via makeLegacyExecutableABI)

Post-handwritten-VulkanSPIRVTarget.cpp-kernels:

  • Move backend list logic to HAL/Transforms/Passes.cpp and build nested pass manager
    (the logic in VulkanSPIRVTarget.cpp is complex right now with all the special cases/flags, but will be getting simpler soon)

Activity

  1. benvanik commented on Mar 11, 2020

    @benvanik
    CollaboratorAuthor

    Mahesh points out that currently the SPIR-V/LLVM backends are using the RewriteLegacyIO pass - that'll also need to be setup in their new pipelines nested on the IREE::HAL::ExecutableSourceOp
    (or, depending on when this work is done, may not be needed at all)

  2. added
    compiler/dialects
    on Mar 19, 2020
  3. added this to the milestone on Mar 26, 2020
  4. benvanik commented on Apr 8, 2020

    @benvanik
    CollaboratorAuthor

    Chatting with river/mehdi it sounds like dynamic pass registration will be required to do this right. They've got plans to implement that this quarter, so my hope is to get everything else done except for the unnesting and then that can be done as a simple change when the infra is ready.

  5. benvanik commented on Apr 23, 2020

    @benvanik
    CollaboratorAuthor
  6. modified the milestones: , on May 5, 2020
  7. modified the milestones: , on Sep 12, 2020
  8. added a commit that references this issue on Nov 6, 2020
  9. added a commit that references this issue on Nov 6, 2020
  10. self-assigned this
    on Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

compiler/dialects

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions