Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

change GpuMat by CUDA

Hi, I wrote a program for change GpuMat by CUDA in c++. But my CUDA code can not find GpuMat cells correctly and it works wrong. please say how I can access to cells address correctly ?

Main :

GMat_s.upload(MyMat_s);    
Read_Stats << <gridS, blockS >> > ((int*)GMat_s.data, MyMat_s.rows, MyMat_s.cols, GMat_s.step);   GMat_s.download(NewMat_s);

Device (GPU)

__global__ void Read_Stats(int* mt, int h, int w, size_t step)

{
    int x = blockIdx.x * blockDim.x + threadIdx.x;
    int y = blockIdx.y * blockDim.y + threadIdx.y;
        int index = ((w*row) + col);
    mt[index] = 0;
    if (index >= h*w)
        return;
}