| 2014-07 Programming in .NET for CUDA |
|
| July 2014 | |
|
We have discovered a project called Cudafy.Net which enables Microsoft C# programmers to access GPU and CPU for parallel computing using CUDA or OpenCL API. This article is a description of our discovery in 2014-06. o The website hosting this project is https://cudafy.codeplex.com/. The website states “CUDAfy.NET allows easy development of high performance GPGPU applications completely from the Microsoft.NET framework and it is developed in C#.” It follows the CUDA programming model but does not require the C# programmer to possess deep understanding of CUDA. Its latest version is 1.26 and supports Nvidia CUDA6.0. o Dr Radu Nicolescu of University of Auckland has confirmed that changing an enumerator for the target GPU in the C# source program from CUDA to OpenCL would produce code for OpenCL environment. That is, the same C# applications written for CUDA can be made easily to run in AMD GPU and AMD/Intel CPU under OpenCL. o An evangelist John Hauck posted his experience as early as April 2013 on the Codeplex website. To run CUDA software on CUDA hardware obviously requires the CUDA toolkit from Nvidia (https://developer.nvidia.com/cuda-downloads ). To run OpenCL on the GPU, the drivers of the GPU cards only would be required. To run OpenCL on Intel CPU will need an Intel SDK: http://software.intel.com/en-us/vcsource/tools/opencl-sdk. To CUDAfy C# applications, obtain this DLL: http://cudafy.codeplex.com/ . For development, use Visual Studio 2010 or 2012. The above information revealed a major difference between CUDAfy C# to CUDA and OpenCL. The Cudafied CUDA rendition needs C++ compiler with CUDA at runtime but Cudafied OpenCL does not need further compilation. Obviously CUDA performance would be substantially above OpenCL in this situation. o Support of OpenCL was official on 5 May 2013 in version 1.22. Another website http://hybriddsp.wordpress.com/2013/06/15/portable CUDA said CUDAfy is applicable to Linux as well, 32 or 64bits, and even Altera FPGA. OpenCL libraries are required. Mono Linux is required. Under the Hood o We believed that C# is being developed as a functional language which is capable of embedding Domain Specific Languages (DSL). DSL is a special purpose language designed to encapsulate possible computations in a specific domain. Embedded means embedded in a host language. An Embedded DSL in a host language has its own look, feel, and semantics customised to a specific problem domain. There are 2 types of Embedded DSL- shallow and deep. Shallow DSL is a function computing on values and return the computed value as the result. Deep DSL provides the result of a computation not as a value but as a structure that can be used to compute a value or cross-compiled before being evaluated (that is, generating another program). We can write an EDSL with expressions which extract a tree of what to do and not a direct result. END |
