Calling mono c# code from Microsoft .net?

前端 未结 3 1838
醉梦人生
醉梦人生 2020-12-17 01:02

I have some neural net code written in c# that would benefit from using SIMD support. Mono 2.2 just came out that supports SIMD but Microsoft\'s c# does not support this yet

相关标签:
3条回答
  • 2020-12-17 01:07

    From Miguel de Icaza's blog:

    Our library provides C# fallbacks for all of the accelerated instructions. This means that if your code runs on a machine that does not provide any SIMD support, or one of the operations that you are using is not supported in your machine, the code will continue to work correctly.

    This also means that you can use the Mono.Simd API with Microsoft's .NET on Windows to prototype and develop your code, and then run it at full speed using Mono.

    As I understand it, this means that you can write code that uses Mono.Simd, and will be able to run it under .Net, but it won't be any faster than regular code, because the .Net runtime doesn't support SIMD yet.

    0 讨论(0)
  • 2020-12-17 01:17

    In order to take advantage of SIMD features, the runtime should be able to natively support it. Basically, Mono treats Mono.Simd namespace specially in the runtime. Obviously, Microsoft .NET runtime does not support this feature. However, the Mono.Simd assembly provided is a completely valid and normal .NET assembly written in managed code and therefore it can run on .NET CLR, but it would be just a software emulation of what SIMD instructions do.

    You can run Mono runtime on Windows and take advantage of those features but there is no direct way to run half of application on .NET and the other half on Mono (you could, of course, use communication mechanisms as two distinct applications can use, but it doesn't make sense for this scenario at all).

    0 讨论(0)
  • 2020-12-17 01:31

    Essentially, if you write it with Simd and distribute the dll with your code, it will use acceleration if the target VM supports it. If not, it doesn't break. So you can use the library and give any users of your program who run .NET apps with Mono a speed boost.

    Microsoft has been said to be planning to add such support in its next release of its runtime, though I cannot find the link and don't have it handy right this sec---can dig the link out of a historic backup if anyone is interested enough.

    0 讨论(0)
提交回复
热议问题