Skip to content

Generate and use the iree_hal_executable_library_t metadata. - #5195

Merged
benvanik merged 1 commit into
mainfrom
benvanik-elf-0
Mar 23, 2021
Merged

benvanik merged 1 commit into
mainfrom
benvanik-elf-0

Conversation

@benvanik

@benvanik benvanik commented Mar 22, 2021 •

Copy link
Copy Markdown
Collaborator

The flatbuffers are still present (and we may always need some kind of
descriptor to help the runtime load) but all reflection is now performed
through the interface.

Fixes #3580.

@benvanik benvanik added compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) runtime Relating to the IREE runtime library labels Mar 22, 2021
@google-cla google-cla Bot added the cla: yes label Mar 22, 2021
The flatbuffers are still present (and we may always need some kind of
descriptor to help the runtime load) but all reflection is now performed
through the interface.
@benvanik
benvanik marked this pull request as ready for review March 23, 2021 17:55
@benvanik
benvanik requested a review from ScottTodd March 23, 2021 17:55
@benvanik
benvanik enabled auto-merge (squash) March 23, 2021 18:01

@asaadaldien asaadaldien left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! The LLVMIR dialect might be limiting but do you think we {can/need} to move it to LLVMIR after linking instead of modifying the llvm module ?

@benvanik
benvanik merged commit 881de81 into main Mar 23, 2021
@benvanik
benvanik deleted the benvanik-elf-0 branch March 23, 2021 23:54
@benvanik

Copy link
Copy Markdown
Collaborator Author

I think it's fine touching the IR as it's much easier to do the -emit-llvm -> LLVM builder APIs than it is to try to map back LLVM IR into the MLIR LLVM dialect. I originally tried that and after a few hours of trial and error gave up and wrote it much faster like this :)

Since the IR we are inserting is just static structures there's no real optimization opportunities we miss like this (there's nothing but some constexpr folding that's likely to happen, and would happen anyway if we produced MLIR and translated that to LLVM IR).

@asaadaldien

Copy link
Copy Markdown
Contributor

I think it's fine touching the IR as it's much easier to do the -emit-llvm -> LLVM builder APIs than it is to try to map back LLVM IR into the MLIR LLVM dialect. I originally tried that and after a few hours of trial and error gave up and wrote it much faster like this :)

Since the IR we are inserting is just static structures there's no real optimization opportunities we miss like this (there's nothing but some constexpr folding that's likely to happen, and would happen anyway if we produced MLIR and translated that to LLVM IR).

Yeah building mlir structs can be a pain! I was suggesting mainly so we can lit-test and validate things which we can do if we optionally embedded the textual LLVM module in the executable right before linking

@benvanik

Copy link
Copy Markdown
Collaborator Author

ah yeah - we could have (and may even still have) a flag for serializing as textual LLVM IR - that'd be nice!

@ScottTodd ScottTodd mentioned this pull request Mar 25, 2021
copybara-service Bot pushed a commit that referenced this pull request Mar 25, 2021
* da64c93 Integrate MLIR-EmitC at iml130/mlir-emitc@dde739f (#5228)
* a8d6c2a Fix doc publication by escaping our IR snippets in markdown. (#5227)
* bd5e535 Introduce RVV VLS code-gen (#5199)
* d496bc9 Avoid allocating temporary buffer for tensors derived from read-only tensors (..
* 1a93557 Tidying up a few pages of documentation. (#5225)
* 46e8331 Add a dedicated iree_c_module CMake module (#5214)
* 603b208 Merge google -> main (#5219)
* c9f3742 Add support for control flow lowering in the VM to emitc target (#5208)
* c8a7b2f Sort descriptors as expected by the native module (#5207)
* 47183fb Revise compiler tracing to enable statistics aggregation. (#5218)
* 500ec7b Set author to match committer for llvm submodule update action. (#5217)
* 881de81 Generate and use the iree_hal_executable_library_t metadata. (#5195)
* cf8180e Increase K tile size for small matrices. (#5213)
* f5804ec Fix problem bug in MobileBert with vectorization enable. (#5211)

COPYBARA_INTEGRATE_REVIEW=#5229 from ScottTodd:main-to-google da64c93
PiperOrigin-RevId: 365076337
iree-github-actions-bot pushed a commit that referenced this pull request Mar 25, 2021
* da64c93 Integrate MLIR-EmitC at iml130/mlir-emitc@dde739f (#5228)
* a8d6c2a Fix doc publication by escaping our IR snippets in markdown. (#5227)
* bd5e535 Introduce RVV VLS code-gen (#5199)
* d496bc9 Avoid allocating temporary buffer for tensors derived from read-only tensors (..
* 1a93557 Tidying up a few pages of documentation. (#5225)
* 46e8331 Add a dedicated iree_c_module CMake module (#5214)
* 603b208 Merge google -> main (#5219)
* c9f3742 Add support for control flow lowering in the VM to emitc target (#5208)
* c8a7b2f Sort descriptors as expected by the native module (#5207)
* 47183fb Revise compiler tracing to enable statistics aggregation. (#5218)
* 500ec7b Set author to match committer for llvm submodule update action. (#5217)
* 881de81 Generate and use the iree_hal_executable_library_t metadata. (#5195)
* cf8180e Increase K tile size for small matrices. (#5213)
* f5804ec Fix problem bug in MobileBert with vectorization enable. (#5211)

PiperOrigin-RevId: 365076337
Comment on lines -70 to -74
// https://lld.llvm.org/WebAssembly.html#exports
for (auto entryPointName : entryPointNames) {
auto *entryPointFn = llvmModule->getFunction(entryPointName);
entryPointFn->addFnAttr("wasm-export-name", entryPointName);
}

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.

These wasm-export-name attributes were load bearing for the entry points to be accessible through the generated wasm modules. The other mechanisms at the link I included here should also work, but may need different plumbing.

After this change (I suspect - haven't bisected), I get empty .wat files:

(module
  (table $T0 1 1 funcref)
  (memory $memory 2)
  (global $g0 (mut i32) (i32.const 66560))
  (export "memory" (memory 0)))

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.

Fix in #5286

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) runtime Relating to the IREE runtime library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define executable C API and rework LLVM target to emit it

3 participants