[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-02-17 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added a comment.

Is there any chance to get this commit cherry-picked to 10.x branch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-02-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

I have updated the TableGen OpenCL builtin definitions accordingly in 
91b3083aecd 
 
("[OpenCL] Fix tblgen support for cl_khr_mipmap_image_writes", 2020-02-05).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-02-05 Thread Alexey Sotkin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
AlexeySotkin marked an inline comment as done.
Closed by commit rGf780e15caf1b: [OpenCL] Fix support for 
cl_khr_mipmap_image_writes (authored by AlexeySotkin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/extension-version.cl


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -243,6 +243,18 @@
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image_writes
+#error "Missing cl_khr_mipmap_image_writes define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image_writes
+#error "Incorrect cl_khr_mipmap_image_writes define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 
'cl_khr_mipmap_image_writes' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -14682,7 +14682,7 @@
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image1d_t image, int coord, int lod, 
uint4 color);
@@ -14699,15 +14699,16 @@
 void __ovld write_imagei(write_only image2d_array_t image_array, int4 coord, 
int lod, int4 color);
 void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, 
int lod, uint4 color);
 
-void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float color);
-void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float color);
+void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float depth);
+void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float depth);
 
 #ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#endif //defined(cl_khr_mipmap_image_writes)
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
@@ -14756,7 +14757,7 @@
 #endif //cl_khr_depth_images
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image1d_t image, int coord, int lod, 
uint4 color);
@@ -14780,8 +14781,9 @@
 void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#endif //cl_khr_mipmap_image_writes
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- clang/include/clang/Basic/OpenCLExtensions.def
+++ clang/include/clang/Basic/OpenCLExtensions.def
@@ -70,6 +70,7 @@
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- 

[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-28 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D71460#1844959 , @Anastasia wrote:

> Adding @svenvh mainly to check if any fix is needed for the TableGen BIFs too?


Yes I believe we should also update `clang/lib/Sema/OpenCLBuiltins.td`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Adding @svenvh mainly to check if any fix is needed for the TableGen BIFs too?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!




Comment at: clang/lib/Headers/opencl-c.h:14686
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);

AlexeySotkin wrote:
> Anastasia wrote:
> > AlexeySotkin wrote:
> > > Anastasia wrote:
> > > > Do we actually need pragma for this extension? I.e. does it need to 
> > > > activate any special mode in the compiler?
> > > I'm not aware of any special mode required for this extension. These 
> > > begin/end pragma lines were added to disable the extension by default as 
> > > it is [[ 
> > > https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/introduction.asciidoc#compiler-directives-for-optional-extensions
> > >  | required ]] by the OpenCL extension spec. Is there any other mechanism 
> > > which should be used for this purpose?
> > > Probably, we should do the same for `cl_khr_mipmap_image`(and maybe 
> > > others?), because with the current compiler, built-ins from this 
> > > extension can be compiled successfully even if `#pragma OPENCL EXTENSION 
> > > cl_khr_mipmap_image : disable` is specified. See 
> > > https://godbolt.org/z/fNEWuG
> > What I am saying is that `pragma` is only typically used to activate some 
> > special mode in the compiler. If we don't need to activate anything perhaps 
> > we don't need to add `pragma` at all? It simplifies compiler and 
> > application code too. Would regular include mechanisms be enough to guard 
> > the availability of those functions?
> > 
> > Maybe this thread will help to understand the topic better: 
> > https://github.com/KhronosGroup/OpenCL-Docs/issues/82
> I think you are right. I have removed the pragma.
I think we probably should get rid of most of extensions in 
clang/include/clang/Basic/OpenCLExtensions.def and just try to implement the 
extensions macro using target specific header.

But it doesn't belong to your change and it's probably too big of the change 
anyway. Just a thought. :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-27 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin marked 2 inline comments as done.
AlexeySotkin added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:14686
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);

