Skip to content

[Driver][SYCL] Fix issue with using deprecated sycldevice triple #6877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1108,14 +1108,13 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
UserTargetName = "spir64_gen";
}

llvm::Triple TT(MakeSYCLDeviceTriple(Val));
if (!isValidSYCLTriple(MakeSYCLDeviceTriple(UserTargetName))) {
Diag(clang::diag::err_drv_invalid_sycl_target) << Val;
continue;
}
std::string NormalizedName = TT.normalize();

// Make sure we don't have a duplicate triple.
std::string NormalizedName = MakeSYCLDeviceTriple(Val).normalize();
auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
if (Duplicate != FoundNormalizedTriples.end()) {
Diag(clang::diag::warn_drv_sycl_offload_target_duplicate)
Expand All @@ -1124,6 +1123,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
}

// Warn about deprecated `sycldevice` environment component.
llvm::Triple TT(MakeSYCLDeviceTriple(UserTargetName));
if (TT.getEnvironmentName() == "sycldevice") {
// Build a string with suggested target triple.
std::string SuggestedTriple = TT.getArchName().str();
Expand All @@ -1147,7 +1147,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
// Store the current triple so that we can check for duplicates in
// the following iterations.
FoundNormalizedTriples[NormalizedName] = Val;
UniqueSYCLTriplesVec.push_back(MakeSYCLDeviceTriple(UserTargetName));
UniqueSYCLTriplesVec.push_back(TT);
}
addSYCLDefaultTriple(C, UniqueSYCLTriplesVec);
} else
Expand Down
4 changes: 3 additions & 1 deletion clang/test/Driver/sycl.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
// DISABLED-NOT: "-sycl-std={{.*}}"
// DISABLED-NOT: "-fsycl-std-layout-kernel-params"

// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice,nvptx64-nvidia-cuda-sycldevice -fno-sycl-libspirv -nocudalib -c %s 2>&1 | FileCheck %s --check-prefix=CHECK_WARNING
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice,nvptx64-nvidia-cuda-sycldevice -fno-sycl-libspirv -nocudalib -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK_WARNING
// CHECK_WARNING: argument 'spir64-unknown-unknown-sycldevice' is deprecated, use 'spir64' instead
// CHECK_WARNING: argument 'nvptx64-nvidia-cuda-sycldevice' is deprecated, use 'nvptx64-nvidia-cuda' instead
// CHECK_WARNING: clang{{.*}} "-triple" "spir64-unknown-unknown"
// CHECK_WARNING: clang{{.*}} "-triple" "nvptx64-nvidia-cuda"

// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl-device-only -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT -DSPIRARCH=spir64
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT -DSPIRARCH=spir64
Expand Down