Skip to content

Commit ac51bba

Browse files
committed
improve data locality, reduce pipeline stalls
1 parent b80f953 commit ac51bba

10 files changed

Lines changed: 2703 additions & 2107 deletions

src/Blake2Fast/Blake2b.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ unsafe internal partial struct Blake2bContext : IBlake2Incremental
3131
private fixed ulong h[HashWords];
3232
private fixed ulong t[2];
3333
private fixed ulong f[2];
34+
#if USE_INTRINSICS
35+
private fixed ulong viv[HashWords];
36+
private fixed byte vrm[32];
37+
#endif
3438
private uint c;
3539
private uint outlen;
3640

@@ -89,6 +93,11 @@ public void Init(int outlen = HashBytes, byte[] key = null)
8993
this.h[0] ^= 0x01010000u ^ (keylen << 8) ^ (uint)outlen;
9094
this.outlen = (uint)outlen;
9195

96+
#if USE_INTRINSICS
97+
Unsafe.CopyBlock(ref Unsafe.As<ulong, byte>(ref this.viv[0]), ref Unsafe.As<ulong, byte>(ref iv[0]), HashBytes);
98+
Unsafe.CopyBlock(ref this.vrm[0], ref rormask[0], 32);
99+
#endif
100+
92101
if (keylen > 0)
93102
{
94103
#if FAST_SPAN

0 commit comments

Comments
 (0)