Skip to content

Adding multiple layouts to HAL executable creation. - #4621

Merged
benvanik merged 1 commit into
mainfrom
benvanik-executable-layouts-wreck
Jan 30, 2021
Merged

benvanik merged 1 commit into
mainfrom
benvanik-executable-layouts-wreck

Conversation

@benvanik

@benvanik benvanik commented Jan 27, 2021 •

Copy link
Copy Markdown
Collaborator

The fact that we were providing one layout per executable was always a bug and only worked because nothing actually used that argument. This fixes things so that we properly pass a layout per entry point of the executable so that linked executables (which may have any number of interfaces) work correctly.

As a side-effect, this PR also simplifies the HAL interface exposed to the compiler to hide the executable caches. That they were represented at all in the IR was a bit weird as they are a runtime-provider controlled concept and the lifetime of them is critically tied to the lifetime of the loaded compiled module. This removes the hack that was implicitly keeping the executables live in the VM.

It also required minor compiler changes because of the split dispatch regions stuff in the legacy spir-v path and I had to add a workaround to fix up the IR. The existing approach (where the SPIR-V backend didn't tell the HAL about the entry points it created) only worked because we were not validating executable layouts and the vulkan pipelines were just created with the same single layout provided. The upside of this hack is that we could probably start linking SPIR-V modules.

Fixes #4536.

@benvanik benvanik added compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) runtime Relating to the IREE runtime library hal/api IREE's public C hardware abstraction layer API labels Jan 27, 2021
@benvanik benvanik added this to the 2021Q1 Core milestone Jan 27, 2021
@google-cla google-cla Bot added the cla: yes label Jan 27, 2021
@benvanik
benvanik requested a review from ScottTodd January 27, 2021 19:13
@benvanik
benvanik force-pushed the staging-hal-rewrite branch from 80885b7 to 50d9823 Compare January 28, 2021 19:26
@benvanik
benvanik force-pushed the benvanik-executable-layouts-wreck branch 2 times, most recently from 90a7648 to 327e836 Compare January 28, 2021 19:52
@benvanik
benvanik force-pushed the staging-hal-rewrite branch from 59b7a7c to 6de6fdf Compare January 29, 2021 04:03
@benvanik
benvanik force-pushed the benvanik-executable-layouts-wreck branch 3 times, most recently from 78f2448 to e176a3c Compare January 29, 2021 07:02
@benvanik

Copy link
Copy Markdown
Collaborator Author

All tests but lit ones are passing now - will do in the AM. Turns out DCE actually works now because of these fixes and some of the tests are assuming it doesn't :P

Base automatically changed from staging-hal-rewrite to main January 29, 2021 18:05

static PassRegistration<MaterializeEntryPointsPass> pass(
"iree-codegen-materialize-entry-points",
"Materialize HAL entry points for each spv.EntryPoint",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Want to add tests for this pass? (fine to skip if the pass will be deleted along with SplitDispatchFunctionPass soon)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah this entire path is woefully undertested - there were only two or three tests in all of IREE that failed with these multiple spir-v entry points (simple_embedding_test was one of them lol). Really hoping we can kill it off soon, and I think the work mahesh is doing is going to make that very possible!

Comment on lines +110 to +111
// Hide the linker banner message printed each time.
"/nologo",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😆

Comment on lines -268 to -273
// TODO(benvanik): support multiple interfaces. We'd probably want to
// store each executable+interface as a variable.
//
// This is *only* safe now because any backends that support multiple
// interfaces during compilation do *not* use layouts during executable
// cache preparation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So happy to see this resolved :D

Required working around the SplitDispatchFunctionPass on the SPIR-V side.

Fixes #4536.
@benvanik
benvanik force-pushed the benvanik-executable-layouts-wreck branch from e176a3c to 068adbc Compare January 30, 2021 01:26
@benvanik
benvanik merged commit 1321588 into main Jan 30, 2021
@benvanik
benvanik deleted the benvanik-executable-layouts-wreck branch January 30, 2021 01:52
@not-jenni not-jenni mentioned this pull request Feb 1, 2021
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) hal/api IREE's public C hardware abstraction layer API runtime Relating to the IREE runtime library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Executable linking produces executables with multiple layouts but runtime does not support that

2 participants