inducer/pycuda — pull request #60 by grlee77 (2014-12-15 19:12:01+00:00)
Title: BUG: fix to demo_struct.py for recent CUDA 4.0+

Hi Andreas,

Thanks, for developing this great package. This is a minor fix to examples/demo_struct.py and the tutorial documentation.

Two things are addressed:
1.) passing a `numpy.int32` (or `numpy.intp`) object as the host data to `cuda.memcpy_htod()` was causing the following error on my system (CUDA v6.5 on 64-bit linux):
```AttributeError: 'np.int32' object has no attribute 'get_buffer'```

A solution is to wrap the int objects with numpy.getbuffer():
``` numpy.getbuffer(numpy.int32(array.size)) ```
using the .data attribute also works:
``` numpy.int32(array.size).data ```
but I think calling `getbuffer()` is a bit clearer

2.) a version check is performed to determine the appropriate way to call the `prepare()` and `prepared_call()` kernel function methods.

The tutorial documentation was updated accordingly, although for the prepared call, I replaced the code with just the CUDA v4.0+ version for brevity. I think that is probably the more comon case at this point (~3.5 years since the CUDA v4.0 release).