[OpenCL] Disable __opencl_c_ext_fp64_* features if cl_khr_fp64 is not supported (#169252)
Fix kernel build when cl_khr_fp64 is not enabled: opencl-c.h:13785:50: error: unknown type name 'atomic_double' 13785 | double __ovld atomic_fetch_min(volatile __global atomic_double *, double); opencl-c.h:13785:67: error: use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support 13785 | double __ovld atomic_fetch_min(volatile __global atomic_double *, double); This is a regression introduced by 423bdb2b. Before that commit, __opencl_c_ext_fp64_global_atomic_add was guarded by cl_khr_fp64 in opencl-c-base.h.
This commit is contained in:
parent
a8a504a08d
commit
25dee656c7
@ -1848,6 +1848,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/// Set features that depend on other features.
|
||||
virtual void setDependentOpenCLOpts();
|
||||
|
||||
/// Get supported OpenCL extensions and optional core features.
|
||||
llvm::StringMap<bool> &getSupportedOpenCLOpts() {
|
||||
return getTargetOpts().OpenCLFeaturesMap;
|
||||
|
||||
@ -640,6 +640,17 @@ bool TargetInfo::areDefaultedSMFStillPOD(const LangOptions &LangOpts) const {
|
||||
return LangOpts.getClangABICompat() > LangOptions::ClangABI::Ver15;
|
||||
}
|
||||
|
||||
void TargetInfo::setDependentOpenCLOpts() {
|
||||
auto &Opts = getSupportedOpenCLOpts();
|
||||
if (!hasFeatureEnabled(Opts, "cl_khr_fp64") ||
|
||||
!hasFeatureEnabled(Opts, "__opencl_c_fp64")) {
|
||||
setFeatureEnabled(Opts, "__opencl_c_ext_fp64_global_atomic_add", false);
|
||||
setFeatureEnabled(Opts, "__opencl_c_ext_fp64_local_atomic_add", false);
|
||||
setFeatureEnabled(Opts, "__opencl_c_ext_fp64_global_atomic_min_max", false);
|
||||
setFeatureEnabled(Opts, "__opencl_c_ext_fp64_local_atomic_min_max", false);
|
||||
}
|
||||
}
|
||||
|
||||
LangAS TargetInfo::getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const {
|
||||
switch (TK) {
|
||||
case OCLTK_Image:
|
||||
|
||||
@ -862,6 +862,7 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
|
||||
|
||||
Target->setSupportedOpenCLOpts();
|
||||
Target->setCommandLineOpenCLOpts();
|
||||
Target->setDependentOpenCLOpts();
|
||||
Target->setMaxAtomicWidth();
|
||||
|
||||
if (!Opts->DarwinTargetVariantTriple.empty())
|
||||
|
||||
17
clang/test/Misc/opencl-c-3.0.incorrect_define.cl
Normal file
17
clang/test/Misc/opencl-c-3.0.incorrect_define.cl
Normal file
@ -0,0 +1,17 @@
|
||||
// RUN: %clang_cc1 -verify -triple spir-unknown-unknown -cl-std=CL3.0 -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 %s
|
||||
// RUN: %clang_cc1 -verify -triple spir-unknown-unknown -cl-std=clc++2021 -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 %s
|
||||
|
||||
#if __opencl_c_ext_fp64_global_atomic_add != 0
|
||||
#error "Incorrectly defined __opencl_c_ext_fp64_global_atomic_add"
|
||||
#endif
|
||||
#if __opencl_c_ext_fp64_local_atomic_add != 0
|
||||
#error "Incorrectly defined __opencl_c_ext_fp64_local_atomic_add"
|
||||
#endif
|
||||
#if __opencl_c_ext_fp64_global_atomic_min_max != 0
|
||||
#error "Incorrectly defined __opencl_c_ext_fp64_global_atomic_min_max"
|
||||
#endif
|
||||
#if __opencl_c_ext_fp64_local_atomic_min_max != 0
|
||||
#error "Incorrectly defined __opencl_c_ext_fp64_local_atomic_min_max"
|
||||
#endif
|
||||
|
||||
// expected-no-diagnostics
|
||||
Loading…
x
Reference in New Issue
Block a user