I posted a method checking a byte[] for being all zeroes. Mono.Simd offers so high performance that I am wondering if this is even possible.
static unsafe bool IsAllZeros(byte[] data)
{
fixed (byte* bytes = data) {
int len = data.Length;
int rem = len % (16*16);
Vector16b* b = (Vector16b*)bytes;
Vector16b* e = b + len / (16*16);
Vector16b zero = Vector16b.Zero;
while (b < e) {
if ((*(b)|*(b+1)|*(b+2)|*(b+3)|*(b+4)|*(b+5)|*(b+6)|*(b+7)|*(b+8)|
*(b+9)|*(b+10)|*(b+11)|*(b+12)|*(b+13)|*(b+14)|*(b+15)) != zero)
return false;
b += 16;
}
for (int i = 0; i < rem; i++)
if (data [len - 1 - i] != 0)
return false;
return true;
}
}
Code above processes 256 MB in 2,6477 ms giving 94 GB/s. Is this even possible?
My DDR2 memory has 800 Mhz frequency. Wikipedia gives a formula for a theoretical maximum bandwidth as 800M*2*64*2 = 25 GB/s.