Anastasia wrote:
> AlexeySotkin wrote:
> > Anastasia wrote:
> > > Do we actually need pragma for this extension? I.e. does it need to 
> > > activate any special mode in the compiler?
> > I'm not aware of any special mode required for this extension. These 
> > begin/end pragma lines were added to disable the extension by default as it 
> > is [[ 
> > https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/introduction.asciidoc#compiler-directives-for-optional-extensions
> >  | required ]] by the OpenCL extension spec. Is there any other mechanism 
> > which should be used for this purpose?
> > Probably, we should do the same for `cl_khr_mipmap_image`(and maybe 
> > others?), because with the current compiler, built-ins from this extension 
> > can be compiled successfully even if `#pragma OPENCL EXTENSION 
> > cl_khr_mipmap_image : disable` is specified. See 
> > https://godbolt.org/z/fNEWuG
> What I am saying is that `pragma` is only typically used to activate some 
> special mode in the compiler. If we don't need to activate anything perhaps 
> we don't need to add `pragma` at all? It simplifies compiler and application 
> code too. Would regular include mechanisms be enough to guard the 
> availability of those functions?
> 
> Maybe this thread will help to understand the topic better: 
> https://github.com/KhronosGroup/OpenCL-Docs/issues/82
I think you are right. I have removed the pragma.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-27 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin updated this revision to Diff 240510.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/extension-version.cl


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -243,6 +243,18 @@
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image_writes
+#error "Missing cl_khr_mipmap_image_writes define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image_writes
+#error "Incorrect cl_khr_mipmap_image_writes define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 
'cl_khr_mipmap_image_writes' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -14682,7 +14682,7 @@
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image1d_t image, int coord, int lod, 
uint4 color);
@@ -14699,15 +14699,16 @@
 void __ovld write_imagei(write_only image2d_array_t image_array, int4 coord, 
int lod, int4 color);
 void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, 
int lod, uint4 color);
 
-void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float color);
-void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float color);
+void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float depth);
+void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float depth);
 
 #ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#endif //defined(cl_khr_mipmap_image_writes)
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
@@ -14756,7 +14757,7 @@
 #endif //cl_khr_depth_images
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image1d_t image, int coord, int lod, 
uint4 color);
@@ -14780,8 +14781,9 @@
 void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#endif //cl_khr_mipmap_image_writes
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- clang/include/clang/Basic/OpenCLExtensions.def
+++ clang/include/clang/Basic/OpenCLExtensions.def
@@ -70,6 +70,7 @@
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -243,6 +243,18 @@
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)

[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:14686
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);

AlexeySotkin wrote:
> Anastasia wrote:
> > Do we actually need pragma for this extension? I.e. does it need to 
> > activate any special mode in the compiler?
> I'm not aware of any special mode required for this extension. These 
> begin/end pragma lines were added to disable the extension by default as it 
> is [[ 
> https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/introduction.asciidoc#compiler-directives-for-optional-extensions
>  | required ]] by the OpenCL extension spec. Is there any other mechanism 
> which should be used for this purpose?
> Probably, we should do the same for `cl_khr_mipmap_image`(and maybe others?), 
> because with the current compiler, built-ins from this extension can be 
> compiled successfully even if `#pragma OPENCL EXTENSION cl_khr_mipmap_image : 
> disable` is specified. See https://godbolt.org/z/fNEWuG
What I am saying is that `pragma` is only typically used to activate some 
special mode in the compiler. If we don't need to activate anything perhaps we 
don't need to add `pragma` at all? It simplifies compiler and application code 
too. Would regular include mechanisms be enough to guard the availability of 
those functions?

Maybe this thread will help to understand the topic better: 
https://github.com/KhronosGroup/OpenCL-Docs/issues/82


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-19 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin updated this revision to Diff 234674.
AlexeySotkin added a comment.

Rename `color` to `depth`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/extension-version.cl


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -243,6 +243,18 @@
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image_writes
+#error "Missing cl_khr_mipmap_image_writes define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image_writes
+#error "Incorrect cl_khr_mipmap_image_writes define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 
'cl_khr_mipmap_image_writes' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -14682,7 +14682,8 @@
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image1d_t image, int coord, int lod, 
uint4 color);
@@ -14699,15 +14700,17 @@
 void __ovld write_imagei(write_only image2d_array_t image_array, int4 coord, 
int lod, int4 color);
 void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, 
