[Mlir-commits] [mlir] Silence MLIRTargetLLVMTests failures pre-ROCm6.4 (PR #147610)
Scott Linder
llvmlistbot at llvm.org
Tue Jul 8 15:47:58 PDT 2025
https://github.com/slinder1 created https://github.com/llvm/llvm-project/pull/147610
COV6 was made default in 6.4, so check that the ROCm we find isn't older before assuming the tests should pass.
Not sure this is worth the code, and it may make more sense to fail open if e.g. the .info/version file isn't present or doesn't have the version in the expected format. I had already written the code before noting this, so figured I'd just see what others think.
>From 31f2eb1e503f1e7ff7241a897855ca3ea5129225 Mon Sep 17 00:00:00 2001
From: Scott Linder <Scott.Linder at amd.com>
Date: Tue, 8 Jul 2025 22:37:24 +0000
Subject: [PATCH] Silence MLIRTargetLLVMTests failures pre-ROCm6.4
COV6 was made default in 6.4, so check that the ROCm we find isn't older
before assuming the tests should pass.
---
.../Target/LLVM/SerializeROCDLTarget.cpp | 26 +++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/mlir/unittests/Target/LLVM/SerializeROCDLTarget.cpp b/mlir/unittests/Target/LLVM/SerializeROCDLTarget.cpp
index a015e1d7dde62..ef314623956d0 100644
--- a/mlir/unittests/Target/LLVM/SerializeROCDLTarget.cpp
+++ b/mlir/unittests/Target/LLVM/SerializeROCDLTarget.cpp
@@ -20,6 +20,7 @@
#include "llvm/IRReader/IRReader.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TargetSelect.h"
@@ -52,6 +53,27 @@ class MLIRTargetLLVMROCDL : public ::testing::Test {
StringRef rocmPath = ROCDL::getROCMPath();
if (rocmPath.empty())
return false;
+ llvm::SmallString<128> rocmVerPath(rocmPath);
+ llvm::sys::path::append(rocmVerPath, ".info", "version");
+ auto bufOrErr = llvm::MemoryBuffer::getFile(rocmVerPath, /*IsText=*/true);
+ if (!bufOrErr)
+ return false;
+ SmallVector<StringRef, 2> majorMinorRest;
+ bufOrErr.get()->getBuffer().split(majorMinorRest, '.', /*MaxSplit=*/2);
+ if (majorMinorRest.size() != 3)
+ return false;
+ auto asInt = [](StringRef s) -> int {
+ unsigned i;
+ if (s.getAsInteger(/*Radix=*/10, i))
+ return -1;
+ return i;
+ };
+ int major = asInt(majorMinorRest[0]);
+ int minor = asInt(majorMinorRest[1]);
+ if (major < 6)
+ return false;
+ if (major == 6 && minor < 4)
+ return false;
llvm::SmallString<128> lldPath(rocmPath);
llvm::sys::path::append(lldPath, "llvm", "bin", "ld.lld");
return llvm::sys::fs::can_execute(lldPath);
@@ -185,7 +207,7 @@ TEST_F(MLIRTargetLLVMROCDL, SKIP_WITHOUT_AMDGPU(SerializeROCDLToPTX)) {
// Test ROCDL serialization to Binary.
TEST_F(MLIRTargetLLVMROCDL, SKIP_WITHOUT_AMDGPU(SerializeROCDLToBinary)) {
if (!hasROCMTools())
- GTEST_SKIP() << "ROCm installation not found, skipping test.";
+ GTEST_SKIP() << "Compatible ROCm installation not found, skipping test.";
MLIRContext context(registry);
@@ -212,7 +234,7 @@ TEST_F(MLIRTargetLLVMROCDL, SKIP_WITHOUT_AMDGPU(SerializeROCDLToBinary)) {
// Test ROCDL metadata.
TEST_F(MLIRTargetLLVMROCDL, SKIP_WITHOUT_AMDGPU(GetELFMetadata)) {
if (!hasROCMTools())
- GTEST_SKIP() << "ROCm installation not found, skipping test.";
+ GTEST_SKIP() << "Compatible ROCm installation not found, skipping test.";
MLIRContext context(registry);
More information about the Mlir-commits
mailing list