Ask Your Question
0

change GpuMat by CUDA

asked 2018-08-04 10:58:28 -0600

abdorreza gravatar image

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;
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-08-08 02:27:30 -0600

Rado gravatar image

Do the following from the documentation answer your question?

  • no functions that return references to their data (because references on GPU are not valid for CPU)

and

In contrast with Mat, in most cases GpuMat::isContinuous() == false

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-08-04 10:58:28 -0600

Seen: 400 times

Last updated: Aug 08 '18