Skip to content

Commit

Permalink
comment explaining need for getbuffer added to example code
Browse files Browse the repository at this point in the history
  • Loading branch information
grlee77 committed Dec 15, 2014
1 parent 7391cbe commit c489bb5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/demo_struct.py
Expand Up @@ -10,6 +10,12 @@ class DoubleOpStruct:
def __init__(self, array, struct_arr_ptr):
self.data = cuda.to_device(array)
self.shape, self.dtype = array.shape, array.dtype
"""
numpy.getbuffer() needed due to lack of new-style buffer interface for
scalar numpy arrays as of numpy version 1.9.1
see: https://github.com/inducer/pycuda/pull/60
"""
cuda.memcpy_htod(int(struct_arr_ptr),
numpy.getbuffer(numpy.int32(array.size)))
cuda.memcpy_htod(int(struct_arr_ptr) + 8,
Expand Down Expand Up @@ -70,7 +76,7 @@ def __str__(self):
print array1
print array2

if cuda.get_version() < (4, 0):
if cuda.get_version() < (4, ):
func.prepared_call((1, 1), do2_ptr)
else:
func.prepared_call((1, 1), block, do2_ptr)
Expand Down

0 comments on commit c489bb5

Please sign in to comment.