CUDA and C#

Hi!

Trying to find some material or resources regarding using CUDA from C#, some code examples or how to’s. I am aware of cudanet from http://www.hoopoe-cloud.com/ but I was wondering if there’s another way of doing it. Since I’ve already implemented kernels and host functions calling the kernels I would like to find a way to call my host functions from C# instead of having to rewrite all of my host functions to C#.

cheers,
Daniel

Well, if you’ve already done all of the host-side code in the native DLL/EXE, then all you need to do is add some P/Invoke signatures in your C# code to call into the native DLL. Search Bing/Google/DuckDuckGo for “Platform Invoke”, “Native Interop”, or “DllImport attribute” and you’ll find what you need.

Well, if you’ve already done all of the host-side code in the native DLL/EXE, then all you need to do is add some P/Invoke signatures in your C# code to call into the native DLL. Search Bing/Google/DuckDuckGo for “Platform Invoke”, “Native Interop”, or “DllImport attribute” and you’ll find what you need.

How should the existent host and device code be compiled? With nvcc xxx.cu --cubin?

How should the existent host and device code be compiled? With nvcc xxx.cu --cubin?

A .cubin file only contains device-based code, so that wouldn’t do anything for the host-side stuff you’ve written. You need to just compile everything into a DLL (which you’ll use nvcc and Visual Studio for, but I don’t know what command line you’ll need to do it).

A .cubin file only contains device-based code, so that wouldn’t do anything for the host-side stuff you’ve written. You need to just compile everything into a DLL (which you’ll use nvcc and Visual Studio for, but I don’t know what command line you’ll need to do it).