Created
May 23, 2022 18:03
-
-
Save lgolubyev/fec32a829598f04ecfca747aacf0b5ac to your computer and use it in GitHub Desktop.
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
pivate static int SumOdd_BranchFree_Parallel_NoChecks_BetterPorts(int[] array) | |
{ | |
int counterA = 0; | |
int counterB = 0; | |
int counterC = 0; | |
int counterD = 0; | |
fixed (int* data = &array[0]) | |
{ | |
var p = (int*)data; | |
var n = (int*)data; | |
for (var i = 0; i < array.Length; i += 4) | |
{ | |
counterA += (n[0] & 1) * p[0]; | |
counterB += (n[1] & 1) * p[1]; | |
counterC += (n[2] & 1) * p[2]; | |
counterD += (n[3] & 1) * p[3]; | |
p += 4; | |
n += 4; | |
} | |
return counterA + counterB + counterC + counterD; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment