[all-commits] [llvm/llvm-project] 89808c: [MLIR][mlir-spirv-cpu-runner] A SPIR-V cpu runner ...

George Mitenkov via All-commits all-commits at lists.llvm.org
Mon Oct 26 06:10:41 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 89808ce7343b22586bfd0d3fafddcdbba94fbcbb
      https://github.com/llvm/llvm-project/commit/89808ce7343b22586bfd0d3fafddcdbba94fbcbb
  Author: George Mitenkov <georgemitenk0v at gmail.com>
  Date:   2020-10-26 (Mon, 26 Oct 2020)

  Changed paths:
    M mlir/CMakeLists.txt
    M mlir/examples/toy/Ch6/toyc.cpp
    M mlir/examples/toy/Ch7/toyc.cpp
    M mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
    M mlir/include/mlir/ExecutionEngine/JitRunner.h
    M mlir/lib/ExecutionEngine/ExecutionEngine.cpp
    M mlir/lib/ExecutionEngine/JitRunner.cpp
    M mlir/test/CMakeLists.txt
    M mlir/test/lit.cfg.py
    M mlir/test/lit.site.cfg.py.in
    A mlir/test/mlir-spirv-cpu-runner/CMakeLists.txt
    A mlir/test/mlir-spirv-cpu-runner/double.mlir
    A mlir/test/mlir-spirv-cpu-runner/lit.local.cfg
    A mlir/test/mlir-spirv-cpu-runner/mlir_test_spirv_cpu_runner_c_wrappers.cpp
    A mlir/test/mlir-spirv-cpu-runner/simple_add.mlir
    M mlir/tools/CMakeLists.txt
    A mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
    A mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp

  Log Message:
  -----------
  [MLIR][mlir-spirv-cpu-runner] A SPIR-V cpu runner prototype

This patch introduces a SPIR-V runner. The aim is to run a gpu
kernel on a CPU via GPU -> SPIRV -> LLVM conversions. This is a first
prototype, so more features will be added in due time.

- Overview
The runner follows similar flow as the other runners in-tree. However,
having converted the kernel to SPIR-V, we encode the bind attributes of
global variables that represent kernel arguments. Then SPIR-V module is
converted to LLVM. On the host side, we emulate passing the data to device
by creating in main module globals with the same symbolic name as in kernel
module. These global variables are later linked with ones from the nested
module. We copy data from kernel arguments to globals, call the kernel
function from nested module and then copy the data back.

- Current state
At the moment, the runner is capable of running 2 modules, nested one in
another. The kernel module must contain exactly one kernel function. Also,
the runner supports rank 1 integer memref types as arguments (to be scaled).

- Enhancement of JitRunner and ExecutionEngine
To translate nested modules to LLVM IR, JitRunner and ExecutionEngine were
altered to take an optional (default to `nullptr`) function reference that
is a custom LLVM IR module builder. This allows to customize LLVM IR module
creation from MLIR modules.

Reviewed By: ftynse, mravishankar

Differential Revision: https://reviews.llvm.org/D86108




More information about the All-commits mailing list