Comparing memory blocks

Hi all,

I’m quite new to CUDA programming and SMP architectures so I hope this question is not too stupid ;-)

I want to do the following:

I have to images both residing on the graphic cards memory. I want to use CUDA now to compare those images pixelwise. So what i thought of was spliting the images in small blocks and let them be compared in parallel. Now i was wondering if there was a function ind Cuda or Cublas which for example takes two blocks of a specified sizes and compares them to each other and then returns true or false.

Any help is appreciated. Thx

Stefan

There is no such function in CUDA. But that should be a pretty simple kernel to write. If you fetch each image pixel just once, you don’t even have to use shared memory. So, just copy your images from host to the device (card) and run your kernel. You’ll have to collect the T/F replies from the threadblocks. Depending on your needs, you can do that either on the host or on the device (use scan-like code for highest performance, see SDK sample).

Paulius

There is no function provided in CUDA to compare images, but your approach is basically correct.

The most efficient method would be to split the image into blocks and have each thread compare it’s pixel with the pixel of the other image in parallel, writing the results to shared memory. Then perform a sum reduction in shared memory to get a measure of the total difference for each block, and write the results to global memory.

You might want to consider using textures for the image lookups.