From e34a7592fadcbdb3707a1c5fa6b5aeb3e662f5d4 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sun, 27 Jun 2010 20:19:41 -0400
Subject: [PATCH] Pretend to have support for cl_nv_device_attribute_query.

---
 doc/make_constants.py   | 14 ++++++++++++++
 doc/source/misc.rst     |  4 ++++
 src/wrapper/wrap_cl.cpp | 10 ++++++++++
 src/wrapper/wrap_cl.hpp |  2 ++
 4 files changed, 30 insertions(+)

diff --git a/doc/make_constants.py b/doc/make_constants.py
index 245898d9..3e92d05e 100644
--- a/doc/make_constants.py
+++ b/doc/make_constants.py
@@ -43,6 +43,20 @@ const_ext_lookup = {
             getattr(devi, "NATIVE_VECTOR_WIDTH_DOUBLE", None): ("CL_1.1", "0.92"),
             getattr(devi, "NATIVE_VECTOR_WIDTH_HALF", None): ("CL_1.1", "0.92"),
             getattr(devi, "OPENCL_C_VERSION", None): ("CL_1.1", "0.92"),
+            getattr(devi, "COMPUTE_CAPABILITY_MAJOR_NV", None):
+            ("cl_nv_device_attribute_query", "0.92"),
+            getattr(devi, "COMPUTE_CAPABILITY_MINOR_NV", None):
+            ("cl_nv_device_attribute_query", "0.92"),
+            getattr(devi, "REGISTERS_PER_BLOCK_NV", None):
+            ("cl_nv_device_attribute_query", "0.92"),
+            getattr(devi, "WARP_SIZE_NV", None):
+            ("cl_nv_device_attribute_query", "0.92"),
+            getattr(devi, "GPU_OVERLAP_NV", None):
+            ("cl_nv_device_attribute_query", "0.92"),
+            getattr(devi, "KERNEL_EXEC_TIMEOUT_NV", None):
+            ("cl_nv_device_attribute_query", "0.92"),
+            getattr(devi, "INTEGRATED_MEMORY_NV", None):
+            ("cl_nv_device_attribute_query", "0.92"),
             },
 
         ctxp: {
diff --git a/doc/source/misc.rst b/doc/source/misc.rst
index e75fe7a0..56ce060c 100644
--- a/doc/source/misc.rst
+++ b/doc/source/misc.rst
@@ -81,6 +81,10 @@ Version 0.92
 * The call signature of :meth:`pyopencl.Kernel.__call__` changed to
   emphasize the importance of *loccal_size*.
 * Add :meth:`pyopencl.Kernel.set_scalar_arg_dtypes`.
+* Add support for the
+  `cl_nv_device_attribute_query <ghttp://www.khronos.org/registry/cl/extensions/khr/cl_nv_device_attribute_query.txt>`_
+  extension.
+
 
 Version 0.91.5
 --------------
diff --git a/src/wrapper/wrap_cl.cpp b/src/wrapper/wrap_cl.cpp
index 55d855dc..7604e3c3 100644
--- a/src/wrapper/wrap_cl.cpp
+++ b/src/wrapper/wrap_cl.cpp
@@ -183,6 +183,16 @@ BOOST_PYTHON_MODULE(_cl)
     ADD_ATTR(DEVICE_, NATIVE_VECTOR_WIDTH_DOUBLE);
     ADD_ATTR(DEVICE_, NATIVE_VECTOR_WIDTH_HALF);
     ADD_ATTR(DEVICE_, OPENCL_C_VERSION);
+#endif
+// support for cl_nv_device_attribute_query
+#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
+    ADD_ATTR(DEVICE_, COMPUTE_CAPABILITY_MAJOR_NV);
+    ADD_ATTR(DEVICE_, COMPUTE_CAPABILITY_MINOR_NV);
+    ADD_ATTR(DEVICE_, REGISTERS_PER_BLOCK_NV);
+    ADD_ATTR(DEVICE_, WARP_SIZE_NV);
+    ADD_ATTR(DEVICE_, GPU_OVERLAP_NV);
+    ADD_ATTR(DEVICE_, KERNEL_EXEC_TIMEOUT_NV);
+    ADD_ATTR(DEVICE_, INTEGRATED_MEMORY_NV);
 #endif
   }
 
diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp
index 5567c02e..7ae60dd5 100644
--- a/src/wrapper/wrap_cl.hpp
+++ b/src/wrapper/wrap_cl.hpp
@@ -17,6 +17,8 @@
 
 // elsewhere ------------------------------------------------------------------
 #include <CL/cl.h>
+// FIXME: Nvidia doesn't install cl_ext.h by default. Grr.
+// #include <CL/cl_ext.h>
 #ifdef HAVE_GL
 #include <GL/gl.h>
 #include <CL/cl_gl.h>
-- 
GitLab