[all-commits] [llvm/llvm-project] 713f85: [mlir][spirv] Add a pass to map memref memory space

Lei Zhang via All-commits all-commits at lists.llvm.org
Fri Aug 5 09:23:21 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 713f85d5952ab27d474aba2a960a893b7e7e438d
      https://github.com/llvm/llvm-project/commit/713f85d5952ab27d474aba2a960a893b7e7e438d
  Author: Lei Zhang <antiagainst at google.com>
  Date:   2022-08-05 (Fri, 05 Aug 2022)

  Changed paths:
    M mlir/include/mlir/Conversion/MemRefToSPIRV/MemRefToSPIRV.h
    M mlir/include/mlir/Conversion/MemRefToSPIRV/MemRefToSPIRVPass.h
    M mlir/include/mlir/Conversion/Passes.td
    M mlir/lib/Conversion/MemRefToSPIRV/CMakeLists.txt
    A mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp
    M mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp
    A mlir/test/Conversion/MemRefToSPIRV/map-storage-class.mlir

  Log Message:
  -----------
  [mlir][spirv] Add a pass to map memref memory space

MemRef types now can carry an attribute to represent the memory
space. Still, upper layers in the compilation stack mostly use
nuemric values. They don't mean much (other than differentiating
separate memory domains) in MLIR's multi-level settings. Those
numeric memory space inside MemRef types need to be translated
into concrete SPIR-V storage classes during lowering to pin down
to concrete memory types.

Thus far we have been hardcoding an arbitrary mapping from memory
space to storage class for converting MemRef types. This works fine
for only targeting Vulkan; it falls apart if we want to target other
SPIR-V consumers like OpenCL, as different consumers might want
different storage classes for the buffer/variable of the same
lifetime. For example, StorageClass in Vulkan vs. CrossWorkgroup
in OpenCL.

So putting up a new pass to let the user to control how to map
MemRef memory spaces into SPIR-V storage classes. This provides
more flexibility and can address the awkwardness in the current
SPIR-V type converter. This pass should be the prelimiary step
towards lowering MemRef related types/ops into SPIR-V.

Reviewed By: mravishankar

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




More information about the All-commits mailing list