Using Unmanaged CUDA in .net application

Dec 29, 2013 at 3:43 PM
Hello,
I have a unmanaged c++ cuda code. I want to use that in a .net application. One way to do is by creating dll and exposing each method and using platform invoke . Other way is to rewrite the whole code in cudafy(Managed cuda).

Is there any simpler method so that i can use my unmanged cuda without rewriting it??


Regards,
Naveen Hegde
Coordinator
Dec 30, 2013 at 1:11 PM
Edited Dec 30, 2013 at 1:12 PM
Yes you can use dummy functions. You can see examples of their use in CudafyExamples project included in the 1.26 installer or from sources.
    [CudafyDummy]
    public struct DummyComplexFloat
    {
        
        public DummyComplexFloat(float r, float i)
        {
            Real = r;
            Imag = i;
        }
        public float Real;
        public float Imag;
        public DummyComplexFloat Add(DummyComplexFloat c)
        {
            return new DummyComplexFloat(Real + c.Real, Imag + c.Imag);
        }
    }

        [CudafyDummy]
        public static void DummyDummyComplexFloatFunction(DummyComplexFloat[] result)
        {

        }
Then in CUDA:


extern "C" __global__ void  DummyDummyComplexFloatFunction(DummyComplexFloat  *result)
{
    int  x = blockIdx.x;
    result[x] = result[x].Add(result[x]);
}