Taking into account the execute disable bit what is the recommended way of executing instructions against a native processor from a high level managed environment such as VB.NET 2008 or C#. In addition has anyone achieved similar in executing GPU 开发者_C百科instructions against a graphics processor?
There are a few GPU options for C#, for direct access without reverting to P/Invoke or writing your own C++ wrappers:
- Brahma is quite interesting. It provides access to the GPU directly via a customized LINQ provider. The code includes some samples of highly computational methods run on the GPU, all written in C# via LINQ.
- SlimDX provides a nice .NET wrapper to all of the major DirectX functionality. With custom shaders, you can do computation on the GPU via DirectX. It also includes DX11 support, so you can use the compute shaders directly (if you have the hardware for it).
- You can access CUDA via CUDA.NET.
- You can use OpenCL via OpenCL.NET.
As for CPU instructions, this typically would require dropping to lower level native code with assembler instruction. Probably the most interesting completely managed (at least partially related) option would be to use Mono.Simd, which provides direct access to the SIMD instructions in the CPU from managed code when running on the Mono stack.
It is not an option. You'll have to P/Invoke a function in DLL that was generated by MASM or written in unmanaged C/C++, using inline assembly or intrinsics. Or use the C++/CLI compiler and generate mixed mode code with #pragma managed.
Beware that you now can no longer depend on the JIT compiler generating whatever platform code is suitable for the operating system. Use Project + Properties, Build tab, Platform Target to force the architecture to match your unmanaged code.
Look at CUDA for managed GPU code.
Create unmanaged .dll library with whatever instructions you want and use P/Invoke to call it.
精彩评论