Skip to content

Commit 035dcf6

Browse files
authored
[HIP] fix bundle ID for amdgcnspirv (#139112)
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.
1 parent 74120d0 commit 035dcf6

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

clang/lib/Driver/OffloadBundler.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ bool OffloadTargetInfo::operator==(const OffloadTargetInfo &Target) const {
145145

146146
std::string OffloadTargetInfo::str() const {
147147
std::string NormalizedTriple;
148-
// Unfortunately we need some special sauce for AMDGPU because all the runtime
149-
// assumes the triple to be "amdgcn-amd-amdhsa-" (empty environment) instead
150-
// of "amdgcn-amd-amdhsa-unknown". It's gonna be very tricky to patch
151-
// different layers of runtime.
152-
if (Triple.isAMDGPU()) {
148+
// Unfortunately we need some special sauce for AMDHSA because all the runtime
149+
// assumes the triple to be "amdgcn/spirv64-amd-amdhsa-" (empty environment)
150+
// instead of "amdgcn/spirv64-amd-amdhsa-unknown". It's gonna be very tricky
151+
// to patch different layers of runtime.
152+
if (Triple.getOS() == Triple::OSType::AMDHSA) {
153153
NormalizedTriple = Triple.normalize(Triple::CanonicalForm::THREE_IDENT);
154154
NormalizedTriple.push_back('-');
155155
} else {

clang/test/Driver/clang-offload-bundler-standardize.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
//
1212
// RUN: echo 'Content of device file 1' > %t.tgt1
1313
// RUN: echo 'Content of device file 2' > %t.tgt2
14-
14+
// RUN: echo 'Content of device file 3' > %t.tgt3
1515
//
1616
// Check code object compatibility for archive unbundling
1717
//
1818
// Create an object bundle
19-
// 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
19+
// 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
2020

21-
// 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
21+
// 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
2222
// BUNDLE: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906]
2323
// BUNDLE: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx908] : [Target: hip-amdgcn-amd-amdhsa--gfx908]
24+
// BUNDLE: Compatible: Exact match: [CodeObject: hip-spirv64-amd-amdhsa--amdgcnspirv] : [Target: hip-spirv64-amd-amdhsa--amdgcnspirv]
2425

2526
// Some code so that we can create a binary out of this file.
2627
int A = 0;

0 commit comments

Comments
 (0)