[khronos-opencl-headers] 61/94: Imported Upstream version 1.2-2013.06.28

Andreas Beckmann anbe at moszumanska.debian.org
Mon Sep 21 02:39:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

anbe pushed a commit to branch master
in repository khronos-opencl-headers.

commit 1e6473a7eb15ff9d78b2e8b9e09452d4d3c44e1e
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sun Jul 14 15:28:57 2013 +0200

    Imported Upstream version 1.2-2013.06.28
---
 cl.hpp   | 598 ++++++++++++++++++++++++++++++++++++---------------------------
 cl_ext.h |  65 ++++++-
 2 files changed, 400 insertions(+), 263 deletions(-)

diff --git a/cl.hpp b/cl.hpp
index 06448e2..0480e31 100644
--- a/cl.hpp
+++ b/cl.hpp
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008-2012 The Khronos Group Inc.
+ * Copyright (c) 2008-2013 The Khronos Group Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and/or associated documentation files (the
@@ -30,9 +30,10 @@
  *   Additions and fixes from:
  *       Brian Cole, March 3rd 2010 and April 2012 
  *       Matt Gruenke, April 2012.
+ *       Bruce Merry, February 2013.
  *   
- *   \version 1.2.4
- *   \date January 2013
+ *   \version 1.2.5
+ *   \date June 2013
  *
  *   Optional extension support
  *
@@ -58,8 +59,8 @@
  *
  * For detail documentation on the bindings see:
  *
- * The OpenCL C++ Wrapper API 1.1 (revision 04)
- *  http://www.khronos.org/registry/cl/specs/opencl-cplusplus-1.1.pdf
+ * The OpenCL C++ Wrapper API 1.2 (revision 09)
+ *  http://www.khronos.org/registry/cl/specs/opencl-cplusplus-1.2.pdf
  *
  * \section example Example
  *
@@ -256,6 +257,7 @@ class Device;
 class Context;
 class CommandQueue;
 class Memory;
+class Buffer;
 
 #if defined(__CL_ENABLE_EXCEPTIONS)
 /*! \brief Exception class 
@@ -1077,145 +1079,154 @@ public:
 
 namespace detail {
 
-// GetInfo help struct
-template <typename Functor, typename T>
-struct GetInfoHelper
+// Generic getInfoHelper. The final parameter is used to guide overload
+// resolution: the actual parameter passed is an int, which makes this
+// a worse conversion sequence than a specialization that declares the
+// parameter as an int.
+template<typename Functor, typename T>
+inline cl_int getInfoHelper(Functor f, cl_uint name, T* param, long)
 {
-    static cl_int
-    get(Functor f, cl_uint name, T* param)
-    {
-        return f(name, sizeof(T), param, NULL);
-    }
-};
+    return f(name, sizeof(T), param, NULL);
+}
 
-// Specialized GetInfoHelper for VECTOR_CLASS params
+// Specialized getInfoHelper for VECTOR_CLASS params
 template <typename Func, typename T>
-struct GetInfoHelper<Func, VECTOR_CLASS<T> >
+inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<T>* param, long)
 {
-    static cl_int get(Func f, cl_uint name, VECTOR_CLASS<T>* param)
-    {
-        ::size_t required;
-        cl_int err = f(name, 0, NULL, &required);
-        if (err != CL_SUCCESS) {
-            return err;
-        }
-
-        T* value = (T*) alloca(required);
-        err = f(name, required, value, NULL);
-        if (err != CL_SUCCESS) {
-            return err;
-        }
+    ::size_t required;
+    cl_int err = f(name, 0, NULL, &required);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
 
-        param->assign(&value[0], &value[required/sizeof(T)]);
-        return CL_SUCCESS;
+    T* value = (T*) alloca(required);
+    err = f(name, required, value, NULL);
+    if (err != CL_SUCCESS) {
+        return err;
     }
-};
 
-template <typename Func>
-struct GetInfoHelper<Func, VECTOR_CLASS<cl::Device> >
+    param->assign(&value[0], &value[required/sizeof(T)]);
+    return CL_SUCCESS;
+}
+
+/* Specialization for reference-counted types. This depends on the
+ * existence of Wrapper<T>::cl_type, and none of the other types having the
+ * cl_type member. Note that simplify specifying the parameter as Wrapper<T>
+ * does not work, because when using a derived type (e.g. Context) the generic
+ * template will provide a better match.
+ */
+template <typename Func, typename T>
+inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<T>* param, int, typename T::cl_type = 0)
 {
-    static cl_int get(Func f, cl_uint name, VECTOR_CLASS<cl::Device>* param)
-    {
-        ::size_t required;
-        cl_int err = f(name, 0, NULL, &required);
-        if (err != CL_SUCCESS) {
-            return err;
-        }
+    ::size_t required;
+    cl_int err = f(name, 0, NULL, &required);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
 
-        cl_device_id* value = (cl_device_id*) alloca(required);
-        err = f(name, required, value, NULL);
-        if (err != CL_SUCCESS) {
-            return err;
-        }
+    typename T::cl_type * value = (typename T::cl_type *) alloca(required);
+    err = f(name, required, value, NULL);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
 
-        param->assign(&value[0], &value[required/sizeof(cl_device_id)]);
-        return CL_SUCCESS;
+    ::size_t elements = required / sizeof(typename T::cl_type);
+    param->assign(&value[0], &value[elements]);
+    for (::size_t i = 0; i < elements; i++)
+    {
+        if (value[i] != NULL)
+        {
+            err = (*param)[i].retain();
+            if (err != CL_SUCCESS) {
+                return err;
+            }
+        }
     }
-};
+    return CL_SUCCESS;
+}
 
 // Specialized for getInfo<CL_PROGRAM_BINARIES>
 template <typename Func>
