Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Unroll loop in convert_to_phi
Browse files Browse the repository at this point in the history
This yields a 10% CPU savings vs the original single value per loop
iteration implementation on a Raspberry Pi 2 Model B.
  • Loading branch information
toofishes committed May 9, 2016
1 parent d08035b commit b0958f4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dump978.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,18 @@ static void convert_to_phi(uint16_t *buffer, int n)
{
int i;

for (i = 0; i < n; ++i)
// unroll the loop. n is always > 2048, usually 36864
for (i = 0; i+8 <= n; i += 8) {
buffer[i] = iqphase[buffer[i]];
buffer[i+1] = iqphase[buffer[i+1]];
buffer[i+2] = iqphase[buffer[i+2]];
buffer[i+3] = iqphase[buffer[i+3]];
buffer[i+4] = iqphase[buffer[i+4]];
buffer[i+5] = iqphase[buffer[i+5]];
buffer[i+6] = iqphase[buffer[i+6]];
buffer[i+7] = iqphase[buffer[i+7]];
}
for (; i < n; ++i)
buffer[i] = iqphase[buffer[i]];
}

Expand Down

0 comments on commit b0958f4

Please sign in to comment.