Hi,
I'm trying to bind a 2D gpuarray to a 2Dtexture, then execute a kernel to
read from the texture and write to another gpuarray.
Here's the code I'm using:
import numpy as np
import pycuda.driver as cuda
import pycuda.gpuarray as gpuarray
import pycuda.autoinit
from pycuda.compiler import SourceModule
nWidth = 32
nHeight = 32
cudaCode = SourceModule('''
texture<int, 2 > tex_in;
__global__ void kernel( int *out ){
int t_j = blockIdx.x*blockDim.x + threadIdx.x;
int t_i = blockIdx.y*blockDim.y + threadIdx.y;
int tid = t_j + t_i*blockDim.x*gridDim.x;
int center = tex2D( tex_in, t_j, t_i );
out[tid] = center;
}
''')
block2D = (16,16,1)
grid2D = (nWidth/block2D[0], nHeight/block2D[1], 1)
kernel = cudaCode.get_function("kernel")
tex = cudaCode.get_texref("tex_in")
in_d = gpuarray.to_gpu( 2*np.ones([nWidth, nHeight]).astype(np.int32))
in_d.bind_to_texref(tex)
out_d = gpuarray.to_gpu( np.zeros([nWidth, nHeight]).astype(np.int32))
kernel(out_d, block=block2D, grid=grid2D)
After executing the kernel the resulting gpuarray is unchanged except for
the first COLUMN which has the correct values.
Is there some kind of pitch or descriptor I need to explicitly pass to the
tex_ref or something else that I'm missing?
Thanks in advance
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda