Hello,
I want work with matrix in C++/CUDA. I wrote this program for pass matrix to GPU by CUDA. I want pass Matrix as a set of 30x30 blocks to GPU. Is it right ? and how I can send only special matrix items to GPU ? For example items that have even column number in MyMat matrix.
Main :
#define BX 30
#define BY 30
#define DX 1920
#define DY 1080
Mat MyMat(1080, 1920, CV_32SC1);
cuda::GpuMat GMat;
GpuMat.upload(MyMat);
dim3 block(BX, BY);
dim3 grid((DX + block.x - 1) / block.x, (DY + block.y - 1) / block.y);
Read_MAT << <grid, block >> > ((int *)GMat.data, MyMat.rows, MyMat.cols); //Kernel invocation
Device :
__global__ void Read_MAT(int* mt, int h, int w)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
int index = ((w*row) + col);
mt[index] = 0;
if (index >= h*w)
return;
}