Skip to content

Commit 4fd05e0

Browse files
committed
[HIP] Change to code object v4
Change to code object v4 by default to match ROCm 4.1. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D99235
1 parent 01a23dc commit 4fd05e0

File tree

10 files changed

+16
-14
lines changed

10 files changed

+16
-14
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
15771577
const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
15781578
const unsigned MinCodeObjVer = 2;
15791579
const unsigned MaxCodeObjVer = 4;
1580-
unsigned CodeObjVer = 3;
1580+
unsigned CodeObjVer = 4;
15811581

15821582
// Emit warnings for legacy options even if they are overridden.
15831583
if (Diagnose) {

clang/lib/Driver/ToolChains/HIP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ void AMDGCN::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
108108
std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
109109
std::string BundlerInputArg = "-inputs=" NULL_FILE;
110110

111-
// TODO: Change the bundle ID as requested by HIP runtime.
112111
// For code object version 2 and 3, the offload kind in bundle ID is 'hip'
113112
// for backward compatibility. For code object version 4 and greater, the
114113
// offload kind in bundle ID is 'hipv4'.
115114
std::string OffloadKind = "hip";
115+
if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
116+
OffloadKind = OffloadKind + "v4";
116117
for (const auto &II : Inputs) {
117118
const auto* A = II.getAction();
118119
BundlerTargetArg = BundlerTargetArg + "," + OffloadKind +

clang/test/Driver/hip-code-object-version.hip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@
4545
// RUN: %s 2>&1 | FileCheck -check-prefix=V4 %s
4646

4747
// V4: "-mllvm" "--amdhsa-code-object-version=4"
48-
// V4: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
48+
// V4: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
4949

5050
// Check bundle ID for code object version default
5151

5252
// RUN: %clang -### -target x86_64-linux-gnu \
5353
// RUN: --offload-arch=gfx906 -nogpulib \
5454
// RUN: %s 2>&1 | FileCheck -check-prefix=VD %s
5555

56-
// VD: "-mllvm" "--amdhsa-code-object-version=3"
57-
// VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
56+
// VD: "-mllvm" "--amdhsa-code-object-version=4"
57+
// VD: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
5858

5959
// Check invalid code object version option.
6060

clang/test/Driver/hip-target-id.hip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
// CHECK-SAME: "-plugin-opt=-mattr=-sramecc,+xnack"
4848

4949
// CHECK: {{"[^"]*clang-offload-bundler[^"]*"}}
50-
// CHECK-SAME: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx908:sramecc+:xnack+,hip-amdgcn-amd-amdhsa--gfx908:sramecc-:xnack+"
50+
// CHECK-SAME: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc+:xnack+,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc-:xnack+"
5151

5252
// Check canonicalization and repeating of target ID.
5353

@@ -58,7 +58,7 @@
5858
// RUN: --offload-arch=fiji \
5959
// RUN: --rocm-path=%S/Inputs/rocm \
6060
// RUN: %s 2>&1 | FileCheck -check-prefix=FIJI %s
61-
// FIJI: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx803"
61+
// FIJI: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx803"
6262

6363
// RUN: %clang -### -target x86_64-linux-gnu \
6464
// RUN: -x hip \
@@ -69,4 +69,4 @@
6969
// RUN: --offload-arch=gfx906 \
7070
// RUN: --rocm-path=%S/Inputs/rocm \
7171
// RUN: %s 2>&1 | FileCheck -check-prefix=MULTI %s
72-
// MULTI: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx900:xnack+,hip-amdgcn-amd-amdhsa--gfx900:xnack-,hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908:sramecc+,hip-amdgcn-amd-amdhsa--gfx908:sramecc-"
72+
// MULTI: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx900:xnack+,hipv4-amdgcn-amd-amdhsa--gfx900:xnack-,hipv4-amdgcn-amd-amdhsa--gfx906,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc+,hipv4-amdgcn-amd-amdhsa--gfx908:sramecc-"

clang/test/Driver/hip-toolchain-device-only.hip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
// CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
2626

2727
// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
28-
// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
28+
// CHECK-SAME: "-targets={{.*}},hip{{.*}}-amdgcn-amd-amdhsa--gfx803,hip{{.*}}-amdgcn-amd-amdhsa--gfx900"
2929
// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV_A_803]],[[IMG_DEV_A_900]]" "-outputs=[[BUNDLE_A:.*hipfb]]"

clang/test/Driver/hip-toolchain-no-rdc.hip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
8484
// CHECK-SAME: "-bundle-align=4096"
85-
// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
85+
// CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
8686
// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV_A_803]],[[IMG_DEV_A_900]]" "-outputs=[[BUNDLE_A:.*hipfb]]"
8787

8888
// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
@@ -145,7 +145,7 @@
145145

146146
// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
147147
// CHECK-SAME: "-bundle-align=4096"
148-
// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
148+
// CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
149149
// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV_B_803]],[[IMG_DEV_B_900]]" "-outputs=[[BUNDLE_A:.*hipfb]]"
150150

151151
// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"

clang/test/Driver/hip-toolchain-rdc-separate.hip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
// LINK-SAME: "-o" "[[IMG_DEV2:.*.out]]" "[[A_BC2]]" "[[B_BC2]]"
126126

127127
// LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
128-
// LINK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
128+
// LINK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
129129
// LINK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
130130

131131
// LINK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"

clang/test/Driver/hip-toolchain-rdc-static-lib.hip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585

8686
// combine images generated into hip fat binary object
8787
// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
88-
// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
88+
// CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
8989
// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
9090

9191
// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"

clang/test/Driver/hip-toolchain-rdc.hip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
// combine images generated into hip fat binary object
9898
// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
9999
// CHECK-SAME: "-bundle-align=4096"
100-
// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
100+
// CHECK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
101101
// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
102102

103103
// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"

clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,7 @@ int main(int argc, const char **argv) {
11431143
.Case("host", true)
11441144
.Case("openmp", true)
11451145
.Case("hip", true)
1146+
.Case("hipv4", true)
11461147
.Default(false);
11471148

11481149
bool TripleIsValid = !Triple.empty();

0 commit comments

Comments
 (0)