-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The transformation of encoder kernels to inline functions (#58) allows us to move the inner encoding loop into separate inline functions. Because the number of remaining loop iterations is known, we can split calls to the inner loop into long unrolled stretches. Tests show that this can result in significant speedups.
- Loading branch information
Showing
8 changed files
with
342 additions
and
135 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,58 @@ | ||
static inline void | ||
enc_loop_neon32 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen) | ||
enc_loop_neon32_inner (const uint8_t **s, uint8_t **o) | ||
{ | ||
size_t rounds = *slen / 48; | ||
// Load 48 bytes and deinterleave: | ||
uint8x16x3_t src = vld3q_u8(*s); | ||
|
||
*slen -= rounds * 48; // 48 bytes consumed per round | ||
*olen += rounds * 64; // 64 bytes produced per round | ||
// Reshuffle: | ||
uint8x16x4_t out = enc_reshuffle(src); | ||
|
||
while (rounds-- > 0) { | ||
// Translate reshuffled bytes to the Base64 alphabet: | ||
out = enc_translate(out); | ||
|
||
// Load 48 bytes and deinterleave: | ||
uint8x16x3_t src = vld3q_u8(*s); | ||
// Interleave and store output: | ||
vst4q_u8(*o, out); | ||
|
||
// Reshuffle: | ||
uint8x16x4_t out = enc_reshuffle(src); | ||
*s += 48; | ||
*o += 64; | ||
} | ||
|
||
// Translate reshuffled bytes to the Base64 alphabet: | ||
out = enc_translate(out); | ||
static inline void | ||
enc_loop_neon32 (const uint8_t **s, size_t *slen, uint8_t **o, size_t *olen) | ||
{ | ||
size_t rounds = *slen / 48; | ||
|
||
// Interleave and store output: | ||
vst4q_u8(*o, out); | ||
*slen -= rounds * 48; // 48 bytes consumed per round | ||
*olen += rounds * 64; // 64 bytes produced per round | ||
|
||
*s += 48; | ||
*o += 64; | ||
while (rounds > 0) { | ||
if (rounds >= 8) { | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
rounds -= 8; | ||
continue; | ||
} | ||
if (rounds >= 4) { | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
rounds -= 4; | ||
continue; | ||
} | ||
if (rounds >= 2) { | ||
enc_loop_neon32_inner(s, o); | ||
enc_loop_neon32_inner(s, o); | ||
rounds -= 2; | ||
continue; | ||
} | ||
enc_loop_neon32_inner(s, o); | ||
break; | ||
} | ||
} |
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
Oops, something went wrong.