Skip to content

Conversation

@brianpopow
Copy link
Collaborator

@brianpopow brianpopow commented Feb 18, 2022

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

I was experimenting a bit with ARM hardware intrinsics and decided to port the adler32 version of chromium to ImageSharp.

BenchmarkDotNet=v0.13.1, OS=ubuntu 20.04
Unknown processor
.NET SDK=5.0.402
[Host] : .NET 5.0.11 (5.0.1121.47308), Arm64 RyuJIT
DefaultJob : .NET 5.0.11 (5.0.1121.47308), Arm64 RyuJIT

Method Mean Error StdDev
AdlerARM 1.082 us 0.0123 us 0.0109 us
AdlerScalar 3.823 us 0.0165 us 0.0146 us

CPU info:

Architecture:        aarch64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              6
On-line CPU(s) list: 0-5
Thread(s) per core:  1
Core(s) per socket:  3
Socket(s):           2
Vendor ID:           ARM
Model:               4
Model name:          Cortex-A53
Stepping:            r0p4
CPU max MHz:         1896.0000
CPU min MHz:         100.0000
BogoMIPS:            48.00
Flags:               fp asimd evtstrm aes pmull sha1 sha2 crc32

Benchmark was run with the following data:

int N = 4096;
byte[] data = new byte[N];
new Random(1).NextBytes(data);

There is still a bug, adler results for N 4096: fixed

Arm: 1010560139
Scalar: 1010560140

Copy link
Contributor

@gfoidl gfoidl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For .NET 7 cross-platform intrinsics will be available, so that code can be written on behalf of Vector128<T> and not via Sse2 / AdvSimd.

I know that it's still a long time until is .NET 7 is available and adopted, but is this something that should be focused on now already?

@brianpopow
Copy link
Collaborator Author

For .NET 7 cross-platform intrinsics will be available, so that code can be written on behalf of Vector128<T> and not via Sse2 / AdvSimd.

I know that it's still a long time until is .NET 7 is available and adopted, but is this something that should be focused on now already?

That's interesting, I was not aware of this. How would that work? SSE has intrinsics which ARM does not have and vice versa.

I think its to early to early to consider this now. Anything ARM related is now only pretty much experimental and will not land in the main branch anytime soon.

@gfoidl
Copy link
Contributor

gfoidl commented Feb 19, 2022

How would that work? SSE has intrinsics which ARM does not have and vice versa

Only the "common subset" is exposes as xplat-intrinsics. The journey started in dotnet/runtime#49397 but more operations got added so far -- I can't find a up-to-date summary of all operations 😢.
For the special cases one needs to fall back to the current intrinsics style (Sse.IsSupported / AdvSimd.IsSupported).

I think its to early to early to consider this now

This is also my expectation. Just wanted to point to it (as a reminder that something is on the way).

@brianpopow
Copy link
Collaborator Author

This is also my expectation. Just wanted to point to it (as a reminder that something is on the way).

Thanks for sharing, that's very interesting to know.

@brianpopow brianpopow changed the title WIP: Add ARM version of adler32 Add ARM version of adler32 Feb 21, 2022
This was referenced Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants