diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e051f2ba5468a..a4da7bd9b1604 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1022,7 +1022,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, for (const auto &TripleAndArchs : DerivedArchs) OpenMPTriples.insert(TripleAndArchs.first()); - } // end of offload-arch + } for (StringRef Val : OpenMPTriples) { llvm::Triple TT(ToolChain::getOpenMPTriple(Val)); @@ -1337,13 +1337,13 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, } else if (IsIntelGPUOffloadArch(StringToOffloadArchIntel(Arch))) { DerivedArchs["spir64_gen"].insert(Arch); } else { - Diag(clang::diag::err_drv_failed_to_deduce_target_from_arch) << Arch; + Diag(clang::diag::err_drv_invalid_sycl_target) << Arch; return; } } // If the set is empty then we failed to find a native architecture. if (Archs.empty()) { - Diag(clang::diag::err_drv_failed_to_deduce_target_from_arch) << "native"; + Diag(clang::diag::err_drv_invalid_sycl_target) << "native"; return; } @@ -1351,13 +1351,13 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, SYCLTriples.insert(TripleAndArchs.first()); for (const auto &Val : SYCLTriples) { - llvm::Triple TT(MakeSYCLDeviceTriple(Val.getKey())); - std::string NormalizedName = TT.normalize(); + llvm::Triple SYCLTargetTriple(MakeSYCLDeviceTriple(Val.getKey())); + std::string NormalizedName = SYCLTargetTriple.normalize(); // Make sure we don't have a duplicate triple. auto Duplicate = FoundNormalizedTriples.find(NormalizedName); if (Duplicate != FoundNormalizedTriples.end()) { - Diag(clang::diag::warn_drv_omp_offload_target_duplicate) + Diag(clang::diag::warn_drv_sycl_offload_target_duplicate) << Val.getKey() << Duplicate->second; continue; } @@ -1365,19 +1365,12 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // Store the current triple so that we can check for duplicates in the // following iterations. FoundNormalizedTriples[NormalizedName] = Val.getKey(); - } - - if (!SYCLTriples.empty()) { - for (const auto &SYCLTriple : SYCLTriples) { - llvm::Triple Triple(MakeSYCLDeviceTriple(SYCLTriple.getKey())); - UniqueSYCLTriplesVec.push_back(Triple); - } + UniqueSYCLTriplesVec.push_back(SYCLTargetTriple); } addSYCLDefaultTriple(C, UniqueSYCLTriplesVec); - } // end of --offload-arch - else { + } else { // If -fsycl is supplied without -fsycl-targets we will assume SPIR-V. // For -fsycl-device-only, we also setup the implied triple as needed. if (HasValidSYCLRuntime) { diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index fbd5a78fbe90f..25cd8d67ac4af 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -33,12 +33,63 @@ struct StringToOffloadArchIntelMap { }; static const StringToOffloadArchIntelMap StringToArchNamesMap[] = { + {"skylake-avx512", OffloadArchIntel::SKYLAKEAVX512}, + {"core-avx2", OffloadArchIntel::COREAVX2}, + {"corei7-avx", OffloadArchIntel::COREI7AVX}, + {"corei7", OffloadArchIntel::COREI7}, + {"westmere", OffloadArchIntel::WESTMERE}, + {"sandybridge", OffloadArchIntel::SANDYBRIDGE}, + {"ivybridge", OffloadArchIntel::IVYBRIDGE}, {"broadwell", OffloadArchIntel::BROADWELL}, {"coffeelake", OffloadArchIntel::COFFEELAKE}, + {"alderlake", OffloadArchIntel::ALDERLAKE}, + {"skylake", OffloadArchIntel::SKYLAKE}, + {"skx", OffloadArchIntel::SKX}, + {"cascadelake", OffloadArchIntel::CASCADELAKE}, {"icelake-client", OffloadArchIntel::ICELAKECLIENT}, + {"icelake-server", OffloadArchIntel::ICELAKESERVER}, + {"sapphirerapids", OffloadArchIntel::SAPPHIRERAPIDS}, + {"graniterapids", OffloadArchIntel::GRANITERAPIDS}, + // Intel GPU mapping. {"bdw", OffloadArchIntel::BDW}, + {"skl", OffloadArchIntel::SKL}, + {"kbl", OffloadArchIntel::KBL}, {"cfl", OffloadArchIntel::CFL}, - {"icl", OffloadArchIntel::ICL}}; + {"apl", OffloadArchIntel::APL}, + {"bxt", OffloadArchIntel::BXT}, + {"glk", OffloadArchIntel::GLK}, + {"whl", OffloadArchIntel::WHL}, + {"aml", OffloadArchIntel::AML}, + {"cml", OffloadArchIntel::CML}, + {"icllp", OffloadArchIntel::ICLLP}, + {"icl", OffloadArchIntel::ICL}, + {"ehl", OffloadArchIntel::EHL}, + {"jsl", OffloadArchIntel::JSL}, + {"tgllp", OffloadArchIntel::TGLLP}, + {"tgl", OffloadArchIntel::TGL}, + {"rkl", OffloadArchIntel::RKL}, + {"adl_s", OffloadArchIntel::ADL_S}, + {"rpl_s", OffloadArchIntel::RPL_S}, + {"adl_p", OffloadArchIntel::ADL_P}, + {"adl_n", OffloadArchIntel::ADL_N}, + {"dg1", OffloadArchIntel::DG1}, + {"acm_g10", OffloadArchIntel::ACM_G10}, + {"dg2_g10", OffloadArchIntel::DG2_G10}, + {"acm_g11", OffloadArchIntel::ACM_G11}, + {"dg2_g10", OffloadArchIntel::DG2_G10}, + {"dg2_g11", OffloadArchIntel::DG2_G11}, + {"acm_g12", OffloadArchIntel::ACM_G12}, + {"dg2_g12", OffloadArchIntel::DG2_G12}, + {"pvc", OffloadArchIntel::PVC}, + {"pvc_vg", OffloadArchIntel::PVC_VG}, + {"mtl_u", OffloadArchIntel::MTL_U}, + {"mtl_s", OffloadArchIntel::MTL_S}, + {"arl_u", OffloadArchIntel::ARL_U}, + {"arl_s", OffloadArchIntel::ARL_S}, + {"mtl_h", OffloadArchIntel::MTL_H}, + {"arl_h", OffloadArchIntel::ARL_H}, + {"bmg_g21", OffloadArchIntel::BMG_G21}, + {"lnl_m", OffloadArchIntel::LNL_M}}; OffloadArchIntel clang::driver::StringToOffloadArchIntel(llvm::StringRef ArchNameAsString) { diff --git a/clang/lib/Driver/ToolChains/SYCL.h b/clang/lib/Driver/ToolChains/SYCL.h index 1fb23f97db65b..b8425dab95a15 100644 --- a/clang/lib/Driver/ToolChains/SYCL.h +++ b/clang/lib/Driver/ToolChains/SYCL.h @@ -64,7 +64,7 @@ enum class OffloadArchIntel { ACM_G10, DG2_G10, ACM_G11, - DG2_GLL, + DG2_G11, ACM_G12, DG2_G12, PVC, diff --git a/clang/test/Driver/sycl-offload-arch-intelgpu.cpp b/clang/test/Driver/sycl-offload-arch-intelgpu.cpp index a27d1c15c33ee..95c51f721862e 100644 --- a/clang/test/Driver/sycl-offload-arch-intelgpu.cpp +++ b/clang/test/Driver/sycl-offload-arch-intelgpu.cpp @@ -1,17 +1,73 @@ /// Tests the behaviors of using -fsycl --offload-new-driver -// --offload-arch=. +// --offload-arch=. -// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=bdw %s 2>&1 | \ -// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE,CLANG-OFFLOAD-PACKAGER -DDEV_STR=bdw -DMAC_STR=BDW +// SYCL AOT compilation to Intel CPUs using --offload-arch -// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=cfl %s 2>&1 | \ -// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE,CLANG-OFFLOAD-PACKAGER -DDEV_STR=cfl -DMAC_STR=CFL +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=broadwell %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=broadwell + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=coffeelake %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=coffeelake + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=icelake-client %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=icelake-client + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=skylake-avx512 %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=skylake-avx512 + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=core-avx2 %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=core-avx2 + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=corei7-avx %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=corei7-avx + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=corei7 %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=corei7 + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=westmere %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=westmere + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=sandybridge %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=sandybridge + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=ivybridge %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=ivybridge +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=alderlake %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=alderlake -///If Arch is icl, map it to icllp internally to create D__SYCL_TARGET_INTEL_GPU_ +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=skylake %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=skylake -// TARGET-TRIPLE: clang{{.*}} "-triple" "spir64_gen-unknown-unknown" -// TARGET-TRIPLE: "-D__SYCL_TARGET_INTEL_GPU_[[MAC_STR]]__" -// CLANG-OFFLOAD-PACKAGER: clang-offload-packager{{.*}} "--image={{.*}}triple=spir64_gen-unknown-unknown,arch=[[DEV_STR]],kind=sycl" +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=skx %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=skx + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=cascadelake %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=cascadelake + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=icelake-server %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=icelake-server + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=sapphirerapids %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=sapphirerapids + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=graniterapids %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-CPU,CLANG-OFFLOAD-PACKAGER-CPU -DDEV_STR=graniterapids + +// TARGET-TRIPLE-CPU: clang{{.*}} "-triple" "spir64_x86_64-unknown-unknown" +// TARGET-TRIPLE-CPU: "-D__SYCL_TARGET_INTEL_X86_64__" +// CLANG-OFFLOAD-PACKAGER-CPU: clang-offload-packager{{.*}} "--image={{.*}}triple=spir64_x86_64-unknown-unknown,arch=[[DEV_STR]],kind=sycl" + + +// SYCL AOT compilation to Intel GPUs using --offload-arch + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=bdw %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-GPU,CLANG-OFFLOAD-PACKAGER-GPU -DDEV_STR=bdw -DMAC_STR=BDW + +// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=cfl %s 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-GPU,CLANG-OFFLOAD-PACKAGER-GPU -DDEV_STR=cfl -DMAC_STR=CFL +// TARGET-TRIPLE-GPU: clang{{.*}} "-triple" "spir64_gen-unknown-unknown" +// TARGET-TRIPLE-GPU: "-D__SYCL_TARGET_INTEL_GPU_[[MAC_STR]]__" +// CLANG-OFFLOAD-PACKAGER-GPU: clang-offload-packager{{.*}} "--image={{.*}}triple=spir64_gen-unknown-unknown,arch=[[DEV_STR]],kind=sycl"