Doing some instructions on some elements of a matrix on GPU memory

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Doing some instructions on some elements of a matrix on GPU memory

elafrit
Hi,

I sent a matrix M on GPU and I need to apply some instructions on a vector from this matrix, for example a vector containing the 3 second elements from this matrix, but without passing by CPU.

thks.
Reply | Threaded
Open this post in threaded view
|

Re: Doing some instructions on some elements of a matrix on GPU memory

Andreas Kloeckner
Hi there,

On Sun, 20 Feb 2011 08:42:36 -0800 (PST), elafrit <[hidden email]> wrote:
> I sent a matrix M on GPU and I need to apply some instructions on a vector
> from this matrix, for example a vector containing the 3 second elements from
> this matrix, but without passing by CPU.

you might be able to do this using ranged elementwise kernels, but in
general, slicing of GPUArrays is not yet supported.

Andreas


_______________________________________________
PyCUDA mailing list
[hidden email]
http://lists.tiker.net/listinfo/pycuda

attachment0 (195 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Doing some instructions on some elements of a matrix on GPU memory

elafrit
Thank you Andreas for your answer,

Instead of slicing, I can't copy the elements that I need in another gpuarray vector for example?
I found this method from Cublas

import pycuda.autoinit
import pycuda.gpuarray as gpuarray
import numpy as np
x = np.random.rand(5).astype(np.float32)
y = np.random.rand(5).astype(np.float32)
x_gpu = gpuarray.to_gpu(x)
y_gpu = gpuarray.to_gpu(y)
d = cublasSdot(x_gpu.size, x_gpu.gpudata, 1, y_gpu.gpudata, 1)
np.allclose(d, np.dot(x, y))

But here both of x_gpu.gpudata points on the first element of the gpuarray x_gpu. Is there any way to point on the element j ?

Thaks again :)