Skip to content

Update the LLVMJIT to use the new runtime dispatch API #1265

Closed

Description

@benvanik

As part of #1249 I set IREE_LLVMJIT_DISABLE=1 to disable the current LLVM JIT execution tests. Compilation tests are still run.

The issue is that the LLVMJITCommandProcessor uses the memref descriptors:
https://github.com/google/iree/blob/eaa431279aadf5fdbe9af9862327dbb717c8d648/iree/hal/llvmjit/llvmjit_command_processor.cc#L56-L61

We've talked about this change in the past but I forgot that it was a blocker for this work because I couldn't run LLVMJIT tests on Windows yet.

These memref descriptors require shapes (AFAICT) that we don't have anymore. It may be possible to work around this iff no field but the data void* is used, but I believe the shape (and strides/lengths calculated from it) are required (https://github.com/google/iree/blob/eaa431279aadf5fdbe9af9862327dbb717c8d648/iree/hal/llvmjit/memref_runtime.h#L136-L153).

If the workaround doesn't work, maybe generating the LLVM IR in the function shim to populate the memref descriptors will. Or, you could switch away and over to the new API and be ready for dynamic shapes and all the other goodness.

The new VMLA code shows a way the new dispatch can be handled:
https://github.com/google/iree/blob/1af5e0972ea801cd933b59d38a232e8534884a7f/iree/hal/vmla/vmla_command_processor.cc#L37-L74

The bindings (and push constants, where dynamic dimensions/etc live) are setup there and provided to the target executable via a single Interface structure:
https://github.com/google/iree/blob/1af5e0972ea801cd933b59d38a232e8534884a7f/iree/hal/vmla/vmla_module.h#L44-L127

The generated code then queries the constants/bindings from that structure:
https://github.com/google/iree/blob/1af5e0972ea801cd933b59d38a232e8534884a7f/iree/compiler/Dialect/VMLA/vmla.imports.mlir#L24-L38

Example IR here:
https://github.com/google/iree/blob/1af5e0972ea801cd933b59d38a232e8534884a7f/iree/compiler/Dialect/VMLA/Transforms/test/transformation.mlir#L19-L29

You could do something similar: a struct with the bindings/push constants, pass a pointer to your generated code, and dereference inside.

Mahesh has a CL train that moves a lot of the codegen over to the new hal interfaces which will make this much easier to get access to there (you need the IREE::HAL::InterfaceOp/InterfaceBindingOps to get the info).

We can gvc/chat more - just wanted to get these code links somewhere :)

Activity

  1. added
    enhancement ➕
    compiler/dialects
    codegen
    on Mar 26, 2020
  2. benvanik commented on Mar 26, 2020

    @benvanik
    CollaboratorAuthor

    Thanks to #1266 (thanks @asaadaldien!) I'm able to keep the LLVM JIT code path working with the new (temporary) API shim. We'll still need to update to use the new interfaces for dynamic shapes but now there's less pressure!

  3. added this to the milestone on Mar 26, 2020
  4. modified the milestones: , on May 5, 2020
  5. benvanik commented on May 5, 2020

    @benvanik
    CollaboratorAuthor

    Note that this work will be needed for dynamic shapes.

  6. benvanik commented on Jun 17, 2020

    @benvanik
    CollaboratorAuthor

    I really want to get rid of the memref_runtime.h and the C ABI incompatible templated C++ structs we are passing across the JIT/shared object boundary and prepare for better versioning across the ABI (as well as custom functions). I'll take a look at doing that before the end of the quarter.

  7. modified the milestones: , on Jun 23, 2020
  8. added
    codegen/llvm
    on Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

codegencodegen/llvmcompiler/dialectsenhancement ➕

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions