SIFT implmentation on CUDA

Hi,
I am in the process (just begun) of coding the SIFT algorithm in CUDA. I use C# for the user to add images to the application.
So far I have managed to covert the image to a 2D double array on the host side. What I wish to do is to have one thread do the SIFT computations for one image, i.e one 2D array, thereby allowing separate threads to process separate images. Furthermore I hope to pass all the image data to the device by using a 3D array, where the row and column will contain the normalized pixel values for each image, which is identified by the 3rd dimension.

At the moment I am having difficulty in passing a 2D/3D array to the device. Any advice would be most appreciated.

Furthermore any comments, suggestions on the above mentioned method would be helpful.

Thanks in advance.

Regards,
iat

What is SIFT? Can u plz brief me?

How are you creating the array in C#? It supports both “normal” arrays and jagged arrays. If you are using the latter, I could see how that might be a problem when you are copying the data over.

Also, what kind of difficulties are you having, specifically?

Hi dlmeetei,

SIFT or Scale-invariant feature transform is an algorithm in computer vision. You can read more about it here

http://en.wikipedia.org/wiki/Scale-invaria…ature_transform

Regards,

iat

Hi profquail,

At the moment I am having issues with two things.

    1. I am using an external cuda dll to interop C# and CUDA. I have managed to normalize the pixel values and store them in a 2D double array.

        Since the 2D array is represented as an object in C# I am having difficulty in passing the 2D array to the cuda dll

This is how I declare the 2D array in C#

double[,] imagedata = new double[b.Width, b.Height];
  1. I require to pass a 2D double array to one of my global functions. I am having some issues working with pointers and the various methods

         available in cuda to do this.
    

Any help/advice is very much appreciated.

Regards,

iat

Passing a .NET array to CUDA isn’t trivial. A C array is basically a pointer to the first element. What you have in C# are not pointers, you use references or handles. They differ from pointers fundamentally by the fact that the memory lies in managed memory and the garbage collector is free to relocate the data to avoid fragmentation etc. (whether it actually does that, I don’t know). So, even if you got to the “low level” pointer to a managed data structure, the data might get moved in the middle of your computation. Handles/references are automagically updated to follow GC, pointers aren’t.

Now I’m pretty sure there’s a way to lock managed memory in place to ensure GC doesn’t screw with it and then somehow obtain a pointer - at least you can do this with images. It’s a hack but I had to use it once.
Another way to do this would be to allocate your doubles on unmanaged heap. I’m not sure how it’s done in C# as I mostly use C++/CLI when I code in .NET and in C++/CLI it’s done by default when one uses ‘new’ (‘gcnew’ allocates in managed heap). Generally, for mixing unmanaged and managed code I’d use C++/CLI specifically to avoid such problems. It still gets ugly at times but not so much as C#.

Here’s something I found
http://social.msdn.microsoft.com/Forums/en…71-9e1afbfb0859