This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Improve diagnostics for double type
AbandonedPublic

Authored by echuraev on Dec 19 2016, 5:14 AM.

Details

Reviewers
Anastasia

Diff Detail

Event Timeline

echuraev updated this revision to Diff 81939.Dec 19 2016, 5:14 AM
echuraev retitled this revision from to [OpenCL] Improve diagnostics for double type.
echuraev updated this object.
echuraev added a reviewer: Anastasia.
echuraev added subscribers: bader, cfe-commits, yaxunl.
yaxunl added inline comments.Dec 19 2016, 7:50 AM
lib/Sema/SemaType.cpp
1505

Please update with clang ToT since OpenCLOptions has interface changes.

echuraev updated this revision to Diff 82094.Dec 20 2016, 4:42 AM
echuraev marked an inline comment as done.
Anastasia added inline comments.Dec 23 2016, 5:01 AM
test/SemaOpenCL/unknown_type.cl
2

Could this be merged with similar test in test/SemaOpenCL/extensions.cl instyead of adding a new file?

This diagnostic was added in this commit: https://reviews.llvm.org/rL289979
It is something like that: "use of undeclared identifier 'double2'; did you mean 'double'?"
This message isn't clear enough and it is difficult to understand that I forgot to enable cl_khr_fp64 extension. May be it will be better to change this diagnostic message to something like that: "use of type 'double2' (vector of 2 'double' values) requires cl_khr_fp64 extension to be enabled"

echuraev abandoned this revision.Jan 26 2017, 2:14 AM

with the new pragma for associating types with extensions. This feature can be implemented by solely modify opencl-c.h by adding #pragma OPENCL EXTENSION cl_khr_fp64 : begin/end around vector double type definitions, e.g.

#pragma OPENCL EXTENSION cl_khr_fp64 : begin
typedef double double2 __attribute__((ext_vector_type(2)));
typedef double double3 __attribute__((ext_vector_type(3)));
typedef double double4 __attribute__((ext_vector_type(4)));
typedef double double8 __attribute__((ext_vector_type(8)));
typedef double double16 __attribute__((ext_vector_type(16)));
#pragma OPENCL EXTENSION cl_khr_fp64 : end
#ifdef cl_khr_fp64
#if __OPENCL_C_VERSION__ < CL_VERSION_1_2
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#endif
#endif

The

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

is for suppressing diagnostics due to using double type in builtin functions. Ideally they should also be surrounded by #pragma OPENCL EXTENSION cl_khr_fp64 : begin/end.