This is an archive of the discontinued LLVM Phabricator instance.

[mlir:Async] Add an async reference counting pass based on the user defined policy
ClosedPublic

Authored by ezhulenev on Jun 28 2021, 8:54 AM.

Details

Summary

Depends On D104999

Automatic reference counting based on the liveness analysis can add a lot of reference counting overhead at runtime. If the IR is known to be constrained to few particular "shapes", it's much more efficient to provide a custom reference counting policy that will specify where it is required to update the async value reference count.

Diff Detail

Event Timeline

ezhulenev created this revision.Jun 28 2021, 8:54 AM
ezhulenev requested review of this revision.Jun 28 2021, 8:54 AM
ezhulenev edited the summary of this revision. (Show Details)Jun 28 2021, 8:56 AM
ezhulenev added a reviewer: mehdi_amini.
ezhulenev updated this revision to Diff 355031.Jun 28 2021, 1:58 PM

Fix a bug in ref counting

ezhulenev updated this revision to Diff 355177.Jun 29 2021, 4:30 AM

Put all reference counting passes into the single file

I suspect the title should be "based" instead of "baded"?

mlir/include/mlir/Dialect/Async/Passes.h
32

I don't understand the method name here?

39

Nit: three ///.

Also, if the first sentence could be along the line of "Create a pass that does XYZ".

mlir/include/mlir/Dialect/Async/Passes.td
79

I am concerned about this: this will break reproducer. Can we look into solutions for this?

mehdi_amini added inline comments.Jun 29 2021, 11:21 AM
mlir/include/mlir/Dialect/Async/Passes.td
79

One option would be to keep the pass without option, and expose an entry point that isn't a pass. The user would create their own pass and inject the policy into the utility entry point,

ezhulenev retitled this revision from [mlir:Async] Add an async reference counting pass baded on the user defined policy to [mlir:Async] Add an async reference counting pass based on the user defined policy.Jun 29 2021, 11:26 AM
ezhulenev marked an inline comment as done.

Rename pass to AsyncRuntimePolicyBasedRefCountingPass

mehdi_amini added inline comments.Jun 29 2021, 11:31 AM
mlir/include/mlir/Dialect/Async/Passes.td
79

Thinking more about it: isn't the "policy" just implementing a calling convention of some sort?
If so, why isn't it an op or dialect interface?

ezhulenev marked an inline comment as done.

Update documentation

ezhulenev added inline comments.Jun 29 2021, 11:37 AM
mlir/include/mlir/Dialect/Async/Passes.h
32

Renamed to AsyncRuntimePolicyBasedRefCountingPass

mlir/include/mlir/Dialect/Async/Passes.td
79

Yeah, agree that this is weird, but I don't actually have examples of policy beyond default. I'll take a look at it later. For now I just added a little bit more documentation.

mehdi_amini added inline comments.Jun 29 2021, 11:40 AM
mlir/include/mlir/Dialect/Async/Passes.td
79

If we don't have other policy, can we just not introduce the ability to inject behavior here for now?
When such injection will be needed, it'll be easier to look into interfaces.

Remove user defined policies from policy based ref counting pass

ezhulenev marked an inline comment as done.Jun 29 2021, 12:13 PM
ezhulenev added inline comments.
mlir/include/mlir/Dialect/Async/Passes.td
79

Yeah, good point. Removed it for now.

mehdi_amini accepted this revision.Jun 29 2021, 12:15 PM
This revision is now accepted and ready to land.Jun 29 2021, 12:15 PM