Bug 55577 - SIMD instructions with System.Numerics.Vectors do not work
Summary: SIMD instructions with System.Numerics.Vectors do not work
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: 15.3
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2017-04-25 17:35 UTC by jvsbl
Modified: 2017-04-27 19:21 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Console App which prints Information about SIMD acceleration (632.68 KB, application/zip)
2017-04-25 17:35 UTC, jvsbl
Details

Description jvsbl 2017-04-25 17:35:05 UTC
Created attachment 21772 [details]
Console App which prints Information about SIMD acceleration

Version: Mono JIT compiler version 5.3.0 (Nightly 5.3.0.67/0ed43bb Mon Apr 10 09:48:18 UTC 2017)

https://www.nuget.org/packages/System.Numerics.Vectors

simple LOC:
Console.WriteLine(System.Numerics.Vector.IsHardwareAccelerated);

delivers false on my Machine Linux Mint 17.3 64 Bit(delivers true on Windows though)
It does not matter if its compiled with Mono or .Net(on Windows) - Mono/.Net works on Windows, but both do not work on Linux - so it should be the JIT imho.

Tried using the Library further as well it was way slower on Linux with the Library than without, but considerably faster on Windows(so SIMD itself is definitely working)

TargetFramework: v4.6.2(tried older Versions as well)
PlatformTarget: x64(tried AnyCPU as well)

Of course I used the Release build and tried to run it with "mono ConsoleApp.exe" as well.

http://www.mono-project.com/news/2016/12/20/system-numeric-vectors/
I hope I've done nothing wrong on the way, but Nightly should be the master Branch(right?)

Attached below the simple Console App I used to test it.

Thanks for any help you can provide
Comment 1 Alexander Köplinger [MSFT] 2017-04-25 18:52:17 UTC
Zoltan: it seems the SIMD intrinsic for IsHardwareAccelerated was only added to System.Numerics.dll, but we need it in System.Numerics.Vectors.dll as well.

The following patch fixes it for me: https://gist.github.com/akoeplinger/f59dbcd1388a7a7e76c29379e02509bf.

Note: the check for Vector`1 in System.Numerics.dll is not needed, the type doesn't exist there so I removed it.
Comment 2 Zoltan Varga 2017-04-25 19:13:35 UTC
Looks ok.
Comment 3 jvsbl 2017-04-25 22:00:28 UTC
wouldn't "Vector`1" be for a Generic class without the generic parameters given?

https://msdn.microsoft.com/en-US/library/mt573439(v=vs.111).aspx
Comment 4 Alexander Köplinger [MSFT] 2017-04-25 23:22:40 UTC
Yes, the point is this type lives in System.Numerics.Vectors.dll not System.Numerics.dll.
Comment 5 Zoltan Varga 2017-04-27 08:49:05 UTC
https://github.com/mono/mono/pull/4762
Comment 6 Alexander Köplinger [MSFT] 2017-04-27 12:26:27 UTC
Merged to master and 2017-04, thanks.

Zoltan: do you think we should put it in 2017-02 as well given that we mention the .NET SIMD classes in http://www.mono-project.com/docs/about-mono/releases/5.0.0/#simd-acceleration-support
Comment 7 Zoltan Varga 2017-04-27 19:21:29 UTC
No, simd is disabled in 2017-02, since there were too many bugs.

Note You need to log in before you can comment on or make changes to this bug.