-struct GetInfoHelper<Func, VECTOR_CLASS<char *> >
+inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<char *>* param, int)
 {
-    static cl_int
-    get(Func f, cl_uint name, VECTOR_CLASS<char *>* param)
-    {
-      cl_uint err = f(name, param->size() * sizeof(char *), &(*param)[0], NULL);
+    cl_int err = f(name, param->size() * sizeof(char *), &(*param)[0], NULL);
 
-      if (err != CL_SUCCESS) {
+    if (err != CL_SUCCESS) {
         return err;
-      }
-
-      return CL_SUCCESS;
     }
-};
+
+    return CL_SUCCESS;
+}
 
 // Specialized GetInfoHelper for STRING_CLASS params
 template <typename Func>
-struct GetInfoHelper<Func, STRING_CLASS>
+inline cl_int getInfoHelper(Func f, cl_uint name, STRING_CLASS* param, long)
 {
-    static cl_int get(Func f, cl_uint name, STRING_CLASS* param)
-    {
-        ::size_t required;
-        cl_int err = f(name, 0, NULL, &required);
-        if (err != CL_SUCCESS) {
-            return err;
-        }
-
-        char* value = (char*) alloca(required);
-        err = f(name, required, value, NULL);
-        if (err != CL_SUCCESS) {
-            return err;
-        }
+    ::size_t required;
+    cl_int err = f(name, 0, NULL, &required);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
 
-        *param = value;
-        return CL_SUCCESS;
+    char* value = (char*) alloca(required);
+    err = f(name, required, value, NULL);
+    if (err != CL_SUCCESS) {
+        return err;
     }
-};
+
+    *param = value;
+    return CL_SUCCESS;
+}
 
 // Specialized GetInfoHelper for cl::size_t params
 template <typename Func, ::size_t N>
-struct GetInfoHelper<Func, size_t<N> >
+inline cl_int getInfoHelper(Func f, cl_uint name, size_t<N>* param, long)
 {
-    static cl_int get(Func f, cl_uint name, size_t<N>* param)
-    {
-        ::size_t required;
-        cl_int err = f(name, 0, NULL, &required);
-        if (err != CL_SUCCESS) {
-            return err;
-        }
+    ::size_t required;
+    cl_int err = f(name, 0, NULL, &required);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
 
-        ::size_t* value = (::size_t*) alloca(required);
-        err = f(name, required, value, NULL);
-        if (err != CL_SUCCESS) {
-            return err;
-        }
+    ::size_t* value = (::size_t*) alloca(required);
+    err = f(name, required, value, NULL);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
 
-        for(int i = 0; i < N; ++i) {
-            (*param)[i] = value[i];
-        }
- 
-        return CL_SUCCESS;
+    for(int i = 0; i < N; ++i) {
+        (*param)[i] = value[i];
     }
-};
 
-#define __GET_INFO_HELPER_WITH_RETAIN(CPP_TYPE) \
-namespace detail { \
-template <typename Func> \
-struct GetInfoHelper<Func, CPP_TYPE> \
-{ \
-    static cl_int get(Func f, cl_uint name, CPP_TYPE* param) \
-    { \
-      cl_uint err = f(name, sizeof(CPP_TYPE), param, NULL); \
-      if (err != CL_SUCCESS) { \
-        return err; \
-      } \
-      \
-      return ReferenceHandler<CPP_TYPE::cl_type>::retain((*param)()); \
-    } \
-}; \
-} 
+    return CL_SUCCESS;
+}
 
