[Mlir-commits] [mlir] [mlir][Target] Make nvptxcompiler passed options high priority to keep consistent with ptxas behavior (PR #121036)

Zichen Lu llvmlistbot at llvm.org
Tue Dec 24 00:20:58 PST 2024


https://github.com/MikaOvO created https://github.com/llvm/llvm-project/pull/121036

When using `ptxas` to do ptx->cubin, the options passed (via `cmd`) have higher priority than the gpuModule target (such as `opt-level`). When using `nvptxcompiler`, it is the opposite and we need to be consistent.

>From ed42c7e2cc44f0e3ef42189adc25a32efba2ee73 Mon Sep 17 00:00:00 2001
From: Zichen Lu <mikaovo2000 at gmail.com>
Date: Tue, 24 Dec 2024 16:17:00 +0800
Subject: [PATCH] [mlir][Target] Make nvptxcompiler passed options high
 priority to be consistent with ptxas

---
 mlir/lib/Target/LLVM/NVVM/Target.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Target/LLVM/NVVM/Target.cpp b/mlir/lib/Target/LLVM/NVVM/Target.cpp
index bca26e3a0e84a9..0f630f56af301e 100644
--- a/mlir/lib/Target/LLVM/NVVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/NVVM/Target.cpp
@@ -484,7 +484,8 @@ NVPTXSerializer::compileToBinaryNVPTX(const std::string &ptxCode) {
   std::string optLevel = std::to_string(this->optLevel);
   std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>> cmdOpts =
       targetOptions.tokenizeCmdOptions();
-  cmdOpts.second.append(
+  cmdOpts.second.insert(
+      cmdOpts.second.begin(),
       {"-arch", getTarget().getChip().data(), "--opt-level", optLevel.c_str()});
 
   // Create the compiler handle.



More information about the Mlir-commits mailing list