I am developing a xamarin forms application right now and I have some problems with hardware acceleration.
Specifically, in the android emulator, hardware acceleration works, ie
System.Numerics.Vector.IsHardwareAccelerated
returns true.
On the device however, it returns false, and thus libraries like ImageSharp are super slow.
I already checked the build settings and "Optimize code" is checked everywhere. Also I added HardwareAccelerated = true
to the MainActivity.cs in the android project, but that doesn't change anything.
Anybody can help?
EDIT:
The emulator is running on api level 25 (android 7.1), in the emulator it is working with debug configuration.
The device is running android 8.1, api level 27, and only release build work there at all.
EDIT:
According to @SushiHangover there is no Hardware acceleration support for System.Numerics.Vector for arm platforms implemented in Mono. Also, see here: https://github.com/SixLabors/ImageSharp/issues/94
Cheers, Johannes
I did a quick scan of Mono's
mini-XXX.c
files andmini-arm.c
andmini-arm64.c
do not implement any SIMD versions.Since there are no intrinsic support, the Mono JIT'er will not map SIMD (NEON) functions on supported ARM devices.
Note: Only
mini-amd64.c
&mini-x86.c
have JIT intrinsic support for SIMD (SSE) within the Mono Runtime/JIT.Note: According to one of the old Mono release notes, AOT'ing via LLVM should give you SIMD support on any supported platform... (I have not tested that)
Update: I tested
llvm
and the generatedlibaot-System.Numerics.Vectors.dll.so
on ARM platforms is not hardware accelerated