+template<typename T> struct ReferenceHandler;
+
+/* Specialization for reference-counted types. This depends on the
+ * existence of Wrapper<T>::cl_type, and none of the other types having the
+ * cl_type member. Note that simplify specifying the parameter as Wrapper<T>
+ * does not work, because when using a derived type (e.g. Context) the generic
+ * template will provide a better match.
+ */
+template<typename Func, typename T>
+inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = 0)
+{
+    typename T::cl_type value;
+    cl_int err = f(name, sizeof(value), &value, NULL);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+    *param = value;
+    if (value != NULL)
+    {
+        err = param->retain();
+        if (err != CL_SUCCESS) {
+            return err;
+        }
+    }
+    return CL_SUCCESS;
+}
 
 #define __PARAM_NAME_INFO_1_0(F) \
     F(cl_platform_info, CL_PLATFORM_PROFILE, STRING_CLASS) \
@@ -1366,6 +1377,8 @@ struct GetInfoHelper<Func, CPP_TYPE> \
     
 #if defined(CL_VERSION_1_2)
 #define __PARAM_NAME_INFO_1_2(F) \
+    F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) \
+    \
     F(cl_program_info, CL_PROGRAM_NUM_KERNELS, ::size_t) \
     F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, STRING_CLASS) \
     \
@@ -1487,7 +1500,7 @@ template <typename Func, typename T>
 inline cl_int
 getInfo(Func f, cl_uint name, T* param)
 {
-    return GetInfoHelper<Func, T>::get(f, name, param);
+    return getInfoHelper(f, name, param, 0);
 }
 
 template <typename Func, typename Arg0>
@@ -1513,8 +1526,7 @@ inline cl_int
 getInfo(Func f, const Arg0& arg0, cl_uint name, T* param)
 {
     GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 };
-    return GetInfoHelper<GetInfoFunctor0<Func, Arg0>, T>
-        ::get(f0, name, param);
+    return getInfoHelper(f0, name, param, 0);
 }
 
 template <typename Func, typename Arg0, typename Arg1, typename T>
@@ -1522,8 +1534,7 @@ inline cl_int
 getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param)
 {
     GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
-    return GetInfoHelper<GetInfoFunctor1<Func, Arg0, Arg1>, T>
-        ::get(f0, name, param);
+    return getInfoHelper(f0, name, param, 0);
 }
 
 template<typename T>
@@ -1650,6 +1661,58 @@ struct ReferenceHandler<cl_event>
     { return ::clReleaseEvent(event); }
 };
 
