From d6652d16ce9ee13cf5c3afa9d8e254c4a2f74312 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Tue, 15 Sep 2015 18:48:05 -0500
Subject: [PATCH] Support for OpenCL 2.0 constants/GetInfo

---
 doc/make_constants.py            |  97 ++++++++++++++++++++-
 pyopencl/cffi_cl.py              |  16 ++++
 setup.py                         |   4 -
 src/c_wrapper/device.cpp         |  98 +++++++++-------------
 src/c_wrapper/device.h           |  18 ----
 src/c_wrapper/kernel.cpp         |   3 +
 src/c_wrapper/memory_object.cpp  |   4 +
 src/c_wrapper/program.cpp        |   5 ++
 src/c_wrapper/sampler.cpp        |   4 +
 src/c_wrapper/wrap_constants.cpp | 140 +++++++++++++++++++++----------
 10 files changed, 262 insertions(+), 127 deletions(-)

diff --git a/doc/make_constants.py b/doc/make_constants.py
index 2d24960c..da5282dc 100644
--- a/doc/make_constants.py
+++ b/doc/make_constants.py
@@ -1,5 +1,5 @@
-from __future__ import absolute_import
-from __future__ import print_function
+from __future__ import absolute_import, print_function
+
 __copyright__ = "Copyright (C) 2009 Andreas Kloeckner"
 
 __license__ = """
@@ -29,6 +29,8 @@ nv_devattr = ("cl_nv_device_attribute_query", "0.92")
 gl_sharing = ("cl_khr_gl_sharing", "0.92")
 cl_11 = ("CL_1.1", "0.92")
 cl_12 = ("CL_1.2", "2011.2")
+cl_12_2015 = ("CL_1.2", "2015.2")
+cl_20 = ("CL_2.0", "2015.2")
 amd_devattr = ("cl_amd_device_attribute_query", "2013.2")
 
 
@@ -72,6 +74,9 @@ const_ext_lookup = {
             "INVALID_LINKER_OPTIONS": cl_12,
             "INVALID_DEVICE_PARTITION_COUNT": cl_12,
 
+            "INVALID_PIPE_SIZE": cl_20,
+            "INVALID_DEVICE_QUEUE": cl_20,
+
             },
 
         cl.device_info: {
@@ -137,6 +142,24 @@ const_ext_lookup = {
             "REFERENCE_COUNT": cl_12,
             "PREFERRED_INTEROP_USER_SYNC": cl_12,
             "PRINTF_BUFFER_SIZE": cl_12,
+
+            "DEVICE_ON_HOST_PROPERTIES": cl_20,
+
+            "MAX_READ_WRITE_IMAGE_ARGS": cl_20,
+            "MAX_GLOBAL_VARIABLE_SIZE": cl_20,
+            "QUEUE_ON_DEVICE_PROPERTIES": cl_20,
+            "QUEUE_ON_DEVICE_PREFERRED_SIZE": cl_20,
+            "QUEUE_ON_DEVICE_MAX_SIZE": cl_20,
+            "MAX_ON_DEVICE_QUEUES": cl_20,
+            "MAX_ON_DEVICE_EVENTS": cl_20,
+            "SVM_CAPABILITIES": cl_20,
+            "GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE": cl_20,
+            "MAX_PIPE_ARGS": cl_20,
+            "PIPE_MAX_ACTIVE_RESERVATIONS": cl_20,
+            "PIPE_MAX_PACKET_SIZE": cl_20,
+            "PREFERRED_PLATFORM_ATOMIC_ALIGNMENT": cl_20,
+            "PREFERRED_GLOBAL_ATOMIC_ALIGNMENT": cl_20,
+            "PREFERRED_LOCAL_ATOMIC_ALIGNMENT": cl_20,
             },
 
         cl.mem_object_type: {
@@ -144,6 +167,8 @@ const_ext_lookup = {
             "IMAGE1D": cl_12,
             "IMAGE1D_ARRAY": cl_12,
             "IMAGE1D_BUFFER": cl_12,
+
+            "PIPE": cl_20,
             },
 
         cl.device_type: {
@@ -166,6 +191,11 @@ const_ext_lookup = {
             "CORRECTLY_ROUNDED_DIVIDE_SQRT": cl_12,
             },
 
+        cl.command_queue_properties: {
+            "ON_DEVICE": cl_20,
+            "ON_DEVICE_DEFAULT": cl_20,
+            },
+
         cl.context_info: {
             "NUM_DEVICES": cl_11,
             "INTEROP_USER_SYNC": cl_12,
@@ -175,6 +205,12 @@ const_ext_lookup = {
             "Rx": cl_11,
             "RGx": cl_11,
             "RGBx": cl_11,
+
+            "sRGB": cl_20,
+            "sRGBx": cl_20,
+            "sRGBA": cl_20,
+            "sBGRA": cl_20,
+            "ABGR": cl_20,
             },
 
         cl.kernel_work_group_info: {
@@ -187,6 +223,12 @@ const_ext_lookup = {
             "MIRRORED_REPEAT": cl_11,
             },
 
+        cl.sampler_info: {
+            "MIP_FILTER_MODE": cl_20,
+            "LOD_MIN": cl_20,
+            "LOD_MAX": cl_20,
+            },
+
         cl.event_info: {
             "CONTEXT": cl_11,
             },
@@ -194,6 +236,8 @@ const_ext_lookup = {
         cl.mem_info: {
             "ASSOCIATED_MEMOBJECT": cl_11,
             "OFFSET": cl_11,
+
+            "USES_SVM_POINTER": cl_20,
             },
 
         cl.image_info: {
@@ -214,6 +258,8 @@ const_ext_lookup = {
 
         cl.program_build_info: {
             "BINARY_TYPE": cl_12,
+
+            "GLOBAL_VARIABLE_TOTAL_SIZE": cl_20,
             },
 
         cl.program_binary_type: {
@@ -231,6 +277,7 @@ const_ext_lookup = {
             "ADDRESS_QUALIFIER": cl_12,
             "ACCESS_QUALIFIER": cl_12,
             "TYPE_NAME": cl_12,
+            "TYPE_QUALIFIER": cl_12_2015,
             "ARG_NAME": cl_12,
             },
 
@@ -248,6 +295,15 @@ const_ext_lookup = {
             "NONE": cl_12,
             },
 
+        cl.kernel_arg_type_qualifier: {
+            "NONE": cl_12_2015,
+            "CONST": cl_12_2015,
+            "RESTRICT": cl_12_2015,
+            "VOLATILE": cl_12_2015,
+
+            "PIPE": cl_20,
+            },
+
         cl.command_type: {
             "READ_BUFFER_RECT": cl_11,
             "WRITE_BUFFER_RECT": cl_11,
@@ -258,12 +314,43 @@ const_ext_lookup = {
             "MIGRATE_MEM_OBJECTS": cl_12,
             "FILL_BUFFER": cl_12,
             "FILL_IMAGE": cl_12,
+
+            "SVM_FREE": cl_20,
+            "SVM_MEMCPY": cl_20,
+            "SVM_MEMFILL": cl_20,
+            "SVM_MAP": cl_20,
+            "SVM_UNMAP": cl_20,
+            },
+
+        cl.command_queue_info: {
+            "SIZE": cl_20,
+            },
+
+        cl.queue_properties: {
+            "PROPERTIES": cl_20,
+            "SIZE": cl_20,
             },
 
         cl.mem_flags: {
             "USE_PERSISTENT_MEM_AMD":
             ("cl_amd_device_memory_flags", "2011.1"),
             "HOST_WRITE_ONLY": cl_12,
+            "KERNEL_READ_AND_WRITE": cl_20,
+            },
+
+        cl.svm_mem_flags: {
+            "READ_WRITE": cl_20,
+            "WRITE_ONLY": cl_20,
+            "READ_ONLY": cl_20,
+            "SVM_FINE_GRAIN_BUFFER": cl_20,
+            "SVM_ATOMICS": cl_20,
+            },
+
+        cl.device_svm_capabilities: {
+            "COARSE_GRAIN_BUFFER": cl_20,
+            "FINE_GRAIN_BUFFER": cl_20,
+            "FINE_GRAIN_SYSTEM": cl_20,
+            "ATOMICS": cl_20,
             },
 
         cl.device_partition_property: {
@@ -305,6 +392,10 @@ const_ext_lookup = {
             "NEXT_FISSIONABLE": fission,
             },
 
+        cl.profiling_info: {
+            "COMPLETE": cl_20,
+            },
+
         cl.mem_migration_flags: {
             "HOST": cl_12,
             "CONTENT_UNDEFINED": cl_12,
@@ -346,7 +437,7 @@ def doc_class(cls):
 
     cls_const_ext = const_ext_lookup.get(cls, {})
     for name in sorted(dir(cls)):
-        if not name.startswith("_") and not name in ["to_string", "names", "values"]:
+        if not name.startswith("_") and name not in ["to_string", "names", "values"]:
             print("    .. attribute :: %s" % name)
 
             if name in cls_const_ext:
diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py
index 8c67c394..28e81794 100644
--- a/pyopencl/cffi_cl.py
+++ b/pyopencl/cffi_cl.py
@@ -295,6 +295,10 @@ class device_exec_capabilities(_NoInit):  # noqa
     pass
 
 
+class device_svm_capabilities(_NoInit):  # noqa
+    pass
+
+
 class command_queue_properties(_NoInit):  # noqa
     pass
 
@@ -315,6 +319,10 @@ class command_queue_info(_NoInit):  # noqa
     pass
 
 
+class queue_properties(_NoInit):  # noqa
+    pass
+
+
 class mem_flags(_NoInit):  # noqa
     @classmethod
     def _writable(cls, flags):
@@ -333,6 +341,10 @@ class mem_flags(_NoInit):  # noqa
         return cls._writable(flags) and cls._hold_host(flags)
 
 
+class svm_mem_flags(_NoInit):  # noqa
+    pass
+
+
 class channel_order(_NoInit):  # noqa
     pass
 
@@ -397,6 +409,10 @@ class kernel_arg_access_qualifier(_NoInit):  # noqa
     pass
 
 
+class kernel_arg_type_qualifier(_NoInit):  # noqa
+    pass
+
+
 class kernel_work_group_info(_NoInit):  # noqa
     pass
 
diff --git a/setup.py b/setup.py
index 306d15f3..52fea857 100644
--- a/setup.py
+++ b/setup.py
@@ -72,8 +72,6 @@ def get_config_schema():
     return ConfigSchema([
         Switch("CL_TRACE", False, "Enable OpenCL API tracing"),
         Switch("CL_ENABLE_GL", False, "Enable OpenCL<->OpenGL interoperability"),
-        Switch("CL_ENABLE_DEVICE_FISSION", True,
-            "Enable device fission extension, if present"),
         Option("CL_PRETEND_VERSION", None,
             "Dotted CL version (e.g. 1.2) which you'd like to use."),
 
@@ -109,8 +107,6 @@ def main():
     if conf["CL_ENABLE_GL"]:
         extra_defines["HAVE_GL"] = 1
 
-    if conf["CL_ENABLE_DEVICE_FISSION"]:
-        extra_defines["PYOPENCL_USE_DEVICE_FISSION"] = 1
     if conf["CL_PRETEND_VERSION"]:
         try:
             major, minor = [int(x) for x in conf["CL_PRETEND_VERSION"].split(".")]
diff --git a/src/c_wrapper/device.cpp b/src/c_wrapper/device.cpp
index 488cc5a6..c4a62a16 100644
--- a/src/c_wrapper/device.cpp
+++ b/src/c_wrapper/device.cpp
@@ -21,17 +21,6 @@ device::~device()
 {
     if (false) {
     }
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-    else if (m_ref_type == REF_FISSION_EXT) {
-#if PYOPENCL_CL_VERSION >= 0x1020
-        cl_platform_id plat;
-        pyopencl_call_guarded_cleanup(clGetDeviceInfo, this, CL_DEVICE_PLATFORM,
-                                      size_arg(plat), nullptr);
-#endif
-        pyopencl_call_guarded_cleanup(
-            pyopencl_get_ext_fun(plat, clReleaseDeviceEXT), this);
-    }
-#endif
 #if PYOPENCL_CL_VERSION >= 0x1020
     else if (m_ref_type == REF_CL_1_2) {
         pyopencl_call_guarded_cleanup(clReleaseDevice, this);
@@ -120,6 +109,7 @@ device::get_info(cl_uint param_name) const
     case CL_DEVICE_EXECUTION_CAPABILITIES:
         return DEV_GET_INT_INF(cl_device_exec_capabilities);
     case CL_DEVICE_QUEUE_PROPERTIES:
+    // same as CL_DEVICE_QUEUE_ON_HOST_PROPERTIES in 2.0
         return DEV_GET_INT_INF(cl_command_queue_properties);
 
     case CL_DEVICE_NAME:
@@ -143,7 +133,7 @@ device::get_info(cl_uint param_name) const
     case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
         return DEV_GET_INT_INF(cl_uint);
 
-    case CL_DEVICE_HOST_UNIFIED_MEMORY:
+    case CL_DEVICE_HOST_UNIFIED_MEMORY: // deprecated in 2.0
         return DEV_GET_INT_INF(cl_bool);
     case CL_DEVICE_OPENCL_C_VERSION:
         return pyopencl_get_str_info(Device, this, param_name);
@@ -159,17 +149,6 @@ device::get_info(cl_uint param_name) const
     case CL_DEVICE_INTEGRATED_MEMORY_NV:
         return DEV_GET_INT_INF(cl_bool);
 #endif
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-    case CL_DEVICE_PARENT_DEVICE_EXT:
-        return pyopencl_get_opaque_info(device, Device, this, param_name);
-    case CL_DEVICE_PARTITION_TYPES_EXT:
-    case CL_DEVICE_AFFINITY_DOMAINS_EXT:
-    case CL_DEVICE_PARTITION_STYLE_EXT:
-        return pyopencl_get_array_info(cl_device_partition_property_ext,
-                                       Device, this, param_name);
-    case CL_DEVICE_REFERENCE_COUNT_EXT:
-        return DEV_GET_INT_INF(cl_uint);
-#endif
 #if PYOPENCL_CL_VERSION >= 0x1020
     case CL_DEVICE_LINKER_AVAILABLE:
         return DEV_GET_INT_INF(cl_bool);
@@ -195,6 +174,42 @@ device::get_info(cl_uint param_name) const
     case CL_DEVICE_PRINTF_BUFFER_SIZE:
         return DEV_GET_INT_INF(cl_bool);
 #endif
+#ifdef cl_khr_image2d_from_buffer
+    case CL_DEVICE_IMAGE_PITCH_ALIGNMENT:
+        return DEV_GET_INT_INF(cl_uint);
+    case CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT:
+        return DEV_GET_INT_INF(cl_uint);
+#endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    case CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS:
+        return DEV_GET_INT_INF(cl_uint);
+    case CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE:
+        return DEV_GET_INT_INF(size_t);
+    case CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES:
+        return DEV_GET_INT_INF(cl_command_queue_properties);
+    case CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE:
+        return DEV_GET_INT_INF(cl_uint);
+    case CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE:
+        return DEV_GET_INT_INF(cl_uint);
+    case CL_DEVICE_MAX_ON_DEVICE_QUEUES:
+        return DEV_GET_INT_INF(cl_uint);
+    case CL_DEVICE_MAX_ON_DEVICE_EVENTS:
+        return DEV_GET_INT_INF(cl_uint);
+    case CL_DEVICE_SVM_CAPABILITIES:
+        return DEV_GET_INT_INF(cl_device_svm_capabilities);
+    case CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE:
+        return DEV_GET_INT_INF(size_t);
+    case CL_DEVICE_MAX_PIPE_ARGS:
+    case CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS:
+    case CL_DEVICE_PIPE_MAX_PACKET_SIZE:
+        return DEV_GET_INT_INF(cl_uint);
+    case CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT:
+    case CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT:
+    case CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT:
+        return DEV_GET_INT_INF(cl_uint);
+#endif
+
+
         // {{{ AMD dev attrs
         //
         // types of AMD dev attrs divined from
@@ -270,28 +285,6 @@ device::create_sub_devices(const cl_device_partition_property *props)
     return buf_to_base<device>(devices, true, device::REF_CL_1_2);
 }
 #endif
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-PYOPENCL_USE_RESULT pyopencl_buf<clobj_t>
-device::create_sub_devices_ext(const cl_device_partition_property_ext *props)
-{
-#if PYOPENCL_CL_VERSION >= 0x1020
-    cl_platform_id plat;
-    pyopencl_call_guarded(clGetDeviceInfo, this, CL_DEVICE_PLATFORM,
-                          size_arg(plat), nullptr);
-#endif
-    auto clCreateSubDevicesEXT =
-        pyopencl_get_ext_fun(plat, clCreateSubDevicesEXT);
-
-    // TODO debug print props
-    cl_uint num_devices;
-    pyopencl_call_guarded(clCreateSubDevicesEXT, this, props, 0, nullptr,
-                          buf_arg(num_devices));
-    pyopencl_buf<cl_device_id> devices(num_devices);
-    pyopencl_call_guarded(clCreateSubDevicesEXT, this, props, devices,
-                          buf_arg(num_devices));
-    return buf_to_base<device>(devices, true, device::REF_FISSION_EXT);
-}
-#endif
 
 // c wrapper
 
@@ -309,18 +302,3 @@ device__create_sub_devices(clobj_t _dev, clobj_t **_devs,
         });
 }
 #endif
-
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-error*
-device__create_sub_devices_ext(clobj_t _dev, clobj_t **_devs,
-                               uint32_t *num_devices,
-                               const cl_device_partition_property_ext *props)
-{
-    auto dev = static_cast<device*>(_dev);
-    return c_handle_error([&] {
-            auto devs = dev->create_sub_devices_ext(props);
-            *num_devices = (uint32_t)devs.len();
-            *_devs = devs.release();
-        });
-}
-#endif
diff --git a/src/c_wrapper/device.h b/src/c_wrapper/device.h
index 06180007..a74ce5a5 100644
--- a/src/c_wrapper/device.h
+++ b/src/c_wrapper/device.h
@@ -16,7 +16,6 @@ public:
     PYOPENCL_DEF_CL_CLASS(DEVICE);
     enum reference_type_t {
         REF_NOT_OWNABLE,
-        REF_FISSION_EXT,
         REF_CL_1_2,
     };
 
@@ -32,18 +31,6 @@ public:
         if (retain && ref_type != REF_NOT_OWNABLE) {
             if (false) {
             }
-#if (defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION))
-            else if (ref_type == REF_FISSION_EXT) {
-#if PYOPENCL_CL_VERSION >= 0x1020
-                cl_platform_id plat;
-                pyopencl_call_guarded(clGetDeviceInfo, this,
-                                      CL_DEVICE_PLATFORM, size_arg(plat),
-                                      nullptr);
-#endif
-                pyopencl_call_guarded(
-                    pyopencl_get_ext_fun(plat, clRetainDeviceEXT), this);
-            }
-#endif
 #if PYOPENCL_CL_VERSION >= 0x1020
             else if (ref_type == REF_CL_1_2) {
                 pyopencl_call_guarded(clRetainDevice, this);
@@ -65,11 +52,6 @@ public:
     PYOPENCL_USE_RESULT pyopencl_buf<clobj_t>
     create_sub_devices(const cl_device_partition_property *props);
 #endif
-
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-    PYOPENCL_USE_RESULT pyopencl_buf<clobj_t>
-    create_sub_devices_ext(const cl_device_partition_property_ext *props);
-#endif
 };
 
 extern template void print_clobj<device>(std::ostream&, const device*);
diff --git a/src/c_wrapper/kernel.cpp b/src/c_wrapper/kernel.cpp
index 246376ab..80ab8c5a 100644
--- a/src/c_wrapper/kernel.cpp
+++ b/src/c_wrapper/kernel.cpp
@@ -76,6 +76,9 @@ kernel::get_arg_info(cl_uint idx, cl_kernel_arg_info param) const
     case CL_KERNEL_ARG_ACCESS_QUALIFIER:
         return pyopencl_get_int_info(cl_kernel_arg_access_qualifier,
                                      KernelArg, this, idx, param);
+    case CL_KERNEL_ARG_TYPE_QUALIFIER:
+        return pyopencl_get_int_info(cl_kernel_arg_type_qualifier,
+                                     KernelArg, this, idx, param);
     case CL_KERNEL_ARG_TYPE_NAME:
     case CL_KERNEL_ARG_NAME:
         return pyopencl_get_str_info(KernelArg, this, idx, param);
diff --git a/src/c_wrapper/memory_object.cpp b/src/c_wrapper/memory_object.cpp
index bc178d5d..98e8fbe5 100644
--- a/src/c_wrapper/memory_object.cpp
+++ b/src/c_wrapper/memory_object.cpp
@@ -49,6 +49,10 @@ memory_object::get_info(cl_uint param_name) const
     case CL_MEM_OFFSET:
         return pyopencl_get_int_info(size_t, MemObject, this, param_name);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    case CL_MEM_USES_SVM_POINTER:
+        return pyopencl_get_int_info(cl_bool, MemObject, this, param_name);
+#endif
 
     default:
         throw clerror("MemoryObject.get_info", CL_INVALID_VALUE);
diff --git a/src/c_wrapper/program.cpp b/src/c_wrapper/program.cpp
index 893d01f9..6aac02f1 100644
--- a/src/c_wrapper/program.cpp
+++ b/src/c_wrapper/program.cpp
@@ -88,6 +88,11 @@ program::get_build_info(const device *dev, cl_program_build_info param) const
     case CL_PROGRAM_BINARY_TYPE:
         return pyopencl_get_int_info(cl_program_binary_type, ProgramBuild,
                                      this, dev, param);
+#endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    case CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE:
+        return pyopencl_get_int_info(size_t, ProgramBuild,
+                                     this, dev, param);
 #endif
     default:
         throw clerror("Program.get_build_info", CL_INVALID_VALUE);
diff --git a/src/c_wrapper/sampler.cpp b/src/c_wrapper/sampler.cpp
index 3e260ef3..ee2e90cf 100644
--- a/src/c_wrapper/sampler.cpp
+++ b/src/c_wrapper/sampler.cpp
@@ -29,6 +29,10 @@ sampler::get_info(cl_uint param_name) const
     case CL_SAMPLER_NORMALIZED_COORDS:
         return pyopencl_get_int_info(cl_bool, Sampler, this, param_name);
 
+#if PYOPENCL_CL_VERSION >= 0x2000
+    // TODO: MIP_FILTER_MODE, LOD_MIN, LOD_MAX
+#endif
+
     default:
         throw clerror("Sampler.get_info", CL_INVALID_VALUE);
     }
diff --git a/src/c_wrapper/wrap_constants.cpp b/src/c_wrapper/wrap_constants.cpp
index fa0695a6..0685b1f5 100644
--- a/src/c_wrapper/wrap_constants.cpp
+++ b/src/c_wrapper/wrap_constants.cpp
@@ -91,13 +91,11 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("status_code", , INVALID_DEVICE_PARTITION_COUNT);
 #endif
 
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-    ADD_ATTR("status_code", , DEVICE_PARTITION_FAILED_EXT);
-    ADD_ATTR("status_code", , INVALID_PARTITION_COUNT_EXT);
-    ADD_ATTR("status_code", , INVALID_PARTITION_NAME_EXT);
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("status_code", , INVALID_PIPE_SIZE);
+    ADD_ATTR("status_code", , INVALID_DEVICE_QUEUE);
 #endif
 
-
     // platform_info
     ADD_ATTR("platform_info", PLATFORM_, PROFILE);
     ADD_ATTR("platform_info", PLATFORM_, VERSION);
@@ -169,6 +167,9 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("device_info", DEVICE_, COMPILER_AVAILABLE);
     ADD_ATTR("device_info", DEVICE_, EXECUTION_CAPABILITIES);
     ADD_ATTR("device_info", DEVICE_, QUEUE_PROPERTIES);
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("device_info", DEVICE_, QUEUE_ON_HOST_PROPERTIES);
+#endif
     ADD_ATTR("device_info", DEVICE_, NAME);
     ADD_ATTR("device_info", DEVICE_, VENDOR);
     ADD_ATTR("device_info", , DRIVER_VERSION);
@@ -178,7 +179,7 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("device_info", DEVICE_, PLATFORM);
 #if PYOPENCL_CL_VERSION >= 0x1010
     ADD_ATTR("device_info", DEVICE_, PREFERRED_VECTOR_WIDTH_HALF);
-    ADD_ATTR("device_info", DEVICE_, HOST_UNIFIED_MEMORY);
+    ADD_ATTR("device_info", DEVICE_, HOST_UNIFIED_MEMORY); // deprecated in 2.0
     ADD_ATTR("device_info", DEVICE_, NATIVE_VECTOR_WIDTH_CHAR);
     ADD_ATTR("device_info", DEVICE_, NATIVE_VECTOR_WIDTH_SHORT);
     ADD_ATTR("device_info", DEVICE_, NATIVE_VECTOR_WIDTH_INT);
@@ -240,13 +241,6 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
 #ifdef CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT
     ADD_ATTR("device_info", DEVICE_, MAX_ATOMIC_COUNTERS_EXT);
 #endif
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-    ADD_ATTR("device_info", DEVICE_, PARENT_DEVICE_EXT);
-    ADD_ATTR("device_info", DEVICE_, PARTITION_TYPES_EXT);
-    ADD_ATTR("device_info", DEVICE_, AFFINITY_DOMAINS_EXT);
-    ADD_ATTR("device_info", DEVICE_, REFERENCE_COUNT_EXT);
-    ADD_ATTR("device_info", DEVICE_, PARTITION_STYLE_EXT);
-#endif
 #if PYOPENCL_CL_VERSION >= 0x1020
     ADD_ATTR("device_info", DEVICE_, LINKER_AVAILABLE);
     ADD_ATTR("device_info", DEVICE_, BUILT_IN_KERNELS);
@@ -265,6 +259,23 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("device_info", DEVICE_, IMAGE_PITCH_ALIGNMENT);
     ADD_ATTR("device_info", DEVICE_, IMAGE_BASE_ADDRESS_ALIGNMENT);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("device_info", DEVICE_, MAX_READ_WRITE_IMAGE_ARGS);
+    ADD_ATTR("device_info", DEVICE_, MAX_GLOBAL_VARIABLE_SIZE);
+    ADD_ATTR("device_info", DEVICE_, QUEUE_ON_DEVICE_PROPERTIES);
+    ADD_ATTR("device_info", DEVICE_, QUEUE_ON_DEVICE_PREFERRED_SIZE);
+    ADD_ATTR("device_info", DEVICE_, QUEUE_ON_DEVICE_MAX_SIZE);
+    ADD_ATTR("device_info", DEVICE_, MAX_ON_DEVICE_QUEUES);
+    ADD_ATTR("device_info", DEVICE_, MAX_ON_DEVICE_EVENTS);
+    ADD_ATTR("device_info", DEVICE_, SVM_CAPABILITIES);
+    ADD_ATTR("device_info", DEVICE_, GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE);
+    ADD_ATTR("device_info", DEVICE_, MAX_PIPE_ARGS);
+    ADD_ATTR("device_info", DEVICE_, PIPE_MAX_ACTIVE_RESERVATIONS);
+    ADD_ATTR("device_info", DEVICE_, PIPE_MAX_PACKET_SIZE);
+    ADD_ATTR("device_info", DEVICE_, PREFERRED_PLATFORM_ATOMIC_ALIGNMENT);
+    ADD_ATTR("device_info", DEVICE_, PREFERRED_GLOBAL_ATOMIC_ALIGNMENT);
+    ADD_ATTR("device_info", DEVICE_, PREFERRED_LOCAL_ATOMIC_ALIGNMENT);
+#endif
 
 
     // device_fp_config
@@ -300,6 +311,14 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("device_exec_capabilities", EXEC_, IMMEDIATE_EXECUTION_INTEL);
 #endif
 
+#if PYOPENCL_CL_VERSION >= 0x2000
+    // device_svm_capabilities
+    ADD_ATTR("device_svm_capabilities", DEVICE_SVM_, COARSE_GRAIN_BUFFER);
+    ADD_ATTR("device_svm_capabilities", DEVICE_SVM_, FINE_GRAIN_BUFFER);
+    ADD_ATTR("device_svm_capabilities", DEVICE_SVM_, FINE_GRAIN_SYSTEM);
+    ADD_ATTR("device_svm_capabilities", DEVICE_SVM_, ATOMICS);
+#endif
+
 
     // command_queue_properties
     ADD_ATTR("command_queue_properties", QUEUE_, OUT_OF_ORDER_EXEC_MODE_ENABLE);
@@ -307,6 +326,10 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
 #ifdef CL_QUEUE_IMMEDIATE_EXECUTION_ENABLE_INTEL
     ADD_ATTR("command_queue_properties", QUEUE_, IMMEDIATE_EXECUTION_ENABLE_INTEL);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("command_queue_properties", QUEUE_, ON_DEVICE);
+    ADD_ATTR("command_queue_properties", QUEUE_, ON_DEVICE_DEFAULT);
+#endif
 
 
     // context_info
@@ -352,6 +375,13 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("command_queue_info", QUEUE_, PROPERTIES);
 
 
+    // queue_properties
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("queue_properties", QUEUE_, PROPERTIES);
+    ADD_ATTR("queue_properties", QUEUE_, SIZE);
+#endif
+
+
     // mem_flags
     ADD_ATTR("mem_flags", MEM_, READ_WRITE);
     ADD_ATTR("mem_flags", MEM_, WRITE_ONLY);
@@ -367,6 +397,17 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("mem_flags", MEM_, HOST_READ_ONLY);
     ADD_ATTR("mem_flags", MEM_, HOST_NO_ACCESS);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("mem_flags", MEM_, KERNEL_READ_AND_WRITE);
+#endif
+
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("svm_mem_flags", MEM_, READ_WRITE);
+    ADD_ATTR("svm_mem_flags", MEM_, WRITE_ONLY);
+    ADD_ATTR("svm_mem_flags", MEM_, READ_ONLY);
+    ADD_ATTR("svm_mem_flags", MEM_, SVM_FINE_GRAIN_BUFFER);
+    ADD_ATTR("svm_mem_flags", MEM_, SVM_ATOMICS);
+#endif
 
 
     // channel_order
@@ -384,6 +425,13 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("channel_order",  , RGx);
     ADD_ATTR("channel_order",  , RGBx);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("channel_order",  , sRGB);
+    ADD_ATTR("channel_order",  , sRGBx);
+    ADD_ATTR("channel_order",  , sRGBA);
+    ADD_ATTR("channel_order",  , sBGRA);
+    ADD_ATTR("channel_order",  , ABGR);
+#endif
 
 
     // channel_type
@@ -414,6 +462,9 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("mem_object_type", MEM_OBJECT_, IMAGE1D_ARRAY);
     ADD_ATTR("mem_object_type", MEM_OBJECT_, IMAGE1D_BUFFER);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("mem_object_type", MEM_OBJECT_, PIPE);
+#endif
 
 
     // mem_info
@@ -428,6 +479,9 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("mem_info", MEM_, ASSOCIATED_MEMOBJECT);
     ADD_ATTR("mem_info", MEM_, OFFSET);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("mem_info", MEM_, USES_SVM_POINTER);
+#endif
 
 
     // image_info
@@ -467,6 +521,11 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("sampler_info", SAMPLER_, NORMALIZED_COORDS);
     ADD_ATTR("sampler_info", SAMPLER_, ADDRESSING_MODE);
     ADD_ATTR("sampler_info", SAMPLER_, FILTER_MODE);
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("sampler_info", SAMPLER_, MIP_FILTER_MODE);
+    ADD_ATTR("sampler_info", SAMPLER_, LOD_MIN);
+    ADD_ATTR("sampler_info", SAMPLER_, LOD_MAX);
+#endif
 
 
     // map_flags
@@ -498,6 +557,9 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
 #if PYOPENCL_CL_VERSION >= 0x1020
     ADD_ATTR("program_build_info", PROGRAM_, BINARY_TYPE);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("program_build_info", PROGRAM_BUILD_, GLOBAL_VARIABLE_TOTAL_SIZE);
+#endif
 
 
     // program_binary_type
@@ -525,6 +587,7 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("kernel_arg_info", KERNEL_ARG_, ADDRESS_QUALIFIER);
     ADD_ATTR("kernel_arg_info", KERNEL_ARG_, ACCESS_QUALIFIER);
     ADD_ATTR("kernel_arg_info", KERNEL_ARG_, TYPE_NAME);
+    ADD_ATTR("kernel_arg_info", KERNEL_ARG_, TYPE_QUALIFIER);
     ADD_ATTR("kernel_arg_info", KERNEL_ARG_, NAME);
 #endif
 
@@ -547,6 +610,18 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
 #endif
 
 
+    // kernel_arg_type_qualifier
+#if PYOPENCL_CL_VERSION >= 0x1020
+    ADD_ATTR("kernel_arg_type_qualifier", KERNEL_ARG_TYPE_, NONE);
+    ADD_ATTR("kernel_arg_type_qualifier", KERNEL_ARG_TYPE_, CONST);
+    ADD_ATTR("kernel_arg_type_qualifier", KERNEL_ARG_TYPE_, RESTRICT);
+    ADD_ATTR("kernel_arg_type_qualifier", KERNEL_ARG_TYPE_, VOLATILE);
+#endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("kernel_arg_type_qualifier", KERNEL_ARG_TYPE_, PIPE);
+#endif
+
+
     // kernel_work_group_info
     ADD_ATTR("kernel_work_group_info", KERNEL_, WORK_GROUP_SIZE);
     ADD_ATTR("kernel_work_group_info", KERNEL_, COMPILE_WORK_GROUP_SIZE);
@@ -603,6 +678,13 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("command_type", COMMAND_, FILL_BUFFER);
     ADD_ATTR("command_type", COMMAND_, FILL_IMAGE);
 #endif
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("command_type", COMMAND_, SVM_FREE);
+    ADD_ATTR("command_type", COMMAND_, SVM_MEMCPY);
+    ADD_ATTR("command_type", COMMAND_, SVM_MEMFILL);
+    ADD_ATTR("command_type", COMMAND_, SVM_MAP);
+    ADD_ATTR("command_type", COMMAND_, SVM_UNMAP);
+#endif
 
 
     // command_execution_status
@@ -617,6 +699,9 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
     ADD_ATTR("profiling_info", PROFILING_COMMAND_, SUBMIT);
     ADD_ATTR("profiling_info", PROFILING_COMMAND_, START);
     ADD_ATTR("profiling_info", PROFILING_COMMAND_, END);
+#if PYOPENCL_CL_VERSION >= 0x2000
+    ADD_ATTR("profiling_info", PROFILING_COMMAND_, COMPLETE);
+#endif
 
 
     // mem_migration_flags
@@ -634,35 +719,6 @@ void populate_constants(void(*add)(const char*, const char*, int64_t value))
 #endif
 
 
-    // device_partition_property_ext
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-    ADD_ATTR("device_partition_property_ext",
-             DEVICE_PARTITION_, EQUALLY, _EXT);
-    ADD_ATTR("device_partition_property_ext",
-             DEVICE_PARTITION_, BY_COUNTS, _EXT);
-    ADD_ATTR("device_partition_property_ext",
-             DEVICE_PARTITION_, BY_NAMES, _EXT);
-    ADD_ATTR("device_partition_property_ext",
-             DEVICE_PARTITION_, BY_AFFINITY_DOMAIN, _EXT);
-    ADD_ATTR("device_partition_property_ext", , PROPERTIES_LIST_END, _EXT);
-    ADD_ATTR("device_partition_property_ext", ,
-             PARTITION_BY_COUNTS_LIST_END, _EXT);
-    ADD_ATTR("device_partition_property_ext", ,
-             PARTITION_BY_NAMES_LIST_END, _EXT);
-#endif
-
-
-    // affinity_domain_ext
-#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION)
-    ADD_ATTR("affinity_domain_ext", AFFINITY_DOMAIN_, L1_CACHE, _EXT);
-    ADD_ATTR("affinity_domain_ext", AFFINITY_DOMAIN_, L2_CACHE, _EXT);
-    ADD_ATTR("affinity_domain_ext", AFFINITY_DOMAIN_, L3_CACHE, _EXT);
-    ADD_ATTR("affinity_domain_ext", AFFINITY_DOMAIN_, L4_CACHE, _EXT);
-    ADD_ATTR("affinity_domain_ext", AFFINITY_DOMAIN_, NUMA, _EXT);
-    ADD_ATTR("affinity_domain_ext", AFFINITY_DOMAIN_, NEXT_FISSIONABLE, _EXT);
-#endif
-
-
     // device_partition_property
 #if PYOPENCL_CL_VERSION >= 0x1020
     ADD_ATTR("device_partition_property", DEVICE_PARTITION_, EQUALLY);
-- 
GitLab