8 Commits

Author SHA1 Message Date
Fabian Mora
016e1eb9c8
[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@gmail.com>
2024-08-27 18:44:50 -04:00
Fabian Mora
fd36a7b944
[mlir][gpu] Pass GPU module to TargetAttrInterface::createObject. (#94910)
This patch adds an argument to `gpu::TargetAttrInterface::createObject`
to pass the GPU module. This is useful as `gpu::ObjectAttr` contains a
property dict for metadata, hence the module can be used for extracting
things like the symbol table and adding it to the property dict.

---------

Co-authored-by: Oleksandr "Alex" Zinenko <ftynse@gmail.com>
2024-08-27 11:05:04 -04:00
Mehdi Amini
c67a4ae47c Apply clang-tidy fixes for readability-container-size-empty in SerializeToLLVMBitcode.cpp (NFC) 2024-02-25 17:05:30 -08:00
Mehdi Amini
b1d1f5786f Apply clang-tidy fixes for modernize-use-override in SerializeToLLVMBitcode.cpp (NFC) 2024-02-25 17:05:30 -08:00
Stella Stamenova
5e30c74309
[mlir] Use the process (host) triple in MLIRTargetLLVMTests (#69538)
The test is meant to execute on the native target and only initializes
the native target. However, it then gets the default target triple
instead of the process (host) triple. This fails in cases where the
native target and the default target are not the same.

The test was added here: https://reviews.llvm.org/D154100
2023-10-18 18:48:24 -07:00
Fabian Mora
895c4ac33f [mlir][Target][LLVM] Adds an utility class for serializing operations to binary strings.
**For an explanation of these patches see D154153.**

Commit message:
This patch adds the utility base class `ModuleToObject`. This class provides an
interface for compiling module operations into binary strings, by default this
class serialize modules to LLVM bitcode.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D154100
2023-08-08 14:48:11 +00:00
Fabian Mora
bc9a3751e8 Revert "[mlir][Target][LLVM] Adds an utility class for serializing operations to binary strings."
This reverts commit c8e0364a4336569f91fe74dbc231beefc8793518.
2023-08-08 13:28:16 +00:00
Fabian Mora
c8e0364a43 [mlir][Target][LLVM] Adds an utility class for serializing operations to binary strings.
**For an explanation of these patches see D154153.**

Commit message:
This patch adds the utility base class `ModuleToObject`. This class provides an
interface for compiling module operations into binary strings, by default this
class serialize modules to LLVM bitcode.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D154100
2023-08-08 13:09:31 +00:00