Is there a step by step guide to enable the template program to run and return to a windows forms application. If i can see how this works, then i can extrapolate it to the rest of my project. At the moment i am having issues configuring the forms application to accept the .cu files.
Does anybody know any resources i could look at for this.
What you are trying to do is mix cuda with c/c++ right? Take a look at the cppintegration sample in the SDK. I personally use a wrapper that calls my kernel. This wrapper is inside the .cu file and I only compile the .cu and include the .h file of my kernel to make it work. But this is under Linux and not using any forms, but i think its just the same.
I seem to remember looking at this a year ago and not getting anywhere with it. I think the problem is due to the boundary between managed and unmanaged code.
I had another go using that file as a basis trying to connect to a windows form with a push button to start the processes.
1>template.obj : fatal error LNK1313: ijw/native module detected; cannot link with pure modules
If you want to use .NET and CUDA, your programs have to be compiled with with clr mixed option. Further, there is either an MT or MD compiler option for mixed clr. Look that compiler option up and make sure the command line compiler option in the custom build for the .cu files matches that.
Yes i managed to get something working using /clr, but not /clr:pure. Do you think it would be possible to mix the two through the use of a DLL? For instance, package the CUDA files into the DLL and then include it in the /clr:pure managed code?
Yes, using a DLL is possible, and it’s actually quite conveniant to do it this way as you can mix CUDA with every other language of your choice (C# in my case).
Hi, interop is the easies way to go. just make a standard dll in c++/c, and you can call it with the following syntax (from C#)
[DllImport("stochfitdll.dll", EntryPoint = "GetData", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
protected static extern int GetData(double[] ZRange, double[] Rho, double[] QRange, double[] Refl, out double roughness, out double chisquare, out double goodnessoffit, out bool isfinished);
This allow you to pass (allocated) arrays into the dll, perform calculations on them or modify them, and pass them back. As a word of warning, if you are going to thread this you’ll want to memcpy them into local arrays.