Hi Andreas,
That is a seriously rapid response! I think this is the minimal code example
that reproduces the problem, probably I am making a mistake somewhere in the
syntax:
import pycuda.gpuarray
from pycuda.compiler import SourceModule
import pycuda.autoinit
——————
cuda_source = r'''
__global__ void cuda_function(float3 input)
{
float3 result = make_float3(input.x, input.y, input.z);
}
'''
mod = SourceModule(cuda_source, cache_dir=False, keep=False)
kernel = mod.get_function("cuda_function")
arg_types = [pycuda.gpuarray.vec.float3]
kernel.prepare(arg_types)
kernel.prepared_call((1, 1, 1), (1, 1, 1), pycuda.gpuarray.vec.make_float3(0.0,
1.0, 2.0))
——————
The resulting error comes in the pack call inside prepared_call:
Traceback (most recent call last):
File "float3_test.py", line 18, in <module>
kernel.prepared_call((1, 1, 1), (1, 1, 1),
pycuda.gpuarray.vec.make_float3(0.0, 1.0, 2.0))
File
"/Users/ben/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pycuda-2013.1.1-py2.7-macosx-10.6-x86_64.egg/pycuda/driver.py",
line 426, in function_prepared_call
arg_buf = pack(func.arg_format, *args)
TypeError: cannot convert to an int; scalar object is not a number
Any help gratefully received.
Ben
On 27 Nov 2013, at 17:47, Andreas Kloeckner
<[email protected]<mailto:[email protected]>> wrote:
Hi Ben,
Rowland Ben
<[email protected]<mailto:[email protected]>> writes:
Just started working with PyCUDA, and already very taken with it, it makes a
whole load of things very simple. Already after a couple of days I have a
working program with OpenGL interop using PySide to provide the GUI and CUDA
doing 3D texture lookups. One thing I haven’t been able to figure out yet
though is how to pass vector arguments to CUDA kernels. I have a function
definition like this:
__global__ void extract_slice(uchar4 *destPbo,
unsigned int width,
unsigned int height,
float3 center,
float3 xDelta,
float3 yDelta)
but I can’t make this work with pycuda passing in float3 variables like this:
self.kernel.prepared_call(grid_dimensions, (16, 16, 1),
target_mapping.device_ptr(),
self.width(),
self.height(),
pycuda.gpuarray.vec.make_float3(0.0, 0.0, 0.0),
pycuda.gpuarray.vec.make_float3(1.0, 0.0, 0.0),
pycuda.gpuarray.vec.make_float3(0.0, 1.0, 0.0)
)
so instead I have had to resort to just passing in 9 floats instead of
3 float3 variables, these are then reconstructed into float3s in the
kernel and everything works correctly. While this is a solution for
the moment I would really like to figure out how to pass vector types
like this, and if anyone can point me in the right direction it would
be much appreciated.
Does passing the vector types to prepare() not work? If so, submit a
snippet that reproduces the issue, and we'll get it fixed.
Andreas
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda