[PyCUDA] unsigned short passed as kernel argument

Peter Schmidtke pschmidtke at mmb.pcb.ub.es
Wed Oct 21 13:33:04 PDT 2009


Hello,

you will be happy, I have a rather basic question that, I hope, lots of
people know the answer for...but me :)
I have the following kernel :

>>> mod = SourceModule("""
>>> __global__ void sum_them(float *dest, float *a, float *b,unsigned short
dim1) 
>>>{
>>>  const int i = dim1;//threadIdx.x;
>>>  dest[i] = a[i] + b[i];
>>>}
>>>""")


and I launch it via : 

>>> sum_them = mod.get_function("sum_them")

>>> sum_them(drv.Out(out), drv.In(x), drv.In(y),drv.In(numpy.uint16(0)),
block=(4,1,1), grid=(1, 1))

The kernel has correct access to the data in x,y and writes correctly to
out. But dim1 is not 0, why? Normally the code like this should only fill
up dest[0] and nothing else. 

Another question a bit disconnected from the first one is, if I allocate a
numpy array with zeros (numpy.zeros(4,dtype="float32")) and I run the
kernel without writing actually to all fields in the array dest, why I have
a resulting array that has no 0 element, but some memory crap?

Thanks in advance.

-- 

Peter Schmidtke

----------------------
PhD Student at the Molecular Modeling and Bioinformatics Group
Dep. Physical Chemistry
Faculty of Pharmacy
University of Barcelona





More information about the PyCUDA mailing list