Search

Add builtin SIMD support for .NET by Alexandre Mutel

Active

497
1
Sign in
to vote
Type: Bug
ID: 778895
Opened: 2/10/2013 12:31:43 AM
Access Restriction: Public
1
Workaround(s)
21
User(s) can reproduce this bug
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 (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.5

Steps to reproduce

Generated code for vector floating points calculation doesn't take advantage of CPU special SIMD instructions

Product Language

English

Operating System

Windows 8

Operating System Language

English

Actual results

No SIMD instructions used in generated code from .NET

Expected results

SIMD instructions
File Attachments
0 attachments
Sign in to post a comment.
Posted by Arkadiy 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