Hi,
Thanks for the reply Andreas. I tried to start with the custom reduction
example on the documentation (transcribed below), but without success. The
error output is also transcribed. Looks like something is wrong with the
pycuda's installation although my logs were clean.
Any thoughts?
Thank you and kind regards
RL
#######
from pycuda import autoinit
from pycuda import gpuarray, reduction
import numpy
a = gpuarray.arange(400, dtype=numpy.float32)
b = gpuarray.arange(400, dtype=numpy.float32)
krnl = reduction.ReductionKernel(numpy.float32, neutral="0",
reduce_expr="a+b",
map_expr="x[i]*y[i]",
arguments="float *x,
float *y")
my_dot_prod = krnl(a, b).get()
#######
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Users/rmlopes/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pycuda/reduction.py",
line 274, in __call__
kwargs = dict(shared_size=self.block_size*self.dtype_out.itemsize)
TypeError: unsupported operand type(s) for *: 'int' and 'getset_descriptor'
On Nov 2, 2012, at 2:33 AM, Andreas Kloeckner <[email protected]> wrote:
> Rui Lopes <[email protected]> writes:
>> I have a program where I have to perform a dot (scalar product) of an array
>> by a matrix. For e.g., consider the following code snippet:
>>
>> #######
>> from pycuda import autoinit, gpuarray
>> import numpy as np
>>
>> a_cpu = np.array([0, 1], dtype = np.float32)
>> b_cpu = np.array([[0, 1, 2], [0, 1, 2]], dtype = np.float32)
>> dot_cpu = np.dot(a_cpu, b_cpu) #yelds a 1x3 np.array
>>
>> a_gpu = gpuarray.to_gpu(a_cpu)
>> b_gpu = gpuarray.to_gpu(b_cpu)
>> dot_gpu = gpuarray.dot(a_gpu,b_gpu) # yelds a 0d array???
>> ########
>
> GPUArray.dot is only good for vector.vector dot products right now. For
> now, the best advice is to implement a simple mat-vec kernel yourself.
>
>> So, I have two issues:
>> i) How to take the scalar result from dot_gpu?
>> ii) How to obtain the correct result? ( = numpy result)
>>
>> I could do the dot operation over each column, but then it will never
>> outperform the cpu equivalent, am I correct?
>
> Yes.
>
> Andreas
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda