Skip to content

Silence MLIRTargetLLVMTests failures pre-ROCm6.4 #147610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions mlir/unittests/Target/LLVM/SerializeROCDLTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Please add inline comments about what happens here and maybe move this to a separate function. Otherwise, it will be very unclear what's going on here, I fear.

return false;
llvm::SmallString<128> lldPath(rocmPath);
llvm::sys::path::append(lldPath, "llvm", "bin", "ld.lld");
return llvm::sys::fs::can_execute(lldPath);
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down