Home Dashboard Directory Help
Search

Add builtin SIMD support for .NET by Alexandre Mutel


Status: 

Active


629
2
Sign in
to vote
Type: Bug
ID: 778895
Opened: 2/10/2013 12:31:43 AM
Access Restriction: Public
1
Workaround(s)
view
30
User(s) can reproduce this bug

Description

The lack of support of native SIMD in .NET is a long pending issue that has lots of side effects:

    • .NET applications can't really compete with a native C++ application that is using some SSE2/NEON implicit instructions to speed up things. While SSE2 has been quite common on CPU for several years now, as well as on ARM mobile platforms.
    • There are several relevant use cases in the industry (At least, in the domain I know so far, Profit and Loss Risk Applications and Trading Systems, Game industry - both for Graphics and Audio applications - that would benefits a *lot* native support of SIMD in .NET, instead of having to develop an inefficient wrapper to a vectorized library.
    • From the visible part of the iceberg, there are several open source projects that are running their own Vectorized types but are not able to efficiently communicate between them.
    • Current workarounds to move vectorized calculations in a native DLL are annoying because we cannot really use fine grained API - that would lost a bit the benefits of SSE2 registers allocs on x86/x64 - so we are stuck to develop specific coarse grained APIs that don't always fit well with the layout of data in the original .NET App
    • With the rise of mobile applications, It is getting even more critical to have SIMD on .NET (the current generated code on ARM when using floating points calculations is verbose and unfortunately not really efficient)

I know that the team in charge of it has been evaluating it/working on it for some years now (For example from this comment on connect: https://connect.microsoft.com/VisualStudio/feedback/details/716162/-net-simd, I remember also a developer of your team on some 'user voices' forum making that he would love to implement it) but the demand for such a feature is probably not high (few .NET programmers really care about performance), the amount of work required to correctly implement it has to be balanced with the visible benefits, and with things to prioritize for supporting new CLR/platforms, SIMD .NET has been always delayed until now.

While we don't know what are your exact plans to hypothetically support it, I'm opening this issue in the belief that It will be closed once It is shipped! :)
We would also love to hear more about your choices on how you would expose it. Among the things I'm concerned:
    • How would be exposed builtin vectorized types? - float4/int4/double2…etc? matrix support like float4x4 ? (that would translate to some float4 instructions would be nice as well). Quid of float3 types that don't map directly to a type but that could be helpful (though a HLSL compiler for example is able to use the remaining w float to store it when calculating, but afair, SSE2 is less practical with that)
    • How accessing shuffle instructions would work?, would be pretty handy to be able to express them like in HLSL, 'myfloat4.xxzx'
    • How would work to manage aligned and unaligned loading into SIMD vectors?
    • A breaking change in the CLR to support it at the IL bytecode level would be even fine, If it makes JIT & offline compiler analysis easier and faster
    • Auto-vectorized is less critical
    
SIMD support builtin in .NET would help .NET platform to be much more attract full for lots of developers & applications!
Details
Sign in to post a comment.
Posted by Arkady Shapkin on 4/4/2014 at 3:49 AM
SIMD for .NET http://blogs.msdn.com/b/clrcodegeneration/archive/2014/04/03/ryujit-ctp3-how-to-use-simd.aspx
Posted by spike0xff on 3/4/2014 at 8:40 AM
Also would be very valuable in image processing, which includes photo-sharing, document scanning and document management.
As a very small example, generating image/document thumbnails is commonly a bottleneck for us, which would be accelerated by SIMD.
We are trying hard to migrate *to* managed code, not away from it.
Posted by Lavagin on 12/26/2013 at 11:24 AM
Any word on the status of this?
Posted by Jeff.Moser on 11/19/2013 at 8:35 AM
Without SIMD support, I cannot write a performance competitive version of the scrypt cryptographic key derivation function in pure C# since the inner loop depends on being able to operate on vectors quickly.
Posted by BenK3 on 8/21/2013 at 8:53 PM
It really needs to be done properly not like mono which is just a few ops and its value is not floats thats better done by a vid card but integer and not just the obvious fast 256 bit moves and compares but bit scans for sequences , mapping etc

Here http://woboq.com/blog/utf-8-processing-using-simd.html is an example of where we are going with SIMD , UTF8 processing is at least an order of magnitude faster than you can do in C# .

Likewise string to int can be done in 30 cycles for 6 -9 character strings with SIMD with validation . ( eg bit scan for point , remove and record . subtract ymm constant 0x00 0x30 0x00 0x030 .. from sequence.. if >= 00, 00,00 and < 00 , 0A , 00 , 0A .. then its valid then add and multiply with a constant and you have your int.
Posted by Stian - on 8/19/2013 at 2:46 AM
Would be nice if you added this support.

Cheers,
Stian
Posted by kgb7711 on 8/18/2013 at 11:59 PM
Hope to see SIMD builtin vs2014 as i wait for it for more than 5 years.
Posted by slimJim200000 on 7/31/2013 at 1:08 PM
This hurts high performance c# applications a lot. 3D apps use a lot of quaternions, matrixs and vectors.
Posted by Arkady Shapkin on 3/19/2013 at 6:54 AM
Suggestion about SIMD and C# http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2212443-c-and-simd
Posted by Alexandre Mutel on 3/16/2013 at 7:15 AM
Even SIMD is coming to the web... https://www.youtube.com/watch?v=CKh7UOELpPo
Posted by Narf the Mouse on 3/8/2013 at 1:26 PM
C#/.Net is excellent for almost any program deployment, including video games. Adding SIMD support would allow .Net game engines and games to meet industry standards for speed in all areas.
Posted by AzureSky on 2/21/2013 at 3:40 PM
This is a very important feature for .NET to have. Please, let's see this in some form as part of the .NET Framework and languages, Microsoft.
Posted by Thomas Ibel on 2/20/2013 at 10:32 PM
Come on, Mono has this feature since years (about 2008).
Posted by Norbo on 2/12/2013 at 2:31 PM
I have been hoping for some sort of implementation of this for a long time. Heavy numerical lifting on the CPU is a persistent bottleneck for our applications. Anything that lets us boost that performance within .NET would be enormously valuable.
Posted by Tom Spilman on 2/12/2013 at 11:19 AM
It is a shame that media and gaming applications have been limited by the lack of SIMD support in .NET for so long. It has been a highly requested feature for years now...

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2212443-c-and-simd

This is a completely artificial limitation that only serves to handicap .NET performance compared to native code.

Please don't let this slip out of the next release yet again.
Posted by Microsoft on 2/10/2013 at 10:20 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 2/10/2013 at 12:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Peter Verswyvelen on 2/12/2013 at 4:11 PM
Use Mono? ;-) I think it has SIMD support. http://tirania.org/blog/archive/2008/Nov-03.html