+
+// Extracts version number with major in the upper 16 bits, minor in the lower 16
+static cl_uint getVersion(const char *versionInfo)
+{
+    int highVersion = 0;
+    int lowVersion = 0;
+    int index = 7;
+    while(versionInfo[index] != '.' ) {
+        highVersion *= 10;
+        highVersion += versionInfo[index]-'0';
+        ++index;
+    }
+    ++index;
+    while(versionInfo[index] != ' ' ) {
+        lowVersion *= 10;
+        lowVersion += versionInfo[index]-'0';
+        ++index;
+    }
+    return (highVersion << 16) | lowVersion;
+}
+
+static cl_uint getPlatformVersion(cl_platform_id platform)
+{
+    ::size_t size = 0;
+    clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
+    char *versionInfo = (char *) alloca(size);
+    clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, &versionInfo[0], &size);
+    return getVersion(versionInfo);
+}
+
+static cl_uint getDevicePlatformVersion(cl_device_id device)
+{
+    cl_platform_id platform;
+    clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
+    return getPlatformVersion(platform);
+}
+
+#if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+static cl_uint getContextPlatformVersion(cl_context context)
+{
+    // The platform cannot be queried directly, so we first have to grab a
+    // device and obtain its context
+    ::size_t size = 0;
+    clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
+    if (size == 0)
+        return 0;
+    cl_device_id *devices = (cl_device_id *) alloca(size);
+    clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices, NULL);
+    return getDevicePlatformVersion(devices[0]);
+}
+#endif // #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+
 template <typename T>
 class Wrapper
 {
@@ -1695,6 +1758,8 @@ public:
     cl_type& operator ()() { return object_; }
 
 protected:
+    template<typename Func, typename U>
+    friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type);
 
     cl_int retain() const
     {
@@ -1717,37 +1782,14 @@ protected:
     cl_type object_;
     bool referenceCountable_;
 
-    static int getVersion(cl_device_id device)
-    {
-        ::size_t size = 0;
-        clGetDeviceInfo(device, CL_DEVICE_VERSION, 0, 0, &size);
-        STRING_CLASS versionInfo;
-        versionInfo.resize(size + 1);
-        clGetDeviceInfo(device, CL_DEVICE_VERSION, size, &versionInfo[0],
-&size);
-        int highVersion = 0;
-        int lowVersion = 0;
-        int index = 7;
-        while(versionInfo[index] != '.' ) {
-            highVersion *= 10;
-            highVersion += versionInfo[index]-'0';
-            ++index;
-        }
-        ++index;
-        while(versionInfo[index] != ' ' ) {
-            lowVersion *= 10;
-            lowVersion += versionInfo[index]-'0';
-            ++index;
-        }
-        return (highVersion << 16) | lowVersion;
-    }
-
     static bool isReferenceCountable(cl_device_id device)
     {
         bool retVal = false;
-        int version = getVersion(device);
-        if(version > ((1 << 16) + 1)) {
-            retVal = true;
+        if (device != NULL) {
+            int version = getDevicePlatformVersion(device);
+            if(version > ((1 << 16) + 1)) {
+                retVal = true;
+            }
         }
         return retVal;
     }
@@ -1796,6 +1838,11 @@ public:
     cl_type& operator ()() { return object_; }
 
 protected:
+    template<typename Func, typename U>
+    friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type);
+
+    template<typename Func, typename U>
+    friend inline cl_int getInfoHelper(Func, cl_uint, VECTOR_CLASS<U>*, int, typename U::cl_type);
 
     cl_int retain() const
     {
@@ -2598,8 +2645,6 @@ __attribute__((weak)) Context Context::default_;
 __attribute__((weak)) volatile cl_int Context::default_error_ = CL_SUCCESS;
 #endif
 
-__GET_INFO_HELPER_WITH_RETAIN(cl::Context)
-
 /*! \brief Class interface for cl_event.
  *
  *  \note Copies of these objects are shallow, meaning that the copy will refer
@@ -2748,8 +2793,6 @@ public:
     }
 };
 
-__GET_INFO_HELPER_WITH_RETAIN(cl::Event)
-
 #if defined(CL_VERSION_1_1)
 /*! \brief Class interface for user events (a subset of cl_event's).
  * 
@@ -2906,7 +2949,7 @@ public:
      *  Wraps clSetMemObjectDestructorCallback().
      *
      *  Repeated calls to this function, for a given cl_mem value, will append
-     *  to the list of functions called (in reverse order) when memory object�s
+     *  to the list of functions called (in reverse order) when memory object's
      *  resources are freed and the memory object is deleted.
      *
      *  \note
@@ -2928,14 +2971,12 @@ public:
 
 };
 
-__GET_INFO_HELPER_WITH_RETAIN(cl::Memory)
-
 // Pre-declare copy functions
 class Buffer;
 template< typename IteratorType >
 cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
 template< typename IteratorType >
-cl_int copy( cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
+cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
 
 /*! \brief Class interface for Buffer Memory Objects.
  * 
@@ -3539,8 +3580,7 @@ public:
         cl_mem_flags flags,
         ImageFormat format,
         ::size_t width,
-        Buffer &buffer,
-        void* host_ptr = NULL,
+        const Buffer &buffer,
         cl_int* err = NULL)
     {
         cl_int error;
@@ -3556,7 +3596,7 @@ public:
             flags, 
             &format, 
             &desc, 
-            host_ptr, 
+            NULL, 
             &error);
 
         detail::errHandler(error, __CREATE_IMAGE_ERR);
@@ -3672,36 +3712,57 @@ public:
         cl_int* err = NULL)
     {
         cl_int error;
-#if defined(CL_VERSION_1_2)
-        cl_image_desc desc;
-        desc.image_type = CL_MEM_OBJECT_IMAGE2D;
-        desc.image_width = width;
-        desc.image_height = height;
-        desc.image_row_pitch = row_pitch;
-        desc.num_mip_levels = 0;
-        desc.num_samples = 0;
-        desc.buffer = 0;
-        object_ = ::clCreateImage(
-            context(), 
-            flags, 
-            &format, 
-            &desc, 
-            host_ptr, 
-            &error);
+        bool useCreateImage;
 
-        detail::errHandler(error, __CREATE_IMAGE_ERR);
-        if (err != NULL) {
-            *err = error;
+#if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+        // Run-time decision based on the actual platform
+        {
+            cl_uint version = detail::getContextPlatformVersion(context());
+            useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
         }
+#elif defined(CL_VERSION_1_2)
+        useCreateImage = true;
 #else
-        object_ = ::clCreateImage2D(
-            context(), flags,&format, width, height, row_pitch, host_ptr, &error);
+        useCreateImage = false;
+#endif
 
-        detail::errHandler(error, __CREATE_IMAGE2D_ERR);
-        if (err != NULL) {
-            *err = error;
+#if defined(CL_VERSION_1_2)
+        if (useCreateImage)
+        {
+            cl_image_desc desc;
+            desc.image_type = CL_MEM_OBJECT_IMAGE2D;
+            desc.image_width = width;
+            desc.image_height = height;
+            desc.image_row_pitch = row_pitch;
+            desc.num_mip_levels = 0;
+            desc.num_samples = 0;
+            desc.buffer = 0;
+            object_ = ::clCreateImage(
+                context(),
+                flags,
+                &format,
+                &desc,
+                host_ptr,
+                &error);
+
+            detail::errHandler(error, __CREATE_IMAGE_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
         }
 #endif // #if defined(CL_VERSION_1_2)
+#if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+        if (!useCreateImage)
+        {
+            object_ = ::clCreateImage2D(
+                context(), flags,&format, width, height, row_pitch, host_ptr, &error);
+
+            detail::errHandler(error, __CREATE_IMAGE2D_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+        }
+#endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
     }
 
     //! \brief Default constructor - initializes to NULL.
@@ -3916,39 +3977,60 @@ public:
         cl_int* err = NULL)
     {
         cl_int error;
-#if defined(CL_VERSION_1_2)
-        cl_image_desc desc;
-        desc.image_type = CL_MEM_OBJECT_IMAGE3D;
-        desc.image_width = width;
-        desc.image_height = height;
-        desc.image_depth = depth;
-        desc.image_row_pitch = row_pitch;
-        desc.image_slice_pitch = slice_pitch;
-        desc.num_mip_levels = 0;
-        desc.num_samples = 0;
-        desc.buffer = 0;
-        object_ = ::clCreateImage(
-            context(), 
-            flags, 
-            &format, 
-            &desc, 
-            host_ptr, 
-            &error);
+        bool useCreateImage;
 
-        detail::errHandler(error, __CREATE_IMAGE_ERR);
-        if (err != NULL) {
-            *err = error;
+#if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+        // Run-time decision based on the actual platform
+        {
+            cl_uint version = detail::getContextPlatformVersion(context());
+            useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
         }
-#else  // #if defined(CL_VERSION_1_2)
-        object_ = ::clCreateImage3D(
-            context(), flags, &format, width, height, depth, row_pitch,
-            slice_pitch, host_ptr, &error);
+#elif defined(CL_VERSION_1_2)
+        useCreateImage = true;
+#else
+        useCreateImage = false;
+#endif
 
-        detail::errHandler(error, __CREATE_IMAGE3D_ERR);
-        if (err != NULL) {
-            *err = error;
+#if defined(CL_VERSION_1_2)
+        if (useCreateImage)
+        {
+            cl_image_desc desc;
+            desc.image_type = CL_MEM_OBJECT_IMAGE3D;
+            desc.image_width = width;
+            desc.image_height = height;
+            desc.image_depth = depth;
+            desc.image_row_pitch = row_pitch;
+            desc.image_slice_pitch = slice_pitch;
+            desc.num_mip_levels = 0;
+            desc.num_samples = 0;
+            desc.buffer = 0;
+            object_ = ::clCreateImage(
+                context(), 
+                flags, 
+                &format, 
+                &desc, 
+                host_ptr, 
+                &error);
+
+            detail::errHandler(error, __CREATE_IMAGE_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
         }
-#endif // #if defined(CL_VERSION_1_2)
+#endif  // #if defined(CL_VERSION_1_2)
+#if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+        if (!useCreateImage)
+        {
+            object_ = ::clCreateImage3D(
+                context(), flags, &format, width, height, depth, row_pitch,
+                slice_pitch, host_ptr, &error);
+
+            detail::errHandler(error, __CREATE_IMAGE3D_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+        }
+#endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
     }
 
     //! \brief Default constructor - initializes to NULL.
@@ -4229,8 +4311,6 @@ public:
     }
 };
 
-__GET_INFO_HELPER_WITH_RETAIN(cl::Sampler)
-
 class Program;
 class CommandQueue;
 class Kernel;
@@ -4483,8 +4563,6 @@ public:
     }
 };
 
-__GET_INFO_HELPER_WITH_RETAIN(cl::Kernel)
-
 /*! \class Program
  * \brief Program interface that implements cl_program.
  */
@@ -4622,6 +4700,25 @@ public:
         }
     }
 
