.NET access to the GPU for compute purposes
Posted
by Daniel Moth
on Daniel Moth
See other posts from Daniel Moth
or by Daniel Moth
Published on Fri, 02 Dec 2011 03:42:50 GMT
Indexed on
2012/03/18
18:16 UTC
Read the original article
Hit count: 409
GPGPU
|ParallelComputing
In the distant past I talked about GPGPU and Microsoft's then approach of DirectCompute. Since then of course we now have C++ AMP coming out with Visual Studio 11, so there is a mainstream easier way for developers to access the GPU for compute purposes, using C++.
The question occasionally arises of how can a .NET developer access the GPU for compute purposes from their C# (or VB) code. The answer is by interoping from the managed code to a native DLL and in the native DLL use C++ AMP.
As a long term .NET developer myself, I can tell you this is straightforward. Sure, there could have been a managed wrapper for C++ AMP, but honestly that is the reason we have interop – it doesn't make much sense to invest resources to solve a problem that is already solved (most developer customers would prefer investments in other areas of Visual Studio!). Besides, interoping from C# to C++ is much easier than interoping to some of the other older approaches of GPGPU programming ;-)
To help you get started with the interop approach, Igor Ostrovsky has previously shared the "Hello World" version of interoping from C# to C++ AMP in his blog post:
…we then were asked specifically about how to interop from C# to C++ AMP in a Metro style application on Windows 8, so Igor delivered again with this post:
Have fun!
Comments about this post by Daniel Moth welcome at the original blog.
© Daniel Moth or respective owner