[all-commits] [llvm/llvm-project] 6ca1a0: [mlir][gpu] Migrate hard-coded address space integ...

Chris via All-commits all-commits at lists.llvm.org
Fri Jan 13 10:00:24 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6ca1a09f03e8e940f306bea73efa935e4ee38173
      https://github.com/llvm/llvm-project/commit/6ca1a09f03e8e940f306bea73efa935e4ee38173
  Author: Christopher Bate <cbate at nvidia.com>
  Date:   2023-01-13 (Fri, 13 Jan 2023)

  Changed paths:
    M mlir/include/mlir/Dialect/GPU/IR/GPUBase.td
    M mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
    M mlir/include/mlir/Dialect/GPU/Transforms/Passes.td
    M mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
    M mlir/include/mlir/Dialect/NVGPU/IR/NVGPU.td
    M mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
    M mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h
    M mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    M mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
    M mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp
    M mlir/lib/Dialect/GPU/CMakeLists.txt
    M mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
    M mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
    A mlir/lib/Dialect/GPU/Transforms/LowerMemorySpaceAttributes.cpp
    M mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp
    M mlir/lib/Dialect/NVGPU/IR/NVGPUDialect.cpp
    M mlir/lib/Dialect/NVGPU/Transforms/OptimizeSharedMemory.cpp
    M mlir/test/Conversion/GPUCommon/memory-attrbution.mlir
    M mlir/test/Dialect/GPU/all-reduce-max.mlir
    M mlir/test/Dialect/GPU/all-reduce.mlir
    M mlir/test/Dialect/GPU/invalid.mlir
    A mlir/test/Dialect/GPU/lower-memory-space-attrs.mlir
    M mlir/test/Dialect/GPU/promotion.mlir
    M mlir/test/Dialect/NVGPU/invalid.mlir

  Log Message:
  -----------
  [mlir][gpu] Migrate hard-coded address space integers to an enum attribute (gpu::AddressSpaceAttr)

This is a purely mechanical change that introduces an enum attribute in the GPU
dialect to represent the various memref memory spaces as opposed to the
hard-coded integer attributes that are currently used.

The following steps were taken to make the transition across the codebase:

1. Introduce a pass "gpu-lower-memory-space-attributes":

The pass updates all memref types that have a memory space attribute that is a
`gpu::AddressSpaceAttr`. These attributes are changed to `IntegerAttr`'s using a
mapping that is given by the caller. This pass is based on the
"map-memref-spirv-storage-class" pass and the common functions can probably
be refactored into a set of utilities under the MemRef dialect.

2. Update the verifiers of GPU/NVGPU dialect operations.

If a verifier currently checks the address space of an operand using
e.g.`getWorkspaceAddressSpace`, then it can continue to do so. However, the
checks are changed to only fail if the memory space is either missing or a wrong
value of type `gpu::AddressSpaceAttr`. Otherwise, it just assumes the address
space is correct because it was specifically lowered to something other than a
`gpu::AddressSpaceAttr`.

3. Update existing gpu-to-llvm conversion infrastructure.

In the existing gpu-to-X passes, we add a full conversion equivalent to
`gpu-lower-memory-space-attributes` just before doing the conversion to the
LLVMDialect. This is done because currently both the gpu-to-llvm passes
(rocdl,nvvm) run gpu-to-gpu rewrites within the pass, which introduce
`AddressSpaceAttr` memory space annotations. Therefore, I inserted the
memory space conversion between the gpu-to-gpu rewrites and the LLVM
conversion.

For more context see the below discourse discussion:
https://discourse.llvm.org/t/gpu-workgroup-shared-memory-address-space-is-hard-coded/

Reviewed By: ftynse

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




More information about the All-commits mailing list