[clang] [HIP] fix bundle ID for amdgcnspirv (PR #139112)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Thu May 8 13:16:43 PDT 2025
https://github.com/yxsamliu updated https://github.com/llvm/llvm-project/pull/139112
>From 7606c3bca9ba1de181d16038218963e822bb90e3 Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" <yaxun.liu at amd.com>
Date: Thu, 8 May 2025 12:40:23 -0400
Subject: [PATCH] [HIP] fix bundle ID for amdgcnspirv
Currently ROCm 6.4.0 only recognize spirv64-amd-amdhsa-
in bundle ID. spirv64-amd-amdhsa-unknown causes all
HIP apps compiled for amdgcnspirv to fail.
Previously we fixed a similar issue for
amdgcn-amd-amdhsa-unknown. This patch extends that
to spirv64-amd-amdhsa-unknown.
---
clang/lib/Driver/OffloadBundler.cpp | 10 +++++-----
clang/test/Driver/clang-offload-bundler-standardize.c | 7 ++++---
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp
index 859e44fb9bdb2..e7a737796925e 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -145,11 +145,11 @@ bool OffloadTargetInfo::operator==(const OffloadTargetInfo &Target) const {
std::string OffloadTargetInfo::str() const {
std::string NormalizedTriple;
- // Unfortunately we need some special sauce for AMDGPU because all the runtime
- // assumes the triple to be "amdgcn-amd-amdhsa-" (empty environment) instead
- // of "amdgcn-amd-amdhsa-unknown". It's gonna be very tricky to patch
- // different layers of runtime.
- if (Triple.isAMDGPU()) {
+ // Unfortunately we need some special sauce for AMDHSA because all the runtime
+ // assumes the triple to be "amdgcn/spirv64-amd-amdhsa-" (empty environment)
+ // instead of "amdgcn/spirv64-amd-amdhsa-unknown". It's gonna be very tricky
+ // to patch different layers of runtime.
+ if (Triple.getOS() == Triple::OSType::AMDHSA) {
NormalizedTriple = Triple.normalize(Triple::CanonicalForm::THREE_IDENT);
NormalizedTriple.push_back('-');
} else {
diff --git a/clang/test/Driver/clang-offload-bundler-standardize.c b/clang/test/Driver/clang-offload-bundler-standardize.c
index fd87fca4ff59d..5b831eec794d2 100644
--- a/clang/test/Driver/clang-offload-bundler-standardize.c
+++ b/clang/test/Driver/clang-offload-bundler-standardize.c
@@ -11,16 +11,17 @@
//
// RUN: echo 'Content of device file 1' > %t.tgt1
// RUN: echo 'Content of device file 2' > %t.tgt2
-
+// RUN: echo 'Content of device file 3' > %t.tgt3
//
// Check code object compatibility for archive unbundling
//
// Create an object bundle
-// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle
+// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908,hip-spirv64-amd-amdhsa--amdgcnspirv -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -input=%t.tgt3 -output=%t.bundle
-// RUN: clang-offload-bundler -unbundle -type=o -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908 -input=%t.bundle -output=%t-hip-amdgcn-amd-amdhsa--gfx906.bc -output=%t-hip-amdgcn-amd-amdhsa--gfx908.bc -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=BUNDLE
+// RUN: clang-offload-bundler -unbundle -type=o -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908,hip-spirv64-amd-amdhsa--amdgcnspirv -input=%t.bundle -output=%t-hip-amdgcn-amd-amdhsa--gfx906.bc -output=%t-hip-amdgcn-amd-amdhsa--gfx908.bc -output=%t-hip-spirv64-amd-amdhsa--amdgcnspirv.bc -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=BUNDLE
// BUNDLE: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906]
// BUNDLE: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx908] : [Target: hip-amdgcn-amd-amdhsa--gfx908]
+// BUNDLE: Compatible: Exact match: [CodeObject: hip-spirv64-amd-amdhsa--amdgcnspirv] : [Target: hip-spirv64-amd-amdhsa--amdgcnspirv]
// Some code so that we can create a binary out of this file.
int A = 0;
More information about the cfe-commits
mailing list