[all-commits] [llvm/llvm-project] 016e1e: [mlir][gpu] Add metadata attributes for storing ke...

Fabian Mora via All-commits all-commits at lists.llvm.org
Tue Aug 27 15:45:12 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 016e1eb9c86923bf6a9669697f6be8309d12b78c
      https://github.com/llvm/llvm-project/commit/016e1eb9c86923bf6a9669697f6be8309d12b78c
  Author: Fabian Mora <fmora.dev at gmail.com>
  Date:   2024-08-27 (Tue, 27 Aug 2024)

  Changed paths:
    M mlir/include/mlir-c/Dialect/GPU.h
    M mlir/include/mlir/Dialect/GPU/IR/CompilationAttrs.td
    M mlir/include/mlir/Target/LLVM/ROCDL/Utils.h
    M mlir/lib/Bindings/Python/DialectGPU.cpp
    M mlir/lib/CAPI/Dialect/GPU.cpp
    M mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
    M mlir/lib/Target/LLVM/CMakeLists.txt
    M mlir/lib/Target/LLVM/NVVM/Target.cpp
    M mlir/lib/Target/LLVM/ROCDL/Target.cpp
    A mlir/lib/Target/LLVM/ROCDL/Utils.cpp
    M mlir/lib/Target/SPIRV/Target.cpp
    M mlir/test/Dialect/GPU/invalid.mlir
    M mlir/test/Dialect/GPU/ops.mlir
    M mlir/test/python/dialects/gpu/dialect.py
    M mlir/unittests/Target/LLVM/SerializeROCDLTarget.cpp
    M mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp

  Log Message:
  -----------
  [mlir][gpu] Add metadata attributes for storing kernel metadata in GPU objects (#95292)

This patch adds the `#gpu.kernel_metadata` and `#gpu.kernel_table`
attributes. The `#gpu.kernel_metadata` attribute allows storing metadata
related to a compiled kernel, for example, the number of scalar
registers used by the kernel. The attribute only has 2 required
parameters, the name and function type. It also has 2 optional
parameters, the arguments attributes and generic dictionary for storing
all other metadata.

The `#gpu.kernel_table` stores a table of `#gpu.kernel_metadata`,
mapping the name of the kernel to the metadata.

Finally, the function `ROCDL::getAMDHSAKernelsELFMetadata` was added to
collect ELF metadata from a binary, and to test the class methods in
both attributes.

Example:
```mlir
gpu.binary @binary [#gpu.object<#rocdl.target<chip = "gfx900">, kernels = #gpu.kernel_table<[
    #gpu.kernel_metadata<"kernel0", (i32) -> (), metadata = {sgpr_count = 255}>,
    #gpu.kernel_metadata<"kernel1", (i32, f32) -> (), arg_attrs = [{llvm.read_only}, {}]>
  ]> , bin = "BLOB">]

```
The motivation behind these attributes is to provide useful information
for things like tunning.

---------

Co-authored-by: Mehdi Amini <joker.eph at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list