+    /**
+     * Construct a program object from a list of devices and a per-device list of binaries.
+     * \param context A valid OpenCL context in which to construct the program.
+     * \param devices A vector of OpenCL device objects for which the program will be created.
+     * \param binaries A vector of pairs of a pointer to a binary object and its length.
+     * \param binaryStatus An optional vector that on completion will be resized to
+     *   match the size of binaries and filled with values to specify if each binary
+     *   was successfully loaded.
+     *   Set to CL_SUCCESS if the binary was successfully loaded.
+     *   Set to CL_INVALID_VALUE if the length is 0 or the binary pointer is NULL.
+     *   Set to CL_INVALID_BINARY if the binary provided is not valid for the matching device.
+     * \param err if non-NULL will be set to CL_SUCCESS on successful operation or one of the following errors:
+     *   CL_INVALID_CONTEXT if context is not a valid context.
+     *   CL_INVALID_VALUE if the length of devices is zero; or if the length of binaries does not match the length of devices; 
+     *     or if any entry in binaries is NULL or has length 0.
+     *   CL_INVALID_DEVICE if OpenCL devices listed in devices are not in the list of devices associated with context.
+     *   CL_INVALID_BINARY if an invalid program binary was encountered for any device. binaryStatus will return specific status for each device.
+     *   CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
+     */
     Program(
         const Context& context,
         const VECTOR_CLASS<Device>& devices,
@@ -4630,26 +4727,41 @@ public:
         cl_int* err = NULL)
     {
         cl_int error;
-        const ::size_t n = binaries.size();
-        ::size_t* lengths = (::size_t*) alloca(n * sizeof(::size_t));
-        const unsigned char** images = (const unsigned char**) alloca(n * sizeof(const void*));
+        
+        const ::size_t numDevices = devices.size();
+        
+        // Catch size mismatch early and return
+        if(binaries.size() != numDevices) {
+            error = CL_INVALID_VALUE;
+            detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+            return;
+        }
 
-        for (::size_t i = 0; i < n; ++i) {
-            images[i] = (const unsigned char*)binaries[(int)i].first;
+        ::size_t* lengths = (::size_t*) alloca(numDevices * sizeof(::size_t));
+        const unsigned char** images = (const unsigned char**) alloca(numDevices * sizeof(const unsigned char**));
+
+        for (::size_t i = 0; i < numDevices; ++i) {
+            images[i] = (const unsigned char*)binaries[i].first;
             lengths[i] = binaries[(int)i].second;
         }
 
-        ::size_t numDevices = devices.size();
         cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id));
         for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
             deviceIDs[deviceIndex] = (devices[deviceIndex])();
         }
 
