Skip to content

Commit

Permalink
Vectorized Multiply (on Avx512) (#45)
Browse files Browse the repository at this point in the history
* avx512 multiply

* Optimize

* optimize

* optimize

* Optimize

* Optimize

* Simplify

* Optimize

* Optimize

* optimize

* Recoment and rename

* Optimize

* Optimize

* Fix benchmarks

* Temp refactor

* Improved comments

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Otpimize

* Refactor

* Clean up comments

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Optimize

* Revert "Optimize"

This reverts commit f380ecf.

* Optimize
  • Loading branch information
benaadams authored Feb 10, 2025
1 parent 992083e commit 7d7b936
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 62 deletions.
92 changes: 46 additions & 46 deletions src/Nethermind.Int256.Benchmark/Benchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public class SignedIntTwoParamBenchmarkBase : SignedBenchmarkBase
public (int, Int256) D;
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class AddUnsigned : UnsignedTwoParamBenchmarkBase
{
Expand All @@ -108,8 +108,8 @@ public UInt256 Add_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class AddSigned : SignedTwoParamBenchmarkBase
{
Expand All @@ -127,8 +127,8 @@ public Int256 Add_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class SubtractUnsigned : UnsignedTwoParamBenchmarkBase
{
Expand All @@ -146,8 +146,8 @@ public UInt256 Subtract_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class SubtractSigned : SignedTwoParamBenchmarkBase
{
Expand All @@ -165,8 +165,8 @@ public Int256 Subtract_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class AddModUnsinged : UnsignedThreeParamBenchmarkBase
{
Expand All @@ -184,8 +184,8 @@ public UInt256 AddMod_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class AddModSinged : SignedThreeParamBenchmarkBase
{
Expand All @@ -203,8 +203,8 @@ public Int256 AddMod_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class SubtractModUnsinged : UnsignedThreeParamBenchmarkBase
{
Expand All @@ -222,8 +222,8 @@ public UInt256 SubtractMod_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class SubtractModSigned : SignedThreeParamBenchmarkBase
{
Expand All @@ -241,8 +241,8 @@ public Int256 SubtractMod_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class MultiplyUnsigned : UnsignedTwoParamBenchmarkBase
{
Expand All @@ -260,8 +260,8 @@ public UInt256 Multiply_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class MultiplySigned : SignedTwoParamBenchmarkBase
{
Expand All @@ -279,8 +279,8 @@ public Int256 Multiply_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class MultiplyModUnsigned : UnsignedThreeParamBenchmarkBase
{
Expand All @@ -298,8 +298,8 @@ public UInt256 MultiplyMod_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class MultiplyModSigned : SignedThreeParamBenchmarkBase
{
Expand All @@ -317,8 +317,8 @@ public Int256 MultiplyMod_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class DivideUnsigned : UnsignedTwoParamBenchmarkBase
{
Expand All @@ -336,8 +336,8 @@ public UInt256 Divide_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class DivideSigned : SignedTwoParamBenchmarkBase
{
Expand All @@ -355,8 +355,8 @@ public Int256 Divide_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class ExpUnsigned : UnsignedIntTwoParamBenchmarkBase
{
Expand All @@ -374,8 +374,8 @@ public UInt256 Exp_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class ExpSigned : SignedIntTwoParamBenchmarkBase
{
Expand All @@ -393,8 +393,8 @@ public Int256 Exp_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class ExpModUnsigned : UnsignedThreeParamBenchmarkBase
{
Expand All @@ -412,8 +412,8 @@ public UInt256 ExpMod_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class ExpModSigned : SignedBenchmarkBase
{
Expand All @@ -440,8 +440,8 @@ public Int256 ExpMod_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class LeftShiftUnsigned : UnsignedIntTwoParamBenchmarkBase
{
Expand All @@ -459,8 +459,8 @@ public UInt256 LeftShift_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class LeftShiftSigned : SignedIntTwoParamBenchmarkBase
{
Expand All @@ -478,8 +478,8 @@ public Int256 LeftShift_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class RightShiftUnsigned : UnsignedIntTwoParamBenchmarkBase
{
Expand All @@ -497,8 +497,8 @@ public UInt256 RightShift_UInt256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class RightShiftSigned : SignedIntTwoParamBenchmarkBase
{
Expand All @@ -516,8 +516,8 @@ public Int256 RightShift_Int256()
}
}

[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[NoIntrinsicsJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser]
public class IsZeroOne
{
Expand Down
4 changes: 3 additions & 1 deletion src/Nethermind.Int256.Benchmark/NoIntrinsicsJobAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
Expand Down Expand Up @@ -116,6 +116,8 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
return CoreRuntime.Core70;
case RuntimeMoniker.Net80:
return CoreRuntime.Core80;
case RuntimeMoniker.Net90:
return CoreRuntime.Core90;
case RuntimeMoniker.Mono:
return MonoRuntime.Default;
case RuntimeMoniker.NativeAot60:
Expand Down
Loading

0 comments on commit 7d7b936

Please sign in to comment.