So today I’m trying to figure out how to compile C# application (.cs file) with CUDA code (.cu file)
I’ve got an application in C# and I also got functions that will be use by this application, and this functions are in CUDA C/C++. So I’m wondering how can I compile C# and CUDA C/C++ to get one executable ?
When I read topic, I only see people that say “use that lib it “translate” your C# in CUDA[…]” or something like that, but that’s not what I want to.
I don’t know much about compilation, or link compilation or [anything] compilation… So if you know a website or get the “how to” I’d like to read it ! Thank you =)
You can certainly build DLLs with CUDA. Initially, all the libraries shipping with CUDA (e.g. CUBLAS, CUFFT) were only available in DLL form. How you would go about invoking functions in a DLL from C#, I don’t have the slightest idea as I have never used C#.
Is there any great documentation about managedCUDA something else than their gitHub ?
I tried to use it following NVidia CUDA ‘Hello world’ in managed C# and F# with use of managedCUDA | AlgoSlaves and it works well with this example, but it seem that we need to use Func<in T1, in T2, out TResult> function(T1, T2) to get the result of a kernel function. But that mean I can’t launch function that get more than 2 parameter ? Weird…
Cause in my .cu file (the one with kernels defined) they ared defined like :
And Cartesian/Propagato/EarthCoordinates/calcAngle are Class !
If I got a well understanding of what managedCUDA is, it’s like if managedCUDA replace the main of my .cu file.
So if I use managedCUDA I need to keep my .ptx file compiled previously by my .cu app. But if it’s a multi-file app I’ll get one .ptx ? Right ? More ?
And when I was reading “how to” on this website, I saw that he choose “_Z6kerneliiPi” for the first argument of CudaKernel() but in another program the name change, how to determine which is the name of our kernel function ?
Recall that CUDA belongs to the C++ family of languages. The name of the kernel in the object file will be constructed from the name the programmer chose for the function, plus the C++ name decoration added during C++ name mangling to encode the types of the functions arguments (note that name decoration schemes are not standardized).
To see the decorated name of a kernel, you could run cuobjdump --dump-elf-symbols on the executable. You can demangle decorated names though numerous online tools, e.g. [url]https://demangler.com/[/url]. E.g. “_Z6kerneliiPi” resolves to “kernel(int, int, int*)”.