As I wrote in my email from 2012-08-14, I experienced
crashes in image-related functions in test_wrapper.py
on NVIDIA hardware. I managed to find the reason of that
crash and fix it (patch in attachment). Below you can find
explanation.

Unlike all other vendors, NVIDIA still have not released
OpenCL 1.2. Image creation functions have changed in
OpenCL 1.2 - now clCreateImage expects to get cl_image_desc
instead of bunch of arguments like height, width, etc.
PyOpenCL tests in Image constructor (pyopencl/__init__.py,
line 200-ish) whether it is run on OpenCL 1.2 or 1.1,
and runs appropriate code based on this. It uses
get_cl_header_version() for this check which fails in
some situations, e.g. on Debian. In Debian we have opencl-headers
(currently in 1.2), ICD loader (1.2) and ICD implementations
with different versions. This means that headers will always
have version 1.2 (or higher - but it'll be the highest
possible version) but platforms might have lower versions.
This was the case of this segfault. PyOpenCL expected to have
new clImageCreate, ICD loader was ready to give pointer
to this function to PyOpenCL, but platform (NVIDIA)
was not providing it.

I have changed Image constructor to base usage of clCreateImage on
devices' platform version. I assumed that Context always have
at least one device - if not, please change this code.

Best regards.

-- 
Tomasz Rybak <[email protected]> GPG/PGP key ID: 2AD5 9860
Fingerprint A481 824E 7DD3 9C0E C40A  488E C654 FB33 2AD5 9860
http://member.acm.org/~tomaszrybak
diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index 48a0935..64e7d8d 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -199,7 +199,10 @@ class Image(_cl._ImageBase):
         if hostbuf is None and pitches is not None:
             raise Error("'pitches' may only be given if 'hostbuf' is given")
 
-        if get_cl_header_version() >= (1,2):
+        import re
+        version = tuple(int(digit) for digit in re.search('\d+\.\d+',
+                context.devices[0].platform.version).group(0).split('.'))
+        if version >= (1,2):
             if buffer is not None and is_array:
                     raise ValueError("'buffer' and 'is_array' are mutually exclusive")
 

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl

Reply via email to