CUDAfy is a set of libraries and tools that permit general purpose programming of NVIDIA CUDA Graphics Processing Units (GPUs) and OpenCL Devices (GPUs, CPUs and FPGAs) completely from within the Microsoft .NET framework. The aim is to create the leading tools for this task; combining flexibility, performance and ease of use.
|The CUDAfy SDK comprises the following:
The base CUDAfy library provides GPGPU specific classes. These are essentially an object orientated .NET means of approaching CUDA. Key components are the GThread and CudafyModule classes and the Cudafy attribute. GThread is used to identify the thread, block and grid IDs of parallel code running on the GPU as well as give access to the various different memory types GPUs have (e.g. shared , global, etc). The Cudafy attribute is placed on methods, structures and constants that will be running on the GPU. CudafyModules contain generated GPU code and other information to allow easy use from the CUDAfy host classes.
Using SharpDevelop’s decompiler ILSpy as basis the translator converts .NET code to CUDA C.
CUDAfy Host Library
The host library permits easy interaction between host and GPU code. CudafyModules can be loaded, data can be allocated on GPU and transferred between host and GPU, and GPU functions can be launched. Allocated data is tracked by the GPU class and pointers to data are standard .NET arrays. Furthermore emulation of GPU code is fully supported meaning that the power of the .NET debugger is available.
CUDAfy Math Library
This is a .NET wrapper around the NVIDIA CURAND (Host and Kernel), CUBLAS, CUSPARSE and CUFFT libraries – Random, Basic Linear Algebra, Sparse Matrix and Fourier Transform.
CUDAfy Module Viewer
Examine *.cdfy modules and modify generated CUDA C source code and retarget for a different architecture.
CUDAfy Command Line Tool
From the command line cudafy .NET dlls and exes and place the *.cdfy xml module into the resources of the original assembly. No need to redistribute *.cdfy files or have CUDA SDK on target machine.
CUDAfy for Linux
Cudafy in alpha form is available for Linux. With Mono and MonoDevelop installed development is quite comfortable even to Windows programmers. A big boost is the performance of transfers of non-pinned memory to and from GPU which does not take the hit the Windows driver model imposes. Set-up is naturally tougher, but google around and push on. If you need the Maths libraries then unfortunately only the FFT library is playing ball – need to dig deeper to see what is happening here for the others. Note that Cudafy is supplied as a set of dlls instead of a single merged one, so remember to link to the various individual dlls.
Change one enum in your code and your CUDAfy .NET code will convert to OpenCL and also run on AMD GPUs and Intel CPUs as well as NVIDIA. Make sure to install the AMD or Intel OpenCL SDKs.