Can I use .NET SIMD on Raspberry Pi 4?

Ivan Koshelev

I'm writing code that will subtract corresponding bytes in two arrays and count the number of resulting bytes surpassing a given threshold. AFAIU, it would really benefit from .NET SIMD, but System.Numerics.Vector.IsHardwareAccelerated returns false when I compile C# on Raspberry Pi 4.

My dotnet version is 3.1.406, I've added

  <PropertyGroup>
    <Optimize>true</Optimize>
  </PropertyGroup>

to the csproj and running release configuration.

Is there any way I can leverage SIMD support in .NET on Raspberry Pi 4? Maybe with .NET 5?

Update I installed .NET 5 and tried .NET Intrinsics, but none is supported:

Console.WriteLine(System.Runtime.Intrinsics.Arm.AdvSimd.IsSupported); //false
Console.WriteLine(System.Runtime.Intrinsics.Arm.Aes.IsSupported);  //false
Console.WriteLine(System.Runtime.Intrinsics.Arm.ArmBase.IsSupported); //false
Console.WriteLine(System.Runtime.Intrinsics.Arm.Crc32.IsSupported); //false
Console.WriteLine(System.Runtime.Intrinsics.Arm.Dp.IsSupported); //false
Console.WriteLine(System.Runtime.Intrinsics.Arm.Rdm.IsSupported); //false
Console.WriteLine(System.Runtime.Intrinsics.Arm.Sha1.IsSupported); //false
Console.WriteLine(System.Runtime.Intrinsics.Arm.Sha256.IsSupported); //false

I'm on 32-bit Raspbian (Debian derivative), is there any chance I need 64-bit version for this to work?

Soonts

Despite the API is done and even documented, the implementation is missing. Take a look. 8-byte SIMD vectors is essential part of NEON ISA for decades now (was introduced in 2005), yet the .NET runtime only implements them when compiling for ARM64 (released in 2013).

I don’t work for Microsoft and have no idea how exactly they compile their binaries, but the source code tells they have at least some support for NEON when building for ARM64 target. If you want these intrinsics in .NET, you can try the 64-bit OS.

There’s a workaround — implement your performance-critical pieces in C++, compile a shared library for Linux, then use [DllImport] to consume these functions from .NET. I have built non-trivial Linux software that way (example), using the following gcc flags to build the DLLs: -march=native -mfpu=neon-fp16 -mfp16-format=ieee -ffast-math -O3 -fPIC This way it will work for 32-bit OS, and won’t require anything special from .NET runtime, I’ve tested with .NET Core 2.1.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can I use Google Translate to make my Raspberry Pi speak in different languages on demand?

From Dev

How can I use the google voice api on my raspberry pi running debian and chromium

From Dev

Can I run a C# application on a Raspberry Pi?

From Dev

Raspberry Pi: Can I turn on a monitor over HDMI?

From Dev

How can I compile Rust code to run on a Raspberry Pi 2?

From Dev

can I use visual studio 2013 (run on windows 8.1 ) to Create raspberry pi 2 app (RPI2 Running Windows 10 )?

From Dev

Can I use the USB port of the raspberry pi (model B+) for serial communication (RS232)

From Dev

Can I run matlab on raspberry pi?

From Dev

How can I modify default page for UV4L streaming server at Raspberry Pi?

From Dev

How can i get JavaFX working on raspberry pi 3

From Dev

Can I use .NET SIMD on Raspberry Pi 4?

From Dev

Raspberry Pi What can I do with it?

From Dev

Installing Steam on Raspberry Pi 4

From Dev

How can I use the google voice api on my raspberry pi running debian and chromium

From Dev

Can I run mythbackend on Raspberry Pi?

From Dev

Use raspberry pi to spoof dns

From Dev

How can I install Ubuntu with APT (not Snappy) on the Raspberry Pi 2?

From Dev

How can I run lightdm on Xvfb on a Raspberry Pi?

From Dev

Why can't I use python-mosquitto on the Raspberry Pi?

From Dev

can I use visual studio 2013 (run on windows 8.1 ) to Create raspberry pi 2 app (RPI2 Running Windows 10 )?

From Dev

How can I modify default page for UV4L streaming server at Raspberry Pi?

From Dev

Can I use Ubuntu One on the Raspberry Pi?

From Dev

How can I compile scanbd on Raspberry Pi?

From Dev

Can you install Ubuntu on the Raspberry Pi 4

From Dev

Can I automatically run a program in raspberry pi when it is turned on?

From Dev

Raspberry Pi 4 updated bootloader

From Dev

Can't install any applications on Raspberry Pi 4

From Dev

Can I use AUX port in Raspberry Pi 3 (Model B) to plug a microphone to get audio signals in?

From Dev

Can't connect with SSH to Ubuntu server (20.04) on raspberry pi 4

Related Related

  1. 1

    Can I use Google Translate to make my Raspberry Pi speak in different languages on demand?

  2. 2

    How can I use the google voice api on my raspberry pi running debian and chromium

  3. 3

    Can I run a C# application on a Raspberry Pi?

  4. 4

    Raspberry Pi: Can I turn on a monitor over HDMI?

  5. 5

    How can I compile Rust code to run on a Raspberry Pi 2?

  6. 6

    can I use visual studio 2013 (run on windows 8.1 ) to Create raspberry pi 2 app (RPI2 Running Windows 10 )?

  7. 7

    Can I use the USB port of the raspberry pi (model B+) for serial communication (RS232)

  8. 8

    Can I run matlab on raspberry pi?

  9. 9

    How can I modify default page for UV4L streaming server at Raspberry Pi?

  10. 10

    How can i get JavaFX working on raspberry pi 3

  11. 11

    Can I use .NET SIMD on Raspberry Pi 4?

  12. 12

    Raspberry Pi What can I do with it?

  13. 13

    Installing Steam on Raspberry Pi 4

  14. 14

    How can I use the google voice api on my raspberry pi running debian and chromium

  15. 15

    Can I run mythbackend on Raspberry Pi?

  16. 16

    Use raspberry pi to spoof dns

  17. 17

    How can I install Ubuntu with APT (not Snappy) on the Raspberry Pi 2?

  18. 18

    How can I run lightdm on Xvfb on a Raspberry Pi?

  19. 19

    Why can't I use python-mosquitto on the Raspberry Pi?

  20. 20

    can I use visual studio 2013 (run on windows 8.1 ) to Create raspberry pi 2 app (RPI2 Running Windows 10 )?

  21. 21

    How can I modify default page for UV4L streaming server at Raspberry Pi?

  22. 22

    Can I use Ubuntu One on the Raspberry Pi?

  23. 23

    How can I compile scanbd on Raspberry Pi?

  24. 24

    Can you install Ubuntu on the Raspberry Pi 4

  25. 25

    Can I automatically run a program in raspberry pi when it is turned on?

  26. 26

    Raspberry Pi 4 updated bootloader

  27. 27

    Can't install any applications on Raspberry Pi 4

  28. 28

    Can I use AUX port in Raspberry Pi 3 (Model B) to plug a microphone to get audio signals in?

  29. 29

    Can't connect with SSH to Ubuntu server (20.04) on raspberry pi 4

HotTag

Archive