-
Notifications
You must be signed in to change notification settings - Fork 738
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
[SYCL]Fix SYCL target triple check for NVidia targets. #14505
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -806,24 +806,28 @@ Driver::OpenMPRuntimeKind Driver::getOpenMPRuntime(const ArgList &Args) const { | |
return RT; | ||
} | ||
|
||
static bool isValidSYCLTriple(llvm::Triple T) { | ||
// NVPTX is valid for SYCL. | ||
if (T.isNVPTX()) | ||
static bool isValidSYCLTriple(llvm::Triple TargetTriple) { | ||
// Check for invalid SYCL device triple values for NVidia GPU targets. | ||
// nvptx64-nvidia-cuda is the valid triple for NVidia targets. | ||
if (TargetTriple.getArchTypeName(TargetTriple.getArch()) == "nvptx64" && | ||
TargetTriple.getVendorTypeName(TargetTriple.getVendor()) == "nvidia" && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once again, I would prefer to avoid string comparison. |
||
TargetTriple.getOSTypeName(TargetTriple.getOS()) == "cuda" && | ||
!TargetTriple.hasEnvironment()) | ||
return true; | ||
|
||
// AMDGCN is valid for SYCL | ||
if (T.isAMDGCN()) | ||
if (TargetTriple.isAMDGCN()) | ||
return true; | ||
|
||
// Check for invalid SYCL device triple values. | ||
// Non-SPIR/SPIRV arch. | ||
if (!T.isSPIROrSPIRV()) | ||
if (!TargetTriple.isSPIROrSPIRV()) | ||
return false; | ||
// SPIR/SPIRV arch, but has invalid SubArch for AOT. | ||
StringRef A(T.getArchName()); | ||
if (T.getSubArch() == llvm::Triple::NoSubArch && | ||
((T.getArch() == llvm::Triple::spir && A != "spir") || | ||
(T.getArch() == llvm::Triple::spir64 && A != "spir64"))) | ||
StringRef A(TargetTriple.getArchName()); | ||
if (TargetTriple.getSubArch() == llvm::Triple::NoSubArch && | ||
((TargetTriple.getArch() == llvm::Triple::spir && A != "spir") || | ||
(TargetTriple.getArch() == llvm::Triple::spir64 && A != "spir64"))) | ||
return false; | ||
return true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,49 +649,49 @@ static Triple::VendorType parseVendor(StringRef VendorName) { | |
|
||
static Triple::OSType parseOS(StringRef OSName) { | ||
return StringSwitch<Triple::OSType>(OSName) | ||
.StartsWith("darwin", Triple::Darwin) | ||
.StartsWith("dragonfly", Triple::DragonFly) | ||
.StartsWith("freebsd", Triple::FreeBSD) | ||
.StartsWith("fuchsia", Triple::Fuchsia) | ||
.StartsWith("ios", Triple::IOS) | ||
.StartsWith("kfreebsd", Triple::KFreeBSD) | ||
.StartsWith("linux", Triple::Linux) | ||
.StartsWith("lv2", Triple::Lv2) | ||
.StartsWith("macos", Triple::MacOSX) | ||
.StartsWith("netbsd", Triple::NetBSD) | ||
.StartsWith("openbsd", Triple::OpenBSD) | ||
.StartsWith("solaris", Triple::Solaris) | ||
.StartsWith("uefi", Triple::UEFI) | ||
.StartsWith("win32", Triple::Win32) | ||
.StartsWith("windows", Triple::Win32) | ||
.StartsWith("zos", Triple::ZOS) | ||
.StartsWith("haiku", Triple::Haiku) | ||
.StartsWith("rtems", Triple::RTEMS) | ||
.StartsWith("nacl", Triple::NaCl) | ||
.StartsWith("aix", Triple::AIX) | ||
.StartsWith("cuda", Triple::CUDA) | ||
.StartsWith("nvcl", Triple::NVCL) | ||
.StartsWith("amdhsa", Triple::AMDHSA) | ||
.StartsWith("ps4", Triple::PS4) | ||
.StartsWith("ps5", Triple::PS5) | ||
.StartsWith("elfiamcu", Triple::ELFIAMCU) | ||
.StartsWith("tvos", Triple::TvOS) | ||
.StartsWith("watchos", Triple::WatchOS) | ||
.StartsWith("bridgeos", Triple::BridgeOS) | ||
.StartsWith("driverkit", Triple::DriverKit) | ||
.StartsWith("xros", Triple::XROS) | ||
.StartsWith("visionos", Triple::XROS) | ||
.StartsWith("mesa3d", Triple::Mesa3D) | ||
.StartsWith("amdpal", Triple::AMDPAL) | ||
.StartsWith("hermit", Triple::HermitCore) | ||
.StartsWith("hurd", Triple::Hurd) | ||
.StartsWith("wasi", Triple::WASI) | ||
.StartsWith("emscripten", Triple::Emscripten) | ||
.StartsWith("shadermodel", Triple::ShaderModel) | ||
.StartsWith("liteos", Triple::LiteOS) | ||
.StartsWith("serenity", Triple::Serenity) | ||
.StartsWith("vulkan", Triple::Vulkan) | ||
.Default(Triple::UnknownOS); | ||
.StartsWith("darwin", Triple::Darwin) | ||
.StartsWith("dragonfly", Triple::DragonFly) | ||
.StartsWith("freebsd", Triple::FreeBSD) | ||
.StartsWith("fuchsia", Triple::Fuchsia) | ||
.StartsWith("ios", Triple::IOS) | ||
.StartsWith("kfreebsd", Triple::KFreeBSD) | ||
.StartsWith("linux", Triple::Linux) | ||
.StartsWith("lv2", Triple::Lv2) | ||
.StartsWith("macos", Triple::MacOSX) | ||
.StartsWith("netbsd", Triple::NetBSD) | ||
.StartsWith("openbsd", Triple::OpenBSD) | ||
.StartsWith("solaris", Triple::Solaris) | ||
.StartsWith("uefi", Triple::UEFI) | ||
.StartsWith("win32", Triple::Win32) | ||
.StartsWith("windows", Triple::Win32) | ||
.StartsWith("zos", Triple::ZOS) | ||
.StartsWith("haiku", Triple::Haiku) | ||
.StartsWith("rtems", Triple::RTEMS) | ||
.StartsWith("nacl", Triple::NaCl) | ||
.StartsWith("aix", Triple::AIX) | ||
.Case("cuda", Triple::CUDA) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm hesitant to accept this change at intel/llvm. If you can get this accepted to the upstream LLVM, then it is fine. This change is at least inconsistent with handling of other OSes. For example, My main concern is that no one prohibits using other things from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, when we pass an invalid target triple value to
This error is non-intuitive and does not clearly describe what the problem is. Currently, in the driver code base, there is no check to verify if the target triple string passed matches the exact value documented - nvptx64-nvidia-cuda For OpenMP, they do allow partial/shortened triple strings with empty Vendor or/and OS components. The following triples are all valid. Please see this function As for this change: I can remove the string comparisons as parseArch() , parseVendor() and parseOS() all use .Case match for Nvidia targets. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the best we can do is check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree, but I still don't think that the suggested customization is right in context of deviation from the community code, further maintenance effort and potential unexpected/unwanted side effects.
We should adopt this in |
||
.StartsWith("nvcl", Triple::NVCL) | ||
.StartsWith("amdhsa", Triple::AMDHSA) | ||
.StartsWith("ps4", Triple::PS4) | ||
.StartsWith("ps5", Triple::PS5) | ||
.StartsWith("elfiamcu", Triple::ELFIAMCU) | ||
.StartsWith("tvos", Triple::TvOS) | ||
.StartsWith("watchos", Triple::WatchOS) | ||
.StartsWith("bridgeos", Triple::BridgeOS) | ||
.StartsWith("driverkit", Triple::DriverKit) | ||
.StartsWith("xros", Triple::XROS) | ||
.StartsWith("visionos", Triple::XROS) | ||
.StartsWith("mesa3d", Triple::Mesa3D) | ||
.StartsWith("amdpal", Triple::AMDPAL) | ||
.StartsWith("hermit", Triple::HermitCore) | ||
.StartsWith("hurd", Triple::Hurd) | ||
.StartsWith("wasi", Triple::WASI) | ||
.StartsWith("emscripten", Triple::Emscripten) | ||
.StartsWith("shadermodel", Triple::ShaderModel) | ||
.StartsWith("liteos", Triple::LiteOS) | ||
.StartsWith("serenity", Triple::Serenity) | ||
.StartsWith("vulkan", Triple::Vulkan) | ||
.Default(Triple::UnknownOS); | ||
} | ||
|
||
static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to do string comparisons?