https://github.com/Artem-B created https://github.com/llvm/llvm-project/pull/107483
Right now we're bailing out too early, and `-cuid` does not get set for the host-only compilations. >From 52a27293d1c93a7ed4dcef845f705808afa3c273 Mon Sep 17 00:00:00 2001 From: Artem Belevich <t...@google.com> Date: Thu, 5 Sep 2024 15:18:53 -0700 Subject: [PATCH] [CUDA/HIP] propagate -cuid to a host-only compilation. --- clang/lib/Driver/Driver.cpp | 12 +++++----- clang/test/Driver/hip-cuid.hip | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b3783e20eabba..efe398dd531da7 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3026,12 +3026,6 @@ class OffloadingActionBuilder final { // Set the flag to true, so that the builder acts on the current input. IsActive = true; - if (CompileHostOnly) - return ABRT_Success; - - // Replicate inputs for each GPU architecture. - auto Ty = IA->getType() == types::TY_HIP ? types::TY_HIP_DEVICE - : types::TY_CUDA_DEVICE; std::string CUID = FixedCUID.str(); if (CUID.empty()) { if (UseCUID == CUID_Random) @@ -3055,6 +3049,12 @@ class OffloadingActionBuilder final { } IA->setId(CUID); + if (CompileHostOnly) + return ABRT_Success; + + // Replicate inputs for each GPU architecture. + auto Ty = IA->getType() == types::TY_HIP ? types::TY_HIP_DEVICE + : types::TY_CUDA_DEVICE; for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) { CudaDeviceActions.push_back( C.MakeAction<InputAction>(IA->getInputArg(), Ty, IA->getId())); diff --git a/clang/test/Driver/hip-cuid.hip b/clang/test/Driver/hip-cuid.hip index ed7de782bba5ac..2e38c59ccf5ef1 100644 --- a/clang/test/Driver/hip-cuid.hip +++ b/clang/test/Driver/hip-cuid.hip @@ -58,6 +58,28 @@ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,HEX %s +// Check that cuid is propagated to the host-only compilation. +// RUN: %clang -### -x hip \ +// RUN: --target=x86_64-unknown-linux-gnu \ +// RUN: --no-offload-new-driver \ +// RUN: --offload-arch=gfx900 \ +// RUN: --offload-host-only \ +// RUN: -c -nogpuinc -nogpulib -cuid=xyz_123 \ +// RUN: %S/Inputs/hip_multiple_inputs/a.cu \ +// RUN: %S/Inputs/hip_multiple_inputs/b.hip \ +// RUN: 2>&1 | FileCheck -check-prefixes=HOST %s + +// Check that cuid is propagated to the device-only compilation. +// RUN: %clang -### -x hip \ +// RUN: --target=x86_64-unknown-linux-gnu \ +// RUN: --no-offload-new-driver \ +// RUN: --offload-arch=gfx900 \ +// RUN: --offload-device-only \ +// RUN: -c -nogpuinc -nogpulib -cuid=xyz_123 \ +// RUN: %S/Inputs/hip_multiple_inputs/a.cu \ +// RUN: %S/Inputs/hip_multiple_inputs/b.hip \ +// RUN: 2>&1 | FileCheck -check-prefixes=DEVICE %s + // INVALID: invalid value 'invalid' in '-fuse-cuid=invalid' // COMMON: "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa" @@ -92,3 +114,21 @@ // HEX-NOT: "-cuid=[[CUID]]" // COMMON-SAME: "-cuid=[[CUID2]]" // COMMON-SAME: "{{.*}}b.hip" + +// HOST: "-cc1"{{.*}} "-triple" "x86_64-unknown-linux-gnu" +// HOST-SAME: "-cuid=[[CUID:xyz_123]]" +// HOST-SAME: "{{.*}}a.cu" + +// HOST: "-cc1"{{.*}} "-triple" "x86_64-unknown-linux-gnu" +// HOST-SAME: "-cuid=[[CUID]]" +// HOST-SAME: "{{.*}}b.hip" + +// DEVICE: "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa" +// DEVICE-SAME: "-target-cpu" "gfx900" +// DEVICE-SAME: "-cuid=[[CUID:xyz_123]]" +// DEVICE-SAME: "{{.*}}a.cu" + +// DEVICE: "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa" +// DEVICE-SAME: "-target-cpu" "gfx900" +// DEVICE-SAME: "-cuid=[[CUID]]" +// DEVICE-SAME: "{{.*}}b.hip" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits