[Libclc-dev] [PATCH] Add image attribute getter builtins

Zoltán Gilián zoltan.gilian at gmail.com
Tue Jun 16 09:01:05 PDT 2015


Backend support for this has been submitted to llvm.

On Tue, Jun 16, 2015 at 4:33 PM, Zoltan Gilian <zoltan.gilian at gmail.com>
wrote:

> Added get_image_* OpenCL builtins to the headers along with a dummy
> implementation to the R600 libs.
> The builtins need to be replaced by the compiler.
> ---
>  generic/include/clc/clc.h                     |  4 ++++
>  generic/include/clc/image/image.h             | 16 ++++++++++++++++
>  generic/lib/SOURCES                           |  1 +
>  generic/lib/image/get_image_dim.cl            |  9 +++++++++
>  r600/lib/SOURCES                              |  5 +++++
>  r600/lib/image/get_image_channel_data_type.cl | 13 +++++++++++++
>  r600/lib/image/get_image_channel_order.cl     | 13 +++++++++++++
>  r600/lib/image/get_image_depth.cl             |  8 ++++++++
>  r600/lib/image/get_image_height.cl            | 13 +++++++++++++
>  r600/lib/image/get_image_width.cl             | 13 +++++++++++++
>  10 files changed, 95 insertions(+)
>  create mode 100644 generic/include/clc/image/image.h
>  create mode 100644 generic/lib/image/get_image_dim.cl
>  create mode 100644 r600/lib/image/get_image_channel_data_type.cl
>  create mode 100644 r600/lib/image/get_image_channel_order.cl
>  create mode 100644 r600/lib/image/get_image_depth.cl
>  create mode 100644 r600/lib/image/get_image_height.cl
>  create mode 100644 r600/lib/image/get_image_width.cl
>
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index cab751d..4199842 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -210,6 +210,10 @@
>  #include <clc/cl_khr_local_int32_extended_atomics/atom_or.h>
>  #include <clc/cl_khr_local_int32_extended_atomics/atom_xor.h>
>
> +/* 6.11.13 Image Read and Write Functions */
> +
> +#include <clc/image/image.h>
> +
>  /* libclc internal defintions */
>  #ifdef __CLC_INTERNAL
>  #include <math/clc_nextafter.h>
> diff --git a/generic/include/clc/image/image.h
> b/generic/include/clc/image/image.h
> new file mode 100644
> index 0000000..9c97563
> --- /dev/null
> +++ b/generic/include/clc/image/image.h
> @@ -0,0 +1,16 @@
> +_CLC_OVERLOAD _CLC_DECL int get_image_width (image2d_t image);
> +_CLC_OVERLOAD _CLC_DECL int get_image_width (image3d_t image);
> +
> +_CLC_OVERLOAD _CLC_DECL int get_image_height (image2d_t image);
> +_CLC_OVERLOAD _CLC_DECL int get_image_height (image3d_t image);
> +
> +_CLC_OVERLOAD _CLC_DECL int get_image_depth (image3d_t image);
> +
> +_CLC_OVERLOAD _CLC_DECL int get_image_channel_data_type (image2d_t image);
> +_CLC_OVERLOAD _CLC_DECL int get_image_channel_data_type (image3d_t image);
> +
> +_CLC_OVERLOAD _CLC_DECL int get_image_channel_order (image2d_t image);
> +_CLC_OVERLOAD _CLC_DECL int get_image_channel_order (image3d_t image);
> +
> +_CLC_OVERLOAD _CLC_DECL int2 get_image_dim (image2d_t image);
> +_CLC_OVERLOAD _CLC_DECL int4 get_image_dim (image3d_t image);
> diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
> index 1e63994..3712785 100644
> --- a/generic/lib/SOURCES
> +++ b/generic/lib/SOURCES
> @@ -127,3 +127,4 @@ shared/vload.cl
>  shared/vstore.cl
>  workitem/get_global_id.cl
>  workitem/get_global_size.cl
> +image/get_image_dim.cl
> diff --git a/generic/lib/image/get_image_dim.cl b/generic/lib/image/
> get_image_dim.cl
> new file mode 100644
> index 0000000..26dbd00
> --- /dev/null
> +++ b/generic/lib/image/get_image_dim.cl
> @@ -0,0 +1,9 @@
> +#include <clc/clc.h>
> +
> +_CLC_OVERLOAD _CLC_DEF int2 get_image_dim (image2d_t image) {
> +  return (int2)(get_image_width(image), get_image_height(image));
> +}
> +_CLC_OVERLOAD _CLC_DEF int4 get_image_dim (image3d_t image) {
> +  return (int4)(get_image_width(image), get_image_height(image),
> +                get_image_depth(image), 0);
> +}
> diff --git a/r600/lib/SOURCES b/r600/lib/SOURCES
> index 0f1227e..a909608 100644
> --- a/r600/lib/SOURCES
> +++ b/r600/lib/SOURCES
> @@ -9,3 +9,8 @@ workitem/get_global_size.ll
>  workitem/get_work_dim.ll
>  synchronization/barrier.cl
>  synchronization/barrier_impl.ll
> +image/get_image_width.cl
> +image/get_image_height.cl
> +image/get_image_depth.cl
> +image/get_image_channel_data_type.cl
> +image/get_image_channel_order.cl
> diff --git a/r600/lib/image/get_image_channel_data_type.cl
> b/r600/lib/image/get_image_channel_data_type.cl
> new file mode 100644
> index 0000000..b82da5a
> --- /dev/null
> +++ b/r600/lib/image/get_image_channel_data_type.cl
> @@ -0,0 +1,13 @@
> +#include <clc/clc.h>
> +
> +int __clc_get_image_channel_data_type_2d(image2d_t)
> __asm("llvm.r600.get.image.channel.data.type");
> +int __clc_get_image_channel_data_type_3d(image3d_t)
> __asm("llvm.r600.get.image.channel.data.type");
> +
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_channel_data_type(image2d_t image) {
> +       return __clc_get_image_channel_data_type_2d(image);
> +}
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_channel_data_type(image3d_t image) {
> +       return __clc_get_image_channel_data_type_3d(image);
> +}
> diff --git a/r600/lib/image/get_image_channel_order.cl b/r600/lib/image/
> get_image_channel_order.cl
> new file mode 100644
> index 0000000..0c31e20
> --- /dev/null
> +++ b/r600/lib/image/get_image_channel_order.cl
> @@ -0,0 +1,13 @@
> +#include <clc/clc.h>
> +
> +int __clc_get_image_channel_order_2d(image2d_t)
> __asm("llvm.r600.get.image.channel.order");
> +int __clc_get_image_channel_order_3d(image3d_t)
> __asm("llvm.r600.get.image.channel.order");
> +
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_channel_order(image2d_t image) {
> +       return __clc_get_image_channel_order_2d(image);
> +}
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_channel_order(image3d_t image) {
> +       return __clc_get_image_channel_order_3d(image);
> +}
> diff --git a/r600/lib/image/get_image_depth.cl b/r600/lib/image/
> get_image_depth.cl
> new file mode 100644
> index 0000000..4b41ff9
> --- /dev/null
> +++ b/r600/lib/image/get_image_depth.cl
> @@ -0,0 +1,8 @@
> +#include <clc/clc.h>
> +
> +int __clc_get_image_depth_3d(image3d_t)
> __asm("llvm.r600.get.image.depth");
> +
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_depth(image3d_t image) {
> +       return __clc_get_image_depth_3d(image);
> +}
> diff --git a/r600/lib/image/get_image_height.cl b/r600/lib/image/
> get_image_height.cl
> new file mode 100644
> index 0000000..6b9aa91
> --- /dev/null
> +++ b/r600/lib/image/get_image_height.cl
> @@ -0,0 +1,13 @@
> +#include <clc/clc.h>
> +
> +int __clc_get_image_height_2d(image2d_t)
> __asm("llvm.r600.get.image.height");
> +int __clc_get_image_height_3d(image3d_t)
> __asm("llvm.r600.get.image.height");
> +
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_height(image2d_t image) {
> +       return __clc_get_image_height_2d(image);
> +}
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_height(image3d_t image) {
> +       return __clc_get_image_height_3d(image);
> +}
> diff --git a/r600/lib/image/get_image_width.cl b/r600/lib/image/
> get_image_width.cl
> new file mode 100644
> index 0000000..58a1c73
> --- /dev/null
> +++ b/r600/lib/image/get_image_width.cl
> @@ -0,0 +1,13 @@
> +#include <clc/clc.h>
> +
> +int __clc_get_image_width_2d(image2d_t)
> __asm("llvm.r600.get.image.width");
> +int __clc_get_image_width_3d(image3d_t)
> __asm("llvm.r600.get.image.width");
> +
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_width(image2d_t image) {
> +       return __clc_get_image_width_2d(image);
> +}
> +_CLC_OVERLOAD _CLC_DEF int
> +get_image_width(image3d_t image) {
> +       return __clc_get_image_width_3d(image);
> +}
> --
> 2.4.2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libclc-dev/attachments/20150616/e79e88b8/attachment-0002.html>


More information about the Libclc-dev mailing list