r232631 - OpenCL: CL2.0 atomic types
Anastasia Stulova
anastasia.stulova at arm.com
Wed Mar 18 08:06:22 PDT 2015
Investigating the fix now.
What's is the acceptable latency for repair?
-----Original Message-----
From: NAKAMURA Takumi [mailto:geek4civic at gmail.com]
Sent: 18 March 2015 14:54
To: Anastasia Stulova
Cc: cfe-commits
Subject: Re: r232631 - OpenCL: CL2.0 atomic types
The test fails for targeting 32-bit i686-* and hexagon-*
2015-03-18 21:55 GMT+09:00 Anastasia Stulova <anastasia.stulova at arm.com>:
> Author: stulova
> Date: Wed Mar 18 07:55:29 2015
> New Revision: 232631
>
> URL: http://llvm.org/viewvc/llvm-project?rev=232631&view=rev
> Log:
> OpenCL: CL2.0 atomic types
>
> OpenCL C Spec v2.0 Section 6.13.11
>
> - Made c11 _Atomic being not accepted for OpenCL
>
> - Implemented CL2.0 atomics by aliasing them to the corresponding c11
> atomic types using implicit typedef
>
> - Added diagnostics for atomics Khronos extension enabling
>
>
> Added:
> cfe/trunk/test/Parser/opencl-atomics-cl20.cl
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Basic/TokenKinds.def
> cfe/trunk/lib/Basic/IdentifierTable.cpp
> cfe/trunk/lib/Sema/Sema.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> nosticSemaKinds.td?rev=232631&r1=232630&r2=232631&view=diff
> ======================================================================
> ========
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Mar 18
> +++ 07:55:29 2015
> @@ -7124,8 +7124,8 @@ def ext_c99_array_usage : Extension< def
> err_c99_array_usage_cxx : Error<
> "%select{qualifier in |static |}0array size %select{||'[*] '}0is a C99 "
> "feature, not permitted in C++">;
> -def err_double_requires_fp64 : Error<
> - "use of type 'double' requires cl_khr_fp64 extension to be
> enabled">;
> + def err_type_requires_extension : Error< "use of type %0 requires
> + %1 extension to be enabled">;
> def err_int128_unsupported : Error<
> "__int128 is not supported on this target">; def
> err_nsconsumed_attribute_mismatch : Error<
>
> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Toke
> nKinds.def?rev=232631&r1=232630&r2=232631&view=diff
> ======================================================================
> ========
> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed Mar 18 07:55:29
> +++ 2015
> @@ -228,6 +228,7 @@ PUNCTUATOR(greatergreatergreater, ">>>")
> // KEYNOMS18 - This is a keyword that must never be enabled under
> // MSVC <= v18.
> // KEYOPENCL - This is a keyword in OpenCL
> +// KEYNOOPENCL - This is a keyword that is not supported in OpenCL
> // KEYALTIVEC - This is a keyword in AltiVec
> // KEYBORLAND - This is a keyword if Borland extensions are enabled
> // BOOLSUPPORT - This is a keyword if 'bool' is a built-in type
> @@ -270,7 +271,7 @@ KEYWORD(volatile , KE
> KEYWORD(while , KEYALL)
> KEYWORD(_Alignas , KEYALL)
> KEYWORD(_Alignof , KEYALL)
> -KEYWORD(_Atomic , KEYALL|KEYNOMS18)
> +KEYWORD(_Atomic , KEYALL|KEYNOMS18|KEYNOOPENCL)
> KEYWORD(_Bool , KEYNOCXX)
> KEYWORD(_Complex , KEYALL)
> KEYWORD(_Generic , KEYALL)
>
> Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTabl
> e.cpp?rev=232631&r1=232630&r2=232631&view=diff
> ======================================================================
> ========
> --- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
> +++ cfe/trunk/lib/Basic/IdentifierTable.cpp Wed Mar 18 07:55:29 2015
> @@ -106,9 +106,11 @@ namespace {
> KEYC11 = 0x400,
> KEYARC = 0x800,
> KEYNOMS18 = 0x01000,
> - WCHARSUPPORT = 0x02000,
> - HALFSUPPORT = 0x04000,
> - KEYALL = (0xffff & ~KEYNOMS18) // Because KEYNOMS18 is used to exclude.
> + KEYNOOPENCL = 0x02000,
> + WCHARSUPPORT = 0x04000,
> + HALFSUPPORT = 0x08000,
> + KEYALL = (0xffff & ~KEYNOMS18 &
> + ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
> };
>
> /// \brief How a keyword is treated in the selected standard.
> @@ -156,7 +158,12 @@ static void AddKeyword(StringRef Keyword
> // Don't add this keyword under MSVCCompat.
> if (LangOpts.MSVCCompat && (Flags & KEYNOMS18) &&
> !LangOpts.isCompatibleWithMSVC(19))
> - return;
> + return;
> +
> + // Don't add this keyword under OpenCL.
> + if (LangOpts.OpenCL && (Flags & KEYNOOPENCL))
> + return;
> +
> // Don't add this keyword if disabled in this language.
> if (AddResult == KS_Disabled) return;
>
>
> Modified: cfe/trunk/lib/Sema/Sema.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=23
> 2631&r1=232630&r2=232631&view=diff
> ======================================================================
> ========
> --- cfe/trunk/lib/Sema/Sema.cpp (original)
> +++ cfe/trunk/lib/Sema/Sema.cpp Wed Mar 18 07:55:29 2015
> @@ -212,6 +212,29 @@ void Sema::Initialize() {
> addImplicitTypedef("image3d_t", Context.OCLImage3dTy);
> addImplicitTypedef("sampler_t", Context.OCLSamplerTy);
> addImplicitTypedef("event_t", Context.OCLEventTy);
> + if (getLangOpts().OpenCLVersion >= 200) {
> + addImplicitTypedef("atomic_int", Context.getAtomicType(Context.IntTy));
> + addImplicitTypedef("atomic_uint",
> + Context.getAtomicType(Context.UnsignedIntTy));
> + addImplicitTypedef("atomic_long", Context.getAtomicType(Context.LongTy));
> + addImplicitTypedef("atomic_ulong",
> + Context.getAtomicType(Context.UnsignedLongTy));
> + addImplicitTypedef("atomic_float",
> + Context.getAtomicType(Context.FloatTy));
> + addImplicitTypedef("atomic_double",
> + Context.getAtomicType(Context.DoubleTy));
> + // OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as
> + // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
> + addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy));
> + addImplicitTypedef("atomic_intptr_t",
> + Context.getAtomicType(Context.getIntPtrType()));
> + addImplicitTypedef("atomic_uintptr_t",
> + Context.getAtomicType(Context.getUIntPtrType()));
> + addImplicitTypedef("atomic_size_t",
> + Context.getAtomicType(Context.getSizeType()));
> + addImplicitTypedef("atomic_ptrdiff_t",
> + Context.getAtomicType(Context.getPointerDiffType()));
> + }
> }
>
> DeclarationName BuiltinVaList =
> &Context.Idents.get("__builtin_va_list");
>
> Modified: cfe/trunk/lib/Sema/SemaType.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?re
> v=232631&r1=232630&r2=232631&view=diff
> ======================================================================
> ========
> --- cfe/trunk/lib/Sema/SemaType.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Mar 18 07:55:29 2015
> @@ -871,7 +871,8 @@ static QualType ConvertDeclSpecToType(Ty
> if (S.getLangOpts().OpenCL &&
> !((S.getLangOpts().OpenCLVersion >= 120) ||
> S.getOpenCLOptions().cl_khr_fp64)) {
> - S.Diag(DS.getTypeSpecTypeLoc(), diag::err_double_requires_fp64);
> + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
> + << Result << "cl_khr_fp64";
> declarator.setInvalidType(true);
> }
> break;
> @@ -947,6 +948,30 @@ static QualType ConvertDeclSpecToType(Ty
> << DS.getSourceRange();
> declarator.setInvalidType(true);
> }
> + } else if (S.getLangOpts().OpenCL) {
> + if (const AtomicType *AT = Result->getAs<AtomicType>()) {
> + const BuiltinType *BT = AT->getValueType()->getAs<BuiltinType>();
> + bool NoExtTypes = BT && (BT->getKind() == BuiltinType::Int ||
> + BT->getKind() == BuiltinType::UInt ||
> + BT->getKind() == BuiltinType::Float);
> + if (!S.getOpenCLOptions().cl_khr_int64_base_atomics && !NoExtTypes) {
> + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
> + << Result << "cl_khr_int64_base_atomics";
> + declarator.setInvalidType(true);
> + }
> + if (!S.getOpenCLOptions().cl_khr_int64_extended_atomics &&
> + !NoExtTypes) {
> + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
> + << Result << "cl_khr_int64_extended_atomics";
> + declarator.setInvalidType(true);
> + }
> + if (!S.getOpenCLOptions().cl_khr_fp64 && BT &&
> + BT->getKind() == BuiltinType::Double) {
> + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
> + << Result << "cl_khr_fp64";
> + declarator.setInvalidType(true);
> + }
> + }
> }
>
> // TypeQuals handled by caller.
>
> Added: cfe/trunk/test/Parser/opencl-atomics-cl20.cl
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-atomi
> cs-cl20.cl?rev=232631&view=auto
> ======================================================================
> ========
> --- cfe/trunk/test/Parser/opencl-atomics-cl20.cl (added)
> +++ cfe/trunk/test/Parser/opencl-atomics-cl20.cl Wed Mar 18 07:55:29
> +++ 2015
> @@ -0,0 +1,56 @@
> +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only // RUN:
> +%clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DCL20 // RUN:
> +%clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT
> +
> +#ifdef EXT
> +#pragma OPENCL EXTENSION cl_khr_int64_base_atomics:enable #pragma
> +OPENCL EXTENSION cl_khr_int64_extended_atomics:enable
> +#pragma OPENCL EXTENSION cl_khr_fp64:enable #endif
> +
> +void atomic_types_test() {
> +// OpenCL v2.0 s6.13.11.6 defines supported atomic types.
> + atomic_int i;
> + atomic_uint ui;
> + atomic_long l;
> + atomic_ulong ul;
> + atomic_float f;
> + atomic_double d;
> + atomic_flag fl;
> + atomic_intptr_t ip;
> + atomic_uintptr_t uip;
> + atomic_size_t s;
> + atomic_ptrdiff_t pd;
> +// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type
> +qualifier // are not supported by OpenCL.
> + _Atomic int i; // expected-error {{use of undeclared identifier
> +'_Atomic'}} } #ifndef CL20 // expected-error at -16 {{use of undeclared
> +identifier 'atomic_int'}} // expected-error at -16 {{use of undeclared
> +identifier 'atomic_uint'}} // expected-error at -16 {{use of undeclared
> +identifier 'atomic_long'}} // expected-error at -16 {{use of undeclared
> +identifier 'atomic_ulong'}} // expected-error at -16 {{use of undeclared
> +identifier 'atomic_float'}} // expected-error at -16 {{use of undeclared
> +identifier 'atomic_double'}} // expected-error at -16 {{use of
> +undeclared identifier 'atomic_flag'}} // expected-error at -16 {{use of
> +undeclared identifier 'atomic_intptr_t'}} // expected-error at -16 {{use
> +of undeclared identifier 'atomic_uintptr_t'}} // expected-error at -16
> +{{use of undeclared identifier 'atomic_size_t'}} //
> +expected-error at -16 {{use of undeclared identifier
> +'atomic_ptrdiff_t'}} #elif !EXT // expected-error at -26 {{use of type
> +'atomic_long' (aka '_Atomic(long)') requires
> +cl_khr_int64_base_atomics extension to be enabled}} //
> +expected-error at -27 {{use of type 'atomic_long' (aka '_Atomic(long)')
> +requires cl_khr_int64_extended_atomics extension to be enabled}} //
> +expected-error at -27 {{use of type 'atomic_ulong' (aka
> +'_Atomic(unsigned long)') requires cl_khr_int64_base_atomics
> +extension to be enabled}} // expected-error at -28 {{use of type
> +'atomic_ulong' (aka '_Atomic(unsigned long)') requires
> +cl_khr_int64_extended_atomics extension to be enabled}} //
> +expected-error at -27 {{use of type 'atomic_double' (aka
> +'_Atomic(double)') requires cl_khr_int64_base_atomics extension to be
> +enabled}} // expected-error at -28 {{use of type 'atomic_double' (aka
> +'_Atomic(double)') requires cl_khr_int64_extended_atomics extension
> +to be enabled}} // expected-error at -29 {{use of type 'atomic_double'
> +(aka '_Atomic(double)') requires cl_khr_fp64 extension to be
> +enabled}} // expected-error-re at -28 {{use of type 'atomic_intptr_t'
> +(aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension
> +to be enabled}} // expected-error-re at -29 {{use of type
> +'atomic_intptr_t' (aka '_Atomic({{.+}})') requires
> +cl_khr_int64_extended_atomics extension to be enabled}} //
> +expected-error-re at -29 {{use of type 'atomic_uintptr_t' (aka
> +'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be
> +enabled}} // expected-error-re at -30 {{use of type 'atomic_uintptr_t'
> +(aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics
> +extension to be enabled}} // expected-error-re at -30 {{use of type
> +'atomic_size_t' (aka '_Atomic({{.+}})') requires
> +cl_khr_int64_base_atomics extension to be enabled}} //
> +expected-error-re at -31 {{use of type 'atomic_size_t' (aka
> +'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension
> +to be enabled}} // expected-error-re at -31 {{use of type
> +'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires
> +cl_khr_int64_base_atomics extension to be enabled}} //
> +expected-error-re at -32 {{use of type 'atomic_ptrdiff_t' (aka
> +'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension
> +to be enabled}} #endif
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list