int lod, uint4 color);
 
-void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float color);
-void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float color);
+void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float depth);
+void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float depth);
 
 #ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : end
+#endif //defined(cl_khr_mipmap_image_writes)
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
@@ -14756,7 +14759,8 @@
 #endif //cl_khr_depth_images
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#ifdef cl_khr_mipmap_image_writes
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image1d_t image, int coord, int lod, 
uint4 color);
@@ -14780,8 +14784,10 @@
 void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : end
+#endif //cl_khr_mipmap_image_writes
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- clang/include/clang/Basic/OpenCLExtensions.def
+++ clang/include/clang/Basic/OpenCLExtensions.def
@@ -70,6 +70,7 @@
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: clang/test/SemaOpenCL/extension-version.cl

[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-18 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin marked an inline comment as done.
AlexeySotkin added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:14686
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);

Anastasia wrote:
> Do we actually need pragma for this extension? I.e. does it need to activate 
> any special mode in the compiler?
I'm not aware of any special mode required for this extension. These begin/end 
pragma lines were added to disable the extension by default as it is [[ 
https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/introduction.asciidoc#compiler-directives-for-optional-extensions
 | required ]] by the OpenCL extension spec. Is there any other mechanism which 
should be used for this purpose?
Probably, we should do the same for `cl_khr_mipmap_image`(and maybe others?), 
because with the current compiler, built-ins from this extension can be 
compiled successfully even if `#pragma OPENCL EXTENSION cl_khr_mipmap_image : 
disable` is specified. See https://godbolt.org/z/fNEWuG


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-18 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added a comment.

In D71460#1783390 , @asavonic wrote:

> What about `get_image_num_mip_levels` functions defined in the extension 
> specification?
>
> Edit: I mean, should the `get_image_num_mip_levels(write_only img)` function 
> be only available if `cl_khr_mipmap_image_writes` extension is supported, or 
> `cl_khr_mipmap_image` is enough?


I think `cl_khr_mipmap_image` is enough, because "the 
`cl_khr_mipmap_image_writes` extension adds built-in functions that can be used 
to **write** a mip-mapped image", while `get_image_num_mip_levels(write_only 
img)` only retrieve a property of the image.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:14686
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);

Do we actually need pragma for this extension? I.e. does it need to activate 
any special mode in the compiler?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-13 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added a comment.

What about `get_image_num_mip_levels` functions defined in the extension 
specification?




Comment at: clang/lib/Headers/opencl-c.h:14780
 
 void __ovld write_imagef(read_write image2d_depth_t image, int2 coord, int 
lod, float color);
 void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, 
int lod, float color);

Shouldn't "color" be renamed to "depth" here as well?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71460/new/

https://reviews.llvm.org/D71460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2019-12-13 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin created this revision.
AlexeySotkin added reviewers: Anastasia, svenvh, yaxunl, asavonic.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Patch by Ilya Mashkov


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71460

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/extension-version.cl


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -243,6 +243,18 @@
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image_writes
+#error "Missing cl_khr_mipmap_image_writes define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image_writes
+#error "Incorrect cl_khr_mipmap_image_writes define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 
'cl_khr_mipmap_image_writes' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -14682,7 +14682,8 @@
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image1d_t image, int coord, int lod, 
uint4 color);
@@ -14699,15 +14700,17 @@
 void __ovld write_imagei(write_only image2d_array_t image_array, int4 coord, 
int lod, int4 color);
 void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, 
int lod, uint4 color);
 
-void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float color);
-void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float color);
+void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float depth);
+void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float depth);
 
 #ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : end
+#endif //defined(cl_khr_mipmap_image_writes)
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
@@ -14756,7 +14759,8 @@
 #endif //cl_khr_depth_images
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#ifdef cl_khr_mipmap_image_writes
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image1d_t image, int coord, int lod, 
uint4 color);
@@ -14780,8 +14784,10 @@
 void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : end
+#endif //cl_khr_mipmap_image_writes
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- clang/include/clang/Basic/OpenCLExtensions.def
+++ clang/include/clang/Basic/OpenCLExtensions.def
@@ -70,6 +70,7 @@
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: