summaryrefslogtreecommitdiff
path: root/mlir/lib/Target/LLVM/ROCDL/Target.cpp
AgeCommit message (Collapse)Author
2025-10-06[NFC][MLIR] Prefer triple overload of lookupTarget (#162187)Aiden Grossman
The overloads accepting a string will be deprecated soon, similar to other functions in TargetRegistry.
2025-09-08MC: Add Triple overloads for more MC constructors (#157321)Matt Arsenault
Avoids more Triple->string->Triple round trip. This is a continuation of f137c3d592e96330e450a8fd63ef7e8877fc1908
2025-04-02[MLIR][AMDGPU] Bump to COV6 (#133849)Shilei Tian
We already bump to COV6 by default in the front-end and backend. This PR is for MLIR. Note that COV6 requires ROCm 6.3+.
2024-12-17[MLIR] Add a BlobAttr interface for attribute to wrap arbitrary content and ↵Mehdi Amini
use it as linkLibs for ModuleToObject (#120116) This change allows to expose through an interface attributes wrapping content as external resources, and the usage inside the ModuleToObject show how we will be able to provide runtime libraries without relying on the filesystem.
2024-09-20[ROCDL] Pass `amd_code_object_version` when serializing ROCDL gpu module ↵Umang Yadav
(#108874) This PR adds ability to pass non-default value to `.amdhsa_code_object_version` metadata when serializing ROCDL GPU modules. It also fixes typos in two places. --------- Co-authored-by: Fabian Mora <fmora.dev@gmail.com>
2024-08-27[mlir][gpu] Add metadata attributes for storing kernel metadata in GPU ↵Fabian Mora
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[mlir][gpu] Pass GPU module to `TargetAttrInterface::createObject`. (#94910)Fabian Mora
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-07-20[MC] Remove unused bool arguments from createMCObjectStreamer callersFangrui Song
2024-07-16[mlir][ROCDL] Construct AMDGCN ISA control variable explicitly (#98912)Fabian Mora
This patch constructs the AMDGCN ISA control variable explicitly instead of linking against the library shipped with ROCm. This change prevents issues arising from the order in which the AMDGCN libraries are linked.
2024-06-25Reland [mlir][Target] Improve ROCDL gpu serialization API (#96198)Fabian Mora
Reland: https://github.com/llvm/llvm-project/pull/95456 This patch improves the ROCDL gpu serialization API by: - Introducing the enum `AMDGCNLibraries` for specifying the AMD GCN device code libraries to use during linking. - Removing `getCommonBitcodeLibs` in favor of `AMDGCNLibraries`. Previously `getCommonBitcodeLibs` would try to load all AMD GCN bitcode librariesm now it will only load the requested libraries. - Exposing the `compileToBinary` method and making it virtual, allowing downstream users to re-use this method. - Exposing `moduleToObjectImpl`, this method provides a prototype flow for compiling to binary, allowing downstream users to re-use this method. - It also avoids constructing the control variables if no device libraries are being used. - Changes the style of the error messages to be composable, ie no full stops. - Adds an error message for when the ROCm toolkit can't be found but it was required.
2024-06-17Revert "Reland [mlir][Target] Improve ROCDL gpu serialization API" (#95847)Fabian Mora
Reverts llvm/llvm-project#95813
2024-06-17Reland [mlir][Target] Improve ROCDL gpu serialization API (#95813)Fabian Mora
Reland: https://github.com/llvm/llvm-project/pull/95456 This patch improves the ROCDL gpu serialization API by: - Introducing the enum `AMDGCNLibraries` for specifying the AMD GCN device code libraries to use during linking. - Removing `getCommonBitcodeLibs` in favor of `AMDGCNLibraries`. Previously `getCommonBitcodeLibs` would try to load all AMD GCN bitcode librariesm now it will only load the requested libraries. - Exposing the `compileToBinary` method and making it virtual, allowing downstream users to re-use this method. - Exposing `moduleToObjectImpl`, this method provides a prototype flow for compiling to binary, allowing downstream users to re-use this method. - It also avoids constructing the control variables if no device libraries are being used. - Changes the style of the error messages to be composable, ie no full stops. - Adds an error message for when the ROCm toolkit can't be found but it was required.
2024-06-17Revert [mlir][Target] Improve ROCDL gpu serialization API (#95790)Fabian Mora
Reverts llvm/llvm-project#95456
2024-06-17[mlir][Target] Improve ROCDL gpu serialization API (#95456)Fabian Mora
This patch improves the ROCDL gpu serialization API by: - Introducing the enum `AMDGCNLibraries` for specifying the AMD GCN device code libraries to use during linking. - Removing `getCommonBitcodeLibs` in favor of `AMDGCNLibraries`. Previously `getCommonBitcodeLibs` would try to load all AMD GCN bitcode librariesm now it will only load the requested libraries. - Exposing the `compileToBinary` method and making it virtual, allowing downstream users to re-use this method. - Exposing `moduleToObjectImpl`, this method provides a prototype flow for compiling to binary, allowing downstream users to re-use this method. - It also avoids constructing the control variables if no device libraries are being used. This patch also changes the behavior of the CMake flag `DEFAULT_ROCM_PATH`. Before it would fall back to a default value of `/opt/rocm` if not specified. However, that default value causes fragile builds in environments with ROCm. Now, the flag falls back to the empty string, making it clear that **the user must provide a value at LLVM build time**.
2024-05-15[mlir] Fix the build after 03c53c69a367008da689f0d2940e2197eb4a955cBenjamin Kramer
2024-03-06[mlir] Remove setRelaxELFRelocations. NFCFangrui Song
The option is always true (see 2aedfdd9b82e6c72a28576d0e8ea854f1300ff4e) and the MCAsmInfo option is going away in favor of MCTargetOptions.
2024-03-05[mlir] Expose MLIR_ROCM_CONVERSIONS_ENABLED in mlir-config.h. (#83977)Ingo Müller
This is a follow up of #83004, which made the same change for `MLIR_CUDA_CONVERSIONS_ENABLED`. As the previous PR, this PR commit exposes mentioned CMake variable through `mlir-config.h` and uses the macro that is introduced with the same name. This replaces the macro `MLIR_ROCM_CONVERSIONS_ENABLED`, which the CMake files previously defined manually.
2024-01-23[MLIR][AMDGPU] Switch to code object version 5 (#79144)Saiyedul Islam
As AMDGPU backend has moved to cov5 as default, mlir should also switch to it.
2023-11-04[mlir] Fix -Wunused-variable in ROCDL/Target.cpp (NFC)Jie Fu
/llvm-project/mlir/lib/Target/LLVM/ROCDL/Target.cpp:181:40: error: unused variable 'targetMachine' [-Werror,-Wunused-variable] std::optional<llvm::TargetMachine *> targetMachine = ^ 1 error generated.
2023-11-03Refactor ModuleToObject to offer more flexibility to subclass (NFC)Mehdi Amini
Some specific implementation of the offload may want more customization, and even avoid using LLVM in-tree to dispatch the ISA translation to a custom solution. This refactoring makes it possible for such implementation to work without even configuring the target backend in LLVM. Reviewers: fabianmcg Reviewed By: fabianmcg Pull Request: https://github.com/llvm/llvm-project/pull/71165
2023-09-29[mlir][ROCDL] Fix file leak in SeralizeToHsaco and its newer form (#67711)Krzysztof Drewniak
SerializetToHsaco, as currently implemented, leaks the file descriptor of the .hsaco temporary file, which causes issues in long-running parallel compilation setups. See also https://github.com/ROCmSoftwarePlatform/rocMLIR/pull/1257
2023-09-14[mlir][gpu][NVPTX] Enable NVIDIA GPU JIT compilation path (#66220)Fabian Mora
This patch adds an NVPTX compilation path that enables JIT compilation on NVIDIA targets. The following modifications were performed: 1. Adding a format field to the GPU object attribute, allowing the translation attribute to use the correct runtime function to load the module. Likewise, a dictionary attribute was added to add any possible extra options. 2. Adding the `createObject` method to `GPUTargetAttrInterface`; this method returns a GPU object from a binary string. 3. Adding the function `mgpuModuleLoadJIT`, which is only available for NVIDIA GPUs, as there is no equivalent for AMD. 4. Adding the CMake flag `MLIR_GPU_COMPILATION_TEST_FORMAT` to specify the format to use during testing.
2023-09-01[mlir] Apply ClangTidy fix (NFC)Adrian Kuegel
Prefer to use empty() instead of checking size().
2023-08-22[mlir] Disentangle dialect and extension registrations.Nicolas Vasilache
This revision avoids the registration of dialect extensions in Pass::getDependentDialects. Such registration of extensions can be dangerous because `DialectRegistry::isSubsetOf` is always guaranteed to return false for extensions (i.e. there is no mechanism to track whether a lambda is already in the list of already registered extensions). When the context is already in a multi-threaded mode, this is guaranteed to assert. Arguably a more structured registration mechanism for extensions with a unique ExtensionID could be envisioned in the future. In the process of cleaning this up, multiple usage inconsistencies surfaced around the registration of translation extensions that this revision also cleans up. Reviewed By: springerm Differential Revision: https://reviews.llvm.org/D157703
2023-08-13[mlir][NVVM|ROCDL] Explicitly construct the return type in loadBitcodeFiles ↵Fabian Mora
in (NVVM|ROCDL)Target Fix a build failure in GCC 7 caused by the function: `std::optional<SmallVector<std::unique_ptr<llvm::Module>>> loadBitcodeFiles` , in `NVVMTarget` & `ROCDLTarget`. The failure is caused because GCC fails to use the move constructor in `std::optional` for constructing the return value, which prompts a call to the deleted copy constructor in `std::unique_ptr`, resulting in a failure. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D157804
2023-08-11[mlir][ROCDL] Adds the ROCDL target attribute.Fabian Mora
**For an explanation of these patches see D154153.** Commit message: This patch adds the ROCDL target attribute for serializing GPU modules into strings containing HSAco. Depends on D154117 Differential Revision: https://reviews.llvm.org/D154129
2023-08-11Revert "[mlir][ROCDL] Adds the ROCDL target attribute."Fabian Mora
This reverts commit 6a0feb1503e21432e63d93b44357bad43f8026d1.
2023-08-11[mlir][ROCDL] Adds the ROCDL target attribute.Fabian Mora
**For an explanation of these patches see D154153.** Commit message: This patch adds the ROCDL target attribute for serializing GPU modules into strings containing HSAco. Depends on D154117 Reviewed By: mehdi_amini, krzysz00 Differential Revision: https://reviews.llvm.org/D154129