Hi-world for CUDA.Net

I'm trying to write a kids app with CUDA.Net, but I'm out of luck.

I realized that:

using GASS.CUDA; // ... var c = new CUDA(); // c.Launch(myfunc); // ???? how ??? 

myfunc should apparently be of type GASS.CUDA.Types.CUfunction , but I have not found how to define it.

+7
source share
2 answers

First you need a .cu file with your kernel (the function must be executed on the GPU). Let there be a file mykernel.cu:

 extern "C" __global__ void fooFunction(float4* data) { // there can be some CUDA code ... } 

This needs to be compiled into a .cubin file using the nvcc compiler. So that the compiler knows about the Visual C ++ compiler, you need to call it from the Visual Studio command line:

 nvcc mykernel.cu --cubin 

This creates the mykernel.cubin file in the same directory.

Then in C # code you can load this binary module and execute the kernel. In the higher-level GASS.CUDA API, it might look like this:

 using GASS.CUDA; // ... CUDA cuda = new CUDA(true); // select first available device (GPU) cuda.CreateContext(0); // load binary kernel module (eg. relative to from bin/Debug/) CUmodule module = cuda.LoadModule("../../mykernel.cubin"); // select function from the module CUfunction function = cuda.GetModuleFunction(module, "fooFunction"); // execute the function fooFunction() on a GPU cuda.Launch(function); 

What is it!

The nvcc compiler should be called as an assembly action better than calling it manually. If anyone knows how to do this, let us know.

+8
source

Unfortunately, CUDA.net is very poorly documented, but http://www.hoopoe-cloud.com/files/cuda.net/2.0/CUDA.NET_2.0.pdf should help you get started. Also, you still need to write your kernel in CUDA C, so http://developer.download.nvidia.com/compute/cuda/3_2_prod/toolkit/docs/CUDA_C_Programming_Guide.pdf would be a good idea to take a look at this , and maybe, and maybe try starting with the CUDA C application before porting it to CUDA.net.

+2
source

All Articles