Skip to content

Use nested references in HAL command buffer dispatches. - #3047

Merged
ScottTodd merged 13 commits into
iree-org:mainfrom
ScottTodd:nested-refs
Sep 11, 2020
Merged

ScottTodd merged 13 commits into
iree-org:mainfrom
ScottTodd:nested-refs

Conversation

@ScottTodd

@ScottTodd ScottTodd commented Sep 1, 2020 •

Copy link
Copy Markdown
Member

Progress on #1890.

This splits

  • CommandBufferDispatchOp -> CommandBufferDispatchOp / CommandBufferDispatchSymbolOp
  • CommandBufferDispatchIndirectOp -> CommandBufferDispatchIndirectOp / CommandBufferDispatchIndirectSymbolOp

A new ResolveEntryPointOrdinalsPass runs after linking but prior to serialization, converting the ops using references to ops using ordinals. Backends may choose to record with or without references. Since the VulkanSPIRV target may split dispatches, it uses ordinals directly and must solve linking in some specialized way (this will at least need more attention as we implement linking).

These attributes will help when using target ops in nested symbol references (`entry_point = @exe::@target::@entry`).
…ents.

This is not strictly required, but enforcing the already implicit structure seems like good practice.
* CommandBufferDispatchOp -> CommandBufferDispatchOp / CommandBufferDispatchOrdinalOp
* CommandBufferDispatchIndirectOp -> CommandBufferDispatchIndirectOp / CommandBufferDispatchIndirectOrdinalOp
* ResolveEntryPointOrdinalsPass runs prior to serialization
* Backends may choose to record with or without references
    * Since VulkanSPIRV may split dispatches, it uses ordinals directly and must solve linking in some specialized way
@ScottTodd ScottTodd added the compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) label Sep 1, 2020
@google-cla google-cla Bot added the cla: yes label Sep 1, 2020
This reverts commit 5ff550c.

The LLVM targets match entry point symbol names to llvm.func names.

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix or work around some mysterious Python failures (in the MLIR crash reproducer..?).

Comment thread iree/compiler/Dialect/HAL/IR/HALOps.td Resolved
@ScottTodd
ScottTodd marked this pull request as ready for review September 3, 2020 20:23
@ScottTodd
ScottTodd requested a review from benvanik September 3, 2020 20:23

@benvanik benvanik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your idea about renaming targetbackend::name too

HAL_CommandBuffer:$command_buffer,
HAL_Executable:$executable,
HAL_OrdinalAttr:$entry_point,
HAL_Executable:$executable, // TODO(scotttodd): remove this and extract from nested ref?

@benvanik benvanik Sep 3, 2020 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we can kill this, which is nice (less chance for the two to get out of sync when we end up moving the entry points around - changing the entry point from @foo::@bar -> @taco::@beef is just a single op, not having to also update executable)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also remove the entry_point here, as there will just be one symbol reference

this way, we have this:
hal.command_buffer.dispatch.symbol %cmd, @executable::@entry_point, ...
and
hal.command_buffer.dispatch %cmd, @executable, entry_point=0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benvanik I'm sorry, what?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, @ tagged you by username, sorry about that! @foo::@bar here are symbols >_>
Ben, use code blocks for those next time :P

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha sorry about that :P

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted offline a bit. Going to investigate that in a follow-up. It's not as straightforward as removing HAL_Executable:$executable here and pulling it out of the symbol reference later. It needs a hal.executable.lookup with a HAL_Device (which we might be able to carry through the DispatchState struct), or something similar.

Comment thread iree/compiler/Dialect/HAL/IR/HALOps.td Resolved
Comment thread iree/compiler/Dialect/HAL/IR/HALOps.td Resolved
Comment thread iree/compiler/Dialect/HAL/IR/HALOps.td Resolved

let arguments = (ins
HAL_CommandBuffer:$command_buffer,
HAL_Executable:$executable, // TODO(scotttodd): remove this and extract from nested ref?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(consistent with whatever we do above)

@ScottTodd
ScottTodd merged commit 465279e into iree-org:main Sep 11, 2020
@ScottTodd
ScottTodd deleted the nested-refs branch September 11, 2020 15:06
@hanhanW hanhanW mentioned this pull request Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants