dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.95k stars 4.65k forks source link

Investigate some potential perf improvements in Number.BigInteger.cs #11950

Open tannergooding opened 5 years ago

tannergooding commented 5 years ago

The floating-point formatting/parsing code currently uses an internal BigInteger ref struct that would likely benefit from using specific hardware intrinsics.

We should investigate using the BMI intrinsics, where possible and also look at exposing new intrinsics around AddWithCarry and Multiply128, both of which can simplify some of the more complex codegen down to a single instruction. You can see https://github.com/dotnet/coreclr/pull/22040#issuecomment-458763153 for some more details and the surrounding discussion.

mazong1123 commented 5 years ago

This sounds an interesting work item to me. If no one is working on it I'd like to take a look.

I went through the code for HW intrinsics, seems to add a new intrinsic we need to touch System/Runtime/Intrinsics and hwintrinsiclistxarch.h. Not sure if there's any guidance. If no I can figure it out as well.

mazong1123 commented 5 years ago

Looking at the board of HW intrinsics, seems an API proposal is needed before implementation. If we decide to add new intrinsics, I would create separate issues for proposing them first. Not sure if this is the right process.

tannergooding commented 5 years ago

Since the BigInteger ref struct exists within S.P.Corelib, the AddWithCarry and Multiply128 intrinsics could be prototyped without going through an API proposal. That is, they can be kept internal and experimented with to get numbers and prove they are useful first.

ghost commented 4 years ago

Tagging subscribers to this area: @tannergooding Notify danmosemsft if you want to be subscribed.