-1

I have a set of images that come from a camera and I need to store these images in CUDA device memory and render it using OpenGL. These images have to be stored one after another, contiguously, in a buffer.

The questions I have are:

  1. Let there be 10 images that I need to store in a buffer, how do I do the correct thread assignment?
  2. I want to know if the program I wrote is correct?

I have pasted only the kernel code; I allocated memory for Buffer and EnergyImg in the host code separately:

const unsigned int tidx = blockDim.x * blockIdx.x + threadIdx.x;
const unsigned int tidy = blockDim.y * blockIdx.y + threadIdx.y;

const unsigned int adx =  tidx + tidy * blockDim.x * gridDim.x;

const unsigned int bdx = adx; 

int TotalFrames = 10;

for(int a = 1; a<=TotalFrames; a++)
{

    int SingleFrame = (m_ImageHeight * m_ImageWidth);

    int CurrentFrame = a * (m_ImageHeight * m_ImageWidth);  
    // (first/next) frame is stored till the end of this value

    int PreviousFrame = (a-1) * (m_ImageHeight * m_ImageWidth); 
    // next frame will be stored in memory from the end of previous frame

    if (  (a==1) )
    {               
        if (adx < CurrentFrame)
        {
            Buffer[adx] = EnergyImg[adx];                                                        
        }
    }

    else if((a > 1) && (a <= TotalFrames))
    {
        if( ((adx > PreviousFrame) && (adx <= CurrentFrame)) )
        {
            while ( bdx < SingleFrame)
            { 
                Buffer[adx] = EnergyImg[bdx];                                                                        
            }
        }
    }
}
4

1 に答える 1