Skip to content

Commit

Permalink
[HIP] Use original file path for CUID (#107734)
Browse files Browse the repository at this point in the history
to avoid being nondeterministic due to random path in distributed build.
  • Loading branch information
yxsamliu authored Sep 15, 2024
1 parent 9de2603 commit 9fc789d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 1 addition & 4 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,10 +3034,7 @@ class OffloadingActionBuilder final {
else if (UseCUID == CUID_Hash) {
llvm::MD5 Hasher;
llvm::MD5::MD5Result Hash;
SmallString<256> RealPath;
llvm::sys::fs::real_path(IA->getInputArg().getValue(), RealPath,
/*expand_tilde=*/true);
Hasher.update(RealPath);
Hasher.update(IA->getInputArg().getValue());
for (auto *A : Args) {
if (A->getOption().matches(options::OPT_INPUT))
continue;
Expand Down
12 changes: 7 additions & 5 deletions clang/test/Driver/hip-cuid-hash.hip
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Check CUID generated by hash.
// The same CUID is generated for the same file with the same options.

// RUN: cd %S

// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
// RUN: %S/Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
// RUN: Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1

// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu --no-offload-new-driver \
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
// RUN: %S/Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
// RUN: Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1

// RUN: FileCheck %s -check-prefixes=SAME -input-file %t.out

Expand All @@ -16,15 +18,15 @@

// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu -DX=1 --no-offload-new-driver \
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
// RUN: %S/Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1
// RUN: Inputs/hip_multiple_inputs/a.cu >%t.out 2>&1

// RUN: %clang -### -x hip --target=x86_64-unknown-linux-gnu -DX=2 --no-offload-new-driver \
// RUN: --offload-arch=gfx906 -c -nogpuinc -nogpulib -fuse-cuid=hash \
// RUN: %S/Inputs/../Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1
// RUN: Inputs/../Inputs/hip_multiple_inputs/a.cu >>%t.out 2>&1

// RUN: FileCheck %s -check-prefixes=DIFF -input-file %t.out

// SAME: "-cc1"{{.*}} "-target-cpu" "gfx906" {{.*}}"-cuid=[[CUID:[0-9a-f]+]]"
// SAME: "-cc1"{{.*}} "-target-cpu" "gfx906" {{.*}}"-cuid=[[CUID:3c08c1ef86ef439d]]"
// SAME: "-cc1"{{.*}} "-target-cpu" "gfx906" {{.*}}"-cuid=[[CUID]]"

// DIFF: "-cc1"{{.*}} "-target-cpu" "gfx906" {{.*}}"-cuid=[[CUID:[0-9a-f]+]]"
Expand Down

0 comments on commit 9fc789d

Please sign in to comment.