26 Commits

Author SHA1 Message Date
Fangrui Song
886ecb3078 [mlir] Remove setRelaxELFRelocations. NFC
The option is always true (see 2aedfdd9b82e6c72a28576d0e8ea854f1300ff4e)
and the MCAsmInfo option is going away in favor of MCTargetOptions.
2024-03-06 23:12:40 -08:00
Ingo Müller
099045a045
[mlir][nvvm] Expose MLIR_NVPTXCOMPILER_ENABLED in mlir-config.h. (#84007)
This is another 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_NVPTXCOMPILER_ENABLED`, which the CMake files previously defined
manually.
2024-03-06 14:14:53 +01:00
Ingo Müller
d70254a623
[mlir][nvvm] Add missing include to llvm-config.h. (#83998)
This is another follow-up of #83004. `NVVM/Target.cpp` uses the macro
`MLIR_NVPTXCOMPILER_ENABLED`, which is defined in `llvm-config.h` but
did not include that file, yielding a warning when compiled with
`-Wundef`. This PR adds the include.

~~This is another 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_NVPTXCOMPILER_ENABLED`, which the CMake files previously defined
manually.~~
2024-03-06 10:13:12 +01:00
Ingo Müller
f3be842728
[mlir] Expose MLIR_ROCM_CONVERSIONS_ENABLED in mlir-config.h. (#83977)
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-03-05 15:37:14 +01:00
Ingo Müller
5f2097dbed
[mlir] Expose MLIR_CUDA_CONVERSIONS_ENABLED in mlir-config.h. (#83004)
That macro was not defined in some cases and thus yielded warnings if
compiled with `-Wundef`. In particular, they were not defined in the
BUILD files, so the GPU targets were broken when built with Bazel. This
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_CUDA_CONVERSIONS_ENABLED, which the CMake files previously defined
manually.
2024-02-28 14:48:40 +01:00
Mehdi Amini
332a504985 Apply clang-tidy fixes for readability-container-size-empty in Target.cpp (NFC) 2024-02-15 16:02:41 -08:00
Mehdi Amini
867678dd81 Apply clang-tidy fixes for llvm-qualified-auto in Target.cpp (NFC) 2024-02-15 16:02:41 -08:00
Saiyedul Islam
9edd1c4dae
[MLIR][AMDGPU] Switch to code object version 5 (#79144)
As AMDGPU backend has moved to cov5 as default, mlir should also switch
to it.
2024-01-23 20:30:44 +05:30
Jie Fu
ac798eaa96 [mlir] Fix -Wunused-variable in ROCDL/Target.cpp (NFC)
/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-04 08:15:37 +08:00
Mehdi Amini
d9dadfda85
Refactor ModuleToObject to offer more flexibility to subclass (NFC)
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-11-03 13:41:45 -07:00
Krzysztof Drewniak
0463e00ac6
[mlir][ROCDL] Fix file leak in SeralizeToHsaco and its newer form (#67711)
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-29 17:24:40 -05:00
Fabian Mora
5093413a50
[mlir][gpu][NVPTX] Enable NVIDIA GPU JIT compilation path (#66220)
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-14 18:00:27 -04:00
Arthur Eubanks
0a1aa6cda2
[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes (#66295)
This will make it easy for callers to see issues with and fix up calls
to createTargetMachine after a future change to the params of
TargetMachine.

This matches other nearby enums.

For downstream users, this should be a fairly straightforward
replacement,
e.g. s/CodeGenOpt::Aggressive/CodeGenOptLevel::Aggressive
or s/CGFT_/CodeGenFileType::
2023-09-14 14:10:14 -07:00
Fabian Mora
c16adb0dcb
[mlir][Target][NVPTX] Add fatbin support to NVPTX compilation. (#65398)
Currently, the NVPTX tool compilation path only calls `ptxas`; thus, the
GPU running the binary must be an exact match of the arch of the target,
or else the runtime throws an error due to the arch mismatch.

This patch adds a call to `fatbinary`, creating a fat binary with the
cubin object and the PTX code, allowing the driver to JIT the PTX at
runtime if there's an arch mismatch.
2023-09-07 07:44:41 -04:00
Adrian Kuegel
658a4fdb26 [mlir] Apply ClangTidy fix (NFC)
Prefer to use .empty() instead of checking size().
2023-09-05 10:16:55 +02:00
Adrian Kuegel
ecfd547240 [mlir] Apply ClangTidy fix (NFC)
Prefer to use empty() instead of checking size().
2023-09-01 08:52:37 +02:00
Jacques Pienaar
cad267831e [mlir] Prefer to use empty to check for emptiness (NFC) 2023-08-31 14:10:03 -07:00
Nicolas Vasilache
7c4e8c6a27 [mlir] Disentangle dialect and extension registrations.
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-22 00:40:09 +00:00
Fabian Mora
d923f4c2d8 [mlir][NVVM|ROCDL] Explicitly construct the return type in loadBitcodeFiles 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-13 00:25:30 +00:00
Fabian Mora
068213130d [mlir][ROCDL] Adds the ROCDL target attribute.
**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-11 21:44:05 +00:00
Fabian Mora
1e77536e1d Revert "[mlir][ROCDL] Adds the ROCDL target attribute."
This reverts commit 6a0feb1503e21432e63d93b44357bad43f8026d1.
2023-08-11 19:50:05 +00:00
Fabian Mora
6a0feb1503 [mlir][ROCDL] Adds the ROCDL target attribute.
**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
2023-08-11 19:43:59 +00:00
Fabian Mora
211c9752c8 [mlir][NVVM] Adds the NVVM target attribute.
**For an explanation of these patches see D154153.**

Commit message:
This patch adds the NVVM target attribute for serializing GPU modules into
strings containing cubin.

Depends on D154113 and D154100 and D154097

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D154117
2023-08-08 19:21:36 +00: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