View crc32_expert_avx2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe uint ChecksumExpertAvx2(ReadOnlySpan<byte> arr) | |
{ | |
ref byte refSpan = ref MemoryMarshal.GetReference<byte>(arr); | |
var z = 0; | |
uint sum = 0; | |
var vectorSum = Avx2.Xor(Vector256<byte>.Zero, Vector256<byte>.Zero).AsUInt32(); | |
var mask = Vector256.Create((byte)3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12, (byte)3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12); |
View crc32_expert_avx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe uint ChecksumExpertAvx(ReadOnlySpan<byte> arr) | |
{ | |
ref byte refSpan = ref MemoryMarshal.GetReference<byte>(arr); | |
uint z = 0; | |
uint sum = 0; | |
var vectorSum = Avx.Xor(Vector128<byte>.Zero, Vector128<byte>.Zero).AsUInt32(); | |
var mask = Vector128.Create((byte)3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12); |
View crc32_expert.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe uint ChecksumExpert(ReadOnlySpan<byte> arr) | |
{ | |
if (arr.Length == 0) return 0; | |
fixed (byte* ptr = arr) | |
{ | |
uint sum = 0; | |
int z = 0; | |
var limit = arr.Length - 32; |
View crc32_bigendian.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe uint Checksum(ReadOnlySpan<byte> arr) | |
{ | |
if (arr.Length == 0) return 0; | |
fixed (byte* ptr = arr) | |
{ | |
uint sum = 0; | |
int z = 0; | |
var limit = arr.Length - 4; |
View crc32_hacker_expanded.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public unsafe static uint ChecksumHackerExpanded(ReadOnlySpan<byte> arr) | |
{ | |
if (arr.Length == 0) return 0; | |
fixed (byte* ptr = arr) | |
{ | |
uint sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0; | |
uint z = 0; | |
int rem = arr.Length % 32; |
View crc32_hacker.asm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
G_M000_IG06: ;; offset=007BH | |
mov r15d, r11d | |
mov r12, qword ptr [rdx+r15] | |
mov r13, qword ptr [rdx+r15+08H] | |
mov rdi, qword ptr [rdx+r15+10H] | |
mov r15, qword ptr [rdx+r15+18H] | |
mov rcx, 0xFF00FF00FF00FF | |
and rcx, r12 | |
add rsi, rcx | |
mov rcx, 0xFF00FF00FF00FF |
View crc32_hacker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public unsafe static uint ChecksumHacker(ReadOnlySpan<byte> arr) | |
{ | |
if (arr.Length == 0) return 0; | |
fixed (byte* ptr = arr) | |
{ | |
uint sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0; | |
uint z = 0; | |
ulong tmp0 = 0, tmp1 = 0; |
View crc32_expert.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public unsafe static uint ChecksumExpert(ReadOnlySpan<byte> arr) | |
{ | |
if (arr.Length == 0) return 0; | |
fixed (byte* ptr = arr) | |
{ | |
uint sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0; | |
uint z = 0; | |
int rem = arr.Length % 32; |
View example.asm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//while (z < limit) | |
// { | |
// sum0 += (uint)(ptr[z + 0] + ptr[z + 4] + ptr[z + 8] + ptr[z + 12] | |
//PRO | |
G_M000_IG06: | |
cmp r11d, ecx | |
jae G_M000_IG17 | |
mov ebx, r11d | |
movzx rbx, byte ptr [rdx+rbx] |
View pointer_access_example.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe int PointerAccessInt(byte* ptr,int x,int y) | |
{ | |
return ptr[x]& ptr[x+y]; | |
} | |
public static unsafe int PointerAccessUInt(byte* ptr,uint x,uint y) | |
{ | |
return ptr[x]& ptr[x+y]; | |
} |
NewerOlder