From a6218a70aa6b2bded8c2a650473436f35902ba20 Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Thu, 29 Jul 2021 14:44:42 +0100 Subject: [PATCH 1/8] [SYCL][ROCm] Use offload-arch instead of mcpu for AMD arch This patch changes using `-mcpu` for SYCL applications targeting AMD to `-Xsycl-target-backend --offload-arch`. Before this patch the offloading arch wasn't set correctly for AMD architectures. This is fixing an issue with HIP that was talked about in #4133, regarding having `v4` in the hip part of the triple, without the `v4` HIP seems to be ignoring the fact that the offloading arch is missing from the triple, which is why there was a workaround orignally to force not using `v4` with SYCL. By fixing the offloading arch this patch fixes the issue properly and now the triple with `v4` works because it also contains the offloading architecture. --- .../clang/Basic/DiagnosticDriverKinds.td | 2 + clang/lib/Driver/Driver.cpp | 99 +++++++++++++++---- clang/lib/Driver/ToolChain.cpp | 5 +- sycl/doc/GetStartedGuide.md | 7 +- 4 files changed, 89 insertions(+), 24 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 41e73f611eb83..798b7021a4cc0 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -289,6 +289,8 @@ def err_drv_expecting_fsycl_with_sycl_opt : Error< "'%0' must be used in conjunction with '-fsycl' to enable offloading">; def err_drv_fsycl_with_c_type : Error< "'%0' must not be used in conjunction with '-fsycl', which expects C++ source">; +def err_drv_sycl_missing_amdgpu_arch : Error< + "Missing AMDGPU architecture for SYCL offloading. Please specify it with -Xsycl-target-backend --offload-arch.">; def warn_drv_sycl_offload_target_duplicate : Warning< "SYCL offloading target '%0' is similar to target '%1' already specified; " "will be ignored">, InGroup; diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 7886579d6fb76..b2257adea06ff 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3961,7 +3961,7 @@ class OffloadingActionBuilder final { ActionList FPGAArchiveInputs; /// List of CUDA architectures to use in this compilation with NVPTX targets. - SmallVector GpuArchList; + SmallVector, 8> GpuArchList; /// Build the last steps for CUDA after all BC files have been linked. JobAction *finalizeNVPTXDependences(Action *Input, const llvm::Triple &TT) { @@ -3998,13 +3998,17 @@ class OffloadingActionBuilder final { const Driver::InputList &Inputs) : DeviceActionBuilder(C, Args, Inputs, Action::OFK_SYCL) {} - void withBoundArchForToolChain(const ToolChain* TC, + void withBoundArchForToolChain(const ToolChain *TC, llvm::function_ref Op) { - if (TC->getTriple().isNVPTX()) - for (CudaArch A : GpuArchList) - Op(CudaArchToString(A)); - else - Op(nullptr); + for (auto &A : GpuArchList) { + if (TC->getTriple() == A.first) { + Op(Args.MakeArgString(A.second.c_str())); + return; + } + } + + // no bound arch for this toolchain + Op(nullptr); } ActionBuilderReturnCode @@ -4058,8 +4062,8 @@ class OffloadingActionBuilder final { } const auto *TC = ToolChains.front(); const char *BoundArch = nullptr; - if (TC->getTriple().isNVPTX()) - BoundArch = CudaArchToString(GpuArchList.front()); + if (TC->getTriple().isNVPTX() || TC->getTriple().isAMDGCN()) + BoundArch = GpuArchList.front().second.c_str(); DA.add(*DeviceCompilerInput, *TC, BoundArch, Action::OFK_SYCL); // Clear the input file, it is already a dependence to a host // action. @@ -4642,39 +4646,94 @@ class OffloadingActionBuilder final { } } - /// Initialize the GPU architecture list from arguments - this populates `GpuArchList` from - /// `--cuda-gpu-arch` flags. Only relevant if compiling to CUDA. Return true if any - /// initialization errors are found. + /// Initialize the GPU architecture list from arguments - this populates + /// `GpuArchList` from `--offload-arch` flags. Only relevant if compiling to + /// CUDA or AMDGCN. Return true if any initialization errors are found. + /// FIXME: SPIR-V AOT targets should also use `offload-arch` to better fit + /// in the standard model. bool initializeGpuArchMap() { const OptTable &Opts = C.getDriver().getOpts(); for (auto *A : Args) { unsigned Index; + llvm::Triple *TargetBE = nullptr; - if (A->getOption().matches(options::OPT_Xsycl_backend_EQ)) + auto GetTripleIt = [&, this](llvm::StringRef Triple) { + llvm::Triple TargetTriple{Triple}; + auto TripleIt = llvm::find_if(SYCLTripleList, [&](auto &SYCLTriple) { + return SYCLTriple == TargetTriple; + }); + return TripleIt != SYCLTripleList.end() ? &*TripleIt : nullptr; + }; + + if (A->getOption().matches(options::OPT_Xsycl_backend_EQ)) { + TargetBE = GetTripleIt(A->getValue(0)); // Passing device args: -Xsycl-target-backend= -opt=val. - if (llvm::Triple(A->getValue(0)).isNVPTX()) + if (TargetBE) Index = Args.getBaseArgs().MakeIndex(A->getValue(1)); else continue; - else if (A->getOption().matches(options::OPT_Xsycl_backend)) + } else if (A->getOption().matches(options::OPT_Xsycl_backend)) { + if (SYCLTripleList.size() > 1) { + C.getDriver().Diag(diag::err_drv_Xsycl_target_missing_triple) + << A->getSpelling(); + continue; + } // Passing device args: -Xsycl-target-backend -opt=val. + TargetBE = &SYCLTripleList.front(); Index = Args.getBaseArgs().MakeIndex(A->getValue(0)); - else + } else continue; A->claim(); auto ParsedArg = Opts.ParseOneArg(Args, Index); + // TODO: Support --no-cuda-gpu-arch, --{,no-}cuda-gpu-arch=all. if (ParsedArg && ParsedArg->getOption().matches(options::OPT_offload_arch_EQ)) { + llvm::StringRef ArchStr = ParsedArg->getValue(0); + if (TargetBE->isNVPTX()) { + // CUDA arch also applies to AMDGCN ... + CudaArch Arch = StringToCudaArch(ArchStr); + if (Arch == CudaArch::UNKNOWN || !IsNVIDIAGpuArch(Arch)) { + C.getDriver().Diag(clang::diag::err_drv_cuda_bad_gpu_arch) + << ArchStr; + continue; + } + ArchStr = CudaArchToString(Arch); + } else if (TargetBE->isAMDGCN()) { + llvm::StringMap Features; + auto Arch = + parseTargetID(getHIPOffloadTargetTriple(), ArchStr, &Features); + if (!Arch) { + C.getDriver().Diag(clang::diag::err_drv_bad_target_id) << ArchStr; + continue; + } + auto CanId = getCanonicalTargetID(Arch.getValue(), Features); + ArchStr = Args.MakeArgStringRef(CanId); + } ParsedArg->claim(); - GpuArchList.push_back(StringToCudaArch(ParsedArg->getValue(0))); + GpuArchList.emplace_back(*TargetBE, ArchStr); } } - // If there are no CUDA architectures provided then default to SM_50. - if (GpuArchList.empty()) { - GpuArchList.push_back(CudaArch::SM_50); + // Handle defaults architectures + for (auto &Triple : SYCLTripleList) { + // For NVIDIA use SM_50 as a default + if (Triple.isNVPTX() && llvm::none_of(GpuArchList, [&](auto &P) { + return P.first.isNVPTX(); + })) { + llvm::StringRef DefaultArch = CudaArchToString(CudaArch::SM_50); + GpuArchList.emplace_back(Triple, DefaultArch); + } + + // For AMD require the architecture to be set by the user + if (Triple.isAMDGCN() && llvm::none_of(GpuArchList, [&](auto &P) { + return P.first.isAMDGCN(); + })) { + C.getDriver().Diag( + clang::diag::err_drv_sycl_missing_amdgpu_arch); + continue; + } } return false; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 07927a190e977..3154e9316d041 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1174,8 +1174,9 @@ llvm::opt::DerivedArgList *ToolChain::TranslateOffloadTargetArgs( // at all, target and host share a toolchain. if (A->getOption().matches(options::OPT_m_Group)) { // AMD GPU is a special case, as -mcpu is required for the device - // compilation. - if (SameTripleAsHost || getTriple().getArch() == llvm::Triple::amdgcn) + // compilation, except for SYCL which uses --offload-arch. + if (SameTripleAsHost || (getTriple().getArch() == llvm::Triple::amdgcn && + DeviceOffloadKind != Action::OFK_SYCL)) DAL->append(A); else Modified = true; diff --git a/sycl/doc/GetStartedGuide.md b/sycl/doc/GetStartedGuide.md index 8eb54324c770e..70d91b96c5cbd 100644 --- a/sycl/doc/GetStartedGuide.md +++ b/sycl/doc/GetStartedGuide.md @@ -547,11 +547,14 @@ clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda-sycldevice \ simple-sycl-app.cpp -o simple-sycl-app-cuda.exe ``` -When building for ROCm, please note that the option `mcpu` must be specified, use the ROCm target triple as follows: +When building for ROCm, use the ROCm target triple and specify the +target architecture with `-Xsycl-target-backend --offload-arch=` +as follows: ```bash clang++ -fsycl -fsycl-targets=amdgcn-amd-amdhsa-sycldevice \ - -mcpu=gfx906 simple-sycl-app.cpp -o simple-sycl-app-cuda.exe + -Xsycl-target-backend --offload-arch=gfx906 \ + simple-sycl-app.cpp -o simple-sycl-app-amd.exe ``` To build simple-sycl-app ahead of time for GPU, CPU or Accelerator devices, From 669c331110561f1cbb56d2c914125fefb1cc75aa Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Tue, 3 Aug 2021 17:26:43 +0100 Subject: [PATCH 2/8] Update clang/lib/Driver/Driver.cpp Co-authored-by: Artem Gindinson --- clang/lib/Driver/Driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index b2257adea06ff..221f9b80f0e2d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3960,7 +3960,7 @@ class OffloadingActionBuilder final { /// List of static archives to extract FPGA dependency info from ActionList FPGAArchiveInputs; - /// List of CUDA architectures to use in this compilation with NVPTX targets. + /// List of GPU architectures to use in this compilation with NVPTX/AMDGCN targets. SmallVector, 8> GpuArchList; /// Build the last steps for CUDA after all BC files have been linked. From 1edd3a500101be6be58e845a1b69d3e0b7f7a8cb Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Tue, 3 Aug 2021 17:34:03 +0100 Subject: [PATCH 3/8] [SYCL][ROCm] Fix formatting --- clang/lib/Driver/Driver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 221f9b80f0e2d..b27cf954dbffe 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3960,7 +3960,8 @@ class OffloadingActionBuilder final { /// List of static archives to extract FPGA dependency info from ActionList FPGAArchiveInputs; - /// List of GPU architectures to use in this compilation with NVPTX/AMDGCN targets. + /// List of GPU architectures to use in this compilation with NVPTX/AMDGCN + /// targets. SmallVector, 8> GpuArchList; /// Build the last steps for CUDA after all BC files have been linked. @@ -4730,8 +4731,7 @@ class OffloadingActionBuilder final { if (Triple.isAMDGCN() && llvm::none_of(GpuArchList, [&](auto &P) { return P.first.isAMDGCN(); })) { - C.getDriver().Diag( - clang::diag::err_drv_sycl_missing_amdgpu_arch); + C.getDriver().Diag(clang::diag::err_drv_sycl_missing_amdgpu_arch); continue; } } From 40bd9dfd101d847aabed8fbf370b1d4d759bbe8d Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Tue, 3 Aug 2021 17:34:26 +0100 Subject: [PATCH 4/8] [SYCL][ROCm] Update AMD SYCL offloading test --- clang/test/Driver/sycl-offload-amdgcn.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/test/Driver/sycl-offload-amdgcn.cpp b/clang/test/Driver/sycl-offload-amdgcn.cpp index ca7ff0474fda6..66213978b1dd5 100644 --- a/clang/test/Driver/sycl-offload-amdgcn.cpp +++ b/clang/test/Driver/sycl-offload-amdgcn.cpp @@ -5,16 +5,16 @@ /// Check action graph. // RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \ -// RUN: -fsycl-targets=amdgcn-amd-amdhsa-sycldevice -mcpu=gfx906 \ +// RUN: -fsycl-targets=amdgcn-amd-amdhsa-sycldevice -Xsycl-target-backend --offload-arch=gfx906 \ // RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/libspirv.bc %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-ACTIONS %s // CHK-ACTIONS: "-cc1" "-triple" "amdgcn-amd-amdhsa-sycldevice" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.bc"{{.*}} "-target-cpu" "gfx906"{{.*}} "-std=c++11"{{.*}} // CHK-ACTIONS-NOT: "-mllvm -sycl-opt" -// CHK-ACTIONS: clang-offload-wrapper"{{.*}} "-host=x86_64-unknown-linux-gnu" "-target=amdgcn" "-kind=sycl"{{.*}} +// CHK-ACTIONS: clang-offload-wrapper"{{.*}} "-host=x86_64-unknown-linux-gnu" "-compile-opts=--offload-arch=gfx906" "-target=amdgcn" "-kind=sycl"{{.*}} /// Check phases w/out specifying a compute capability. // RUN: %clangxx -ccc-print-phases -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \ -// RUN: -fsycl-targets=amdgcn-amd-amdhsa-sycldevice -mcpu=gfx906 %s 2>&1 \ +// RUN: -fsycl-targets=amdgcn-amd-amdhsa-sycldevice -Xsycl-target-backend --offload-arch=gfx906 %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASES-NO-CC %s // CHK-PHASES-NO-CC: 0: input, "{{.*}}", c++, (host-sycl) // CHK-PHASES-NO-CC: 1: append-footer, {0}, c++, (host-sycl) From ed8b330c293d02f512ffa1283943d76754350fca Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Wed, 4 Aug 2021 11:05:02 +0100 Subject: [PATCH 5/8] [SYCL][ROCm] Add test for missing arch diagnostic --- clang/lib/Driver/Driver.cpp | 2 +- clang/test/Driver/sycl-offload-amdgcn.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index b27cf954dbffe..98d961fea0b65 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4732,7 +4732,7 @@ class OffloadingActionBuilder final { return P.first.isAMDGCN(); })) { C.getDriver().Diag(clang::diag::err_drv_sycl_missing_amdgpu_arch); - continue; + return true; } } diff --git a/clang/test/Driver/sycl-offload-amdgcn.cpp b/clang/test/Driver/sycl-offload-amdgcn.cpp index 66213978b1dd5..ff869ce73ac5a 100644 --- a/clang/test/Driver/sycl-offload-amdgcn.cpp +++ b/clang/test/Driver/sycl-offload-amdgcn.cpp @@ -3,6 +3,12 @@ // UNSUPPORTED: system-windows +// Check that the offload arch is required +// RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \ +// RUN: -fsycl-targets=amdgcn-amd-amdhsa-sycldevice %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-ARCH %s +// CHK-ARCH: error: Missing AMDGPU architecture for SYCL offloading. Please specify it with -Xsycl-target-backend --offload-arch. + /// Check action graph. // RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \ // RUN: -fsycl-targets=amdgcn-amd-amdhsa-sycldevice -Xsycl-target-backend --offload-arch=gfx906 \ From 0a01af1cc936d6f9de6c4b561a35c1e59b91b956 Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Wed, 4 Aug 2021 11:12:00 +0100 Subject: [PATCH 6/8] [SYCL][ROCm] Add AMD architectures to clang tests --- clang/test/Driver/sycl-offload-amdgcn.cpp | 30 ++++++++++----------- clang/test/Driver/sycl-triple-dae-flags.cpp | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/clang/test/Driver/sycl-offload-amdgcn.cpp b/clang/test/Driver/sycl-offload-amdgcn.cpp index ff869ce73ac5a..a7c9cac88343e 100644 --- a/clang/test/Driver/sycl-offload-amdgcn.cpp +++ b/clang/test/Driver/sycl-offload-amdgcn.cpp @@ -25,22 +25,22 @@ // CHK-PHASES-NO-CC: 0: input, "{{.*}}", c++, (host-sycl) // CHK-PHASES-NO-CC: 1: append-footer, {0}, c++, (host-sycl) // CHK-PHASES-NO-CC: 2: preprocessor, {1}, c++-cpp-output, (host-sycl) -// CHK-PHASES-NO-CC: 3: input, "{{.*}}", c++, (device-sycl) -// CHK-PHASES-NO-CC: 4: preprocessor, {3}, c++-cpp-output, (device-sycl) -// CHK-PHASES-NO-CC: 5: compiler, {4}, ir, (device-sycl) -// CHK-PHASES-NO-CC: 6: offload, "host-sycl (x86_64-unknown-linux-gnu)" {2}, "device-sycl (amdgcn-amd-amdhsa-sycldevice)" {5}, c++-cpp-output +// CHK-PHASES-NO-CC: 3: input, "{{.*}}", c++, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 4: preprocessor, {3}, c++-cpp-output, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 5: compiler, {4}, ir, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 6: offload, "host-sycl (x86_64-unknown-linux-gnu)" {2}, "device-sycl (amdgcn-amd-amdhsa-sycldevice:gfx906)" {5}, c++-cpp-output // CHK-PHASES-NO-CC: 7: compiler, {6}, ir, (host-sycl) // CHK-PHASES-NO-CC: 8: backend, {7}, assembler, (host-sycl) // CHK-PHASES-NO-CC: 9: assembler, {8}, object, (host-sycl) // CHK-PHASES-NO-CC: 10: linker, {9}, image, (host-sycl) -// CHK-PHASES-NO-CC: 11: linker, {5}, ir, (device-sycl) -// CHK-PHASES-NO-CC: 12: sycl-post-link, {11}, ir, (device-sycl) -// CHK-PHASES-NO-CC: 13: file-table-tform, {12}, ir, (device-sycl) -// CHK-PHASES-NO-CC: 14: backend, {13}, assembler, (device-sycl) -// CHK-PHASES-NO-CC: 15: assembler, {14}, object, (device-sycl) -// CHK-PHASES-NO-CC: 16: linker, {15}, image, (device-sycl) -// CHK-PHASES-NO-CC: 17: linker, {16}, hip-fatbin, (device-sycl) -// CHK-PHASES-NO-CC: 18: foreach, {13, 17}, hip-fatbin, (device-sycl) -// CHK-PHASES-NO-CC: 19: file-table-tform, {12, 18}, tempfiletable, (device-sycl) -// CHK-PHASES-NO-CC: 20: clang-offload-wrapper, {19}, object, (device-sycl) -// CHK-PHASES-NO-CC: 21: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (amdgcn-amd-amdhsa-sycldevice)" {20}, image +// CHK-PHASES-NO-CC: 11: linker, {5}, ir, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 12: sycl-post-link, {11}, ir, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 13: file-table-tform, {12}, ir, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 14: backend, {13}, assembler, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 15: assembler, {14}, object, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 16: linker, {15}, image, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 17: linker, {16}, hip-fatbin, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 18: foreach, {13, 17}, hip-fatbin, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 19: file-table-tform, {12, 18}, tempfiletable, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 20: clang-offload-wrapper, {19}, object, (device-sycl, gfx906) +// CHK-PHASES-NO-CC: 21: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (amdgcn-amd-amdhsa-sycldevice:gfx906)" {20}, image diff --git a/clang/test/Driver/sycl-triple-dae-flags.cpp b/clang/test/Driver/sycl-triple-dae-flags.cpp index 89f4f06c1b317..920e6dfb020a7 100644 --- a/clang/test/Driver/sycl-triple-dae-flags.cpp +++ b/clang/test/Driver/sycl-triple-dae-flags.cpp @@ -1,7 +1,7 @@ // RUN: %clangxx -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda-sycldevice -fsycl-dead-args-optimization %s 2> %t.cuda.out // RUN: FileCheck %s --input-file %t.cuda.out // -// RUN: %clangxx -### -fsycl -fsycl-targets=amdgcn-amd-amdhsa-sycldevice -fsycl-dead-args-optimization %s 2> %t.rocm.out +// RUN: %clangxx -### -fsycl -fsycl-targets=amdgcn-amd-amdhsa-sycldevice -Xsycl-target-backend --offload-arch=gfx906 -fsycl-dead-args-optimization %s 2> %t.rocm.out // RUN: FileCheck %s --input-file %t.rocm.out // CHECK-NOT: -fenable-sycl-dae // CHECK-NOT: -emit-param-info From 733102954112a34cfd1ef4343a464084e9584d99 Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Wed, 4 Aug 2021 14:47:43 +0100 Subject: [PATCH 7/8] [SYCL][ROCm] Fix missing arch diagnostic formatting --- clang/include/clang/Basic/DiagnosticDriverKinds.td | 2 +- clang/test/Driver/sycl-offload-amdgcn.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 798b7021a4cc0..7617ee6051908 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -290,7 +290,7 @@ def err_drv_expecting_fsycl_with_sycl_opt : Error< def err_drv_fsycl_with_c_type : Error< "'%0' must not be used in conjunction with '-fsycl', which expects C++ source">; def err_drv_sycl_missing_amdgpu_arch : Error< - "Missing AMDGPU architecture for SYCL offloading. Please specify it with -Xsycl-target-backend --offload-arch.">; + "missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend --offload-arch'">; def warn_drv_sycl_offload_target_duplicate : Warning< "SYCL offloading target '%0' is similar to target '%1' already specified; " "will be ignored">, InGroup; diff --git a/clang/test/Driver/sycl-offload-amdgcn.cpp b/clang/test/Driver/sycl-offload-amdgcn.cpp index a7c9cac88343e..46ee36bbff8c8 100644 --- a/clang/test/Driver/sycl-offload-amdgcn.cpp +++ b/clang/test/Driver/sycl-offload-amdgcn.cpp @@ -7,7 +7,7 @@ // RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \ // RUN: -fsycl-targets=amdgcn-amd-amdhsa-sycldevice %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-ARCH %s -// CHK-ARCH: error: Missing AMDGPU architecture for SYCL offloading. Please specify it with -Xsycl-target-backend --offload-arch. +// CHK-ARCH: error: missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend --offload-arch' /// Check action graph. // RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \ From fad9c908e74af33d4b7eb0a898102c866ea0e48e Mon Sep 17 00:00:00 2001 From: Nicolas Miller Date: Fri, 6 Aug 2021 17:55:20 +0100 Subject: [PATCH 8/8] Update clang/lib/Driver/Driver.cpp Co-authored-by: Victor Lomuller --- clang/lib/Driver/Driver.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 98d961fea0b65..f45a48c34ffe4 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4650,8 +4650,9 @@ class OffloadingActionBuilder final { /// Initialize the GPU architecture list from arguments - this populates /// `GpuArchList` from `--offload-arch` flags. Only relevant if compiling to /// CUDA or AMDGCN. Return true if any initialization errors are found. - /// FIXME: SPIR-V AOT targets should also use `offload-arch` to better fit - /// in the standard model. + /// FIXME: "offload-arch" and the BoundArch mechanism should also be + // used in the SYCLToolChain for SPIR-V AOT to track the offload + // architecture instead of the Triple sub-arch it currently uses. bool initializeGpuArchMap() { const OptTable &Opts = C.getDriver().getOpts(); for (auto *A : Args) {