+        if(binaryStatus) {
+            binaryStatus->resize(numDevices);
+        }
+        
         object_ = ::clCreateProgramWithBinary(
             context(), (cl_uint) devices.size(),
             deviceIDs,
             lengths, images, binaryStatus != NULL
-               ? (cl_int*) &binaryStatus->front()
+               ? &binaryStatus->front()
                : NULL, &error);
 
         detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
@@ -4847,7 +4959,7 @@ inline Program linkProgram(
     void* data = NULL,
     cl_int* err = NULL) 
 {
-    cl_int err_local;
+    cl_int err_local = CL_SUCCESS;
 
     cl_program programs[2] = { input1(), input2() };
 
@@ -4864,11 +4976,9 @@ inline Program linkProgram(
         data,
         &err_local);
 
-    if (err_local != CL_SUCCESS) {
-        err_local = detail::errHandler(err_local,__COMPILE_PROGRAM_ERR);
-        if (err != NULL) {
-            *err = err_local;
-        }
+    detail::errHandler(err_local,__COMPILE_PROGRAM_ERR);
+    if (err != NULL) {
+        *err = err_local;
     }
 
     return Program(prog);
@@ -4881,15 +4991,7 @@ inline Program linkProgram(
     void* data = NULL,
     cl_int* err = NULL) 
 {
-    cl_int err_local;
-
-    if (inputPrograms.size() == 0) {
-        err_local = detail::errHandler(CL_INVALID_VALUE,__COMPILE_PROGRAM_ERR);
-        if (err != NULL) {
-            *err = err_local;
-        }
-        return Program();
-    }
+    cl_int err_local = CL_SUCCESS;
 
     cl_program * programs = (cl_program*) alloca(inputPrograms.size() * sizeof(cl_program));
 
@@ -4898,13 +5000,6 @@ inline Program linkProgram(
           programs[i] = inputPrograms[i]();
         }
     } 
-    else {
-        err_local = detail::errHandler(CL_OUT_OF_HOST_MEMORY,__COMPILE_PROGRAM_ERR);
-        if (err != NULL) {
-            *err = err_local;
-        }
-        return Program();
-    }
 
     cl_program prog = ::clLinkProgram(
         Context::getDefault()(),
@@ -4917,11 +5012,9 @@ inline Program linkProgram(
         data,
         &err_local);
 
-    if (err_local != CL_SUCCESS) {
-        err_local = detail::errHandler(err_local,__COMPILE_PROGRAM_ERR);
-        if (err != NULL) {
-            *err = err_local;
-        }
+    detail::errHandler(err_local,__COMPILE_PROGRAM_ERR);
+    if (err != NULL) {
+        *err = err_local;
     }
 
     return Program(prog);
@@ -4948,8 +5041,6 @@ inline VECTOR_CLASS<char *> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* er
     return binaries;
 }
 
-__GET_INFO_HELPER_WITH_RETAIN(cl::Program)
-
 inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
 {
     cl_int error;
@@ -6002,8 +6093,6 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
     }
 };
 
-__GET_INFO_HELPER_WITH_RETAIN(cl::CommandQueue)
-
 #ifdef _WIN32
 __declspec(selectany) volatile int CommandQueue::default_initialized_ = __DEFAULT_NOT_INITIALIZED;
 __declspec(selectany) CommandQueue CommandQueue::default_;
@@ -6171,7 +6260,7 @@ inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Bu
  * Blocking copy operation between iterators and a buffer.
  */
 template< typename IteratorType >
-inline cl_int copy( cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
+inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
 {
     typedef typename std::iterator_traits<IteratorType>::value_type DataType;
     cl_int error;
@@ -6468,7 +6557,6 @@ inline cl_int finish(void)
     return queue.finish();
 }
 
-
 // Kernel Functor support
 // New interface as of September 2011
 // Requires the C++11 std::tr1::function (note do not support TR1)
@@ -6664,7 +6752,6 @@ struct SetArg
     }
 };  
 
-
 template<int index>
 struct SetArg<index, NullType>
 {
@@ -6673,7 +6760,6 @@ struct SetArg<index, NullType>
     }
 };
 
-
 template <
    typename T0,   typename T1,   typename T2,   typename T3,
    typename T4,   typename T5,   typename T6,   typename T7,
@@ -6772,7 +6858,6 @@ public:
         SetArg<30, T30>::set(kernel_, t30);
         SetArg<31, T31>::set(kernel_, t31);
         
-
         args.queue_.enqueueNDRangeKernel(
             kernel_,
             args.offset_,
@@ -6781,7 +6866,6 @@ public:
             &args.events_,
             &event);
         
-
         return event;
     }
 
@@ -12193,8 +12277,6 @@ public:
 #undef __UNLOAD_COMPILER_ERR
 #endif //__CL_USER_OVERRIDE_ERROR_STRINGS
 
-#undef __GET_INFO_HELPER_WITH_RETAIN
-
 #undef __CL_FUNCTION_TYPE
 
 // Extensions
diff --git a/cl_ext.h b/cl_ext.h
index 632cb21..6908b7e 100644
--- a/cl_ext.h
+++ b/cl_ext.h
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008 - 2012 The Khronos Group Inc.
+ * Copyright (c) 2008-2013 The Khronos Group Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and/or associated documentation files (the
@@ -34,10 +34,10 @@ extern "C" {
 #endif
 
 #ifdef __APPLE__
-	#include <OpenCL/cl.h>
+        #include <OpenCL/cl.h>
     #include <AvailabilityMacros.h>
 #else
-	#include <CL/cl.h>
+        #include <CL/cl.h>
 #endif
 
 /* cl_khr_fp16 extension - no extension #define since it has no functions  */
@@ -61,7 +61,7 @@ extern "C" {
  * before using.
  */
 #define cl_APPLE_SetMemObjectDestructor 1
-cl_int	CL_API_ENTRY clSetMemObjectDestructorAPPLE(  cl_mem /* memobj */, 
+cl_int  CL_API_ENTRY clSetMemObjectDestructorAPPLE(  cl_mem /* memobj */, 
                                         void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), 
                                         void * /*user_data */ )             CL_EXT_SUFFIX__VERSION_1_0;  
 
@@ -169,7 +169,6 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /
 #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV            0x4005
 #define CL_DEVICE_INTEGRATED_MEMORY_NV              0x4006
 
-
 /*********************************
 * cl_amd_device_attribute_query *
 *********************************/
@@ -239,7 +238,63 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /
     #define CL_PARTITION_BY_COUNTS_LIST_END_EXT         ((cl_device_partition_property_ext) 0)
     #define CL_PARTITION_BY_NAMES_LIST_END_EXT          ((cl_device_partition_property_ext) 0 - 1)
 
+/*********************************
+* cl_qcom_ext_host_ptr extension
+*********************************/
+
+#define CL_MEM_EXT_HOST_PTR_QCOM                  (1 << 29)
+
+#define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM   0x40A0      
+#define CL_DEVICE_PAGE_SIZE_QCOM                  0x40A1
+#define CL_IMAGE_ROW_ALIGNMENT_QCOM               0x40A2
+#define CL_IMAGE_SLICE_ALIGNMENT_QCOM             0x40A3
+#define CL_MEM_HOST_UNCACHED_QCOM                 0x40A4
+#define CL_MEM_HOST_WRITEBACK_QCOM                0x40A5
+#define CL_MEM_HOST_WRITETHROUGH_QCOM             0x40A6
+#define CL_MEM_HOST_WRITE_COMBINING_QCOM          0x40A7
+
+typedef cl_uint                                   cl_image_pitch_info_qcom;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceImageInfoQCOM(cl_device_id             device,
+                         size_t                   image_width,
+                         size_t                   image_height,
+                         const cl_image_format   *image_format,
+                         cl_image_pitch_info_qcom param_name,
+                         size_t                   param_value_size,
+                         void                    *param_value,
+                         size_t                  *param_value_size_ret);
+
+typedef struct _cl_mem_ext_host_ptr
+{
+    // Type of external memory allocation.
+    // Legal values will be defined in layered extensions.
+    cl_uint  allocation_type;
+            
+    // Host cache policy for this external memory allocation.
+    cl_uint  host_cache_policy;
+
+} cl_mem_ext_host_ptr;
+
+/*********************************
+* cl_qcom_ion_host_ptr extension
+*********************************/
+
+#define CL_MEM_ION_HOST_PTR_QCOM                  0x40A8
+
+typedef struct _cl_mem_ion_host_ptr
+{
+    // Type of external memory allocation.
+    // Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations.
+    cl_mem_ext_host_ptr  ext_host_ptr;
+
+    // ION file descriptor
+    int                  ion_filedesc;
+            
+    // Host pointer to the ION allocated memory
+    void*                ion_hostptr;
 
+} cl_mem_ion_host_ptr;
 
 #endif /* CL_VERSION_1_1 */
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/khronos-opencl-headers.git



More information about the Pkg-opencl-commits mailing list