Skip to content

Instantly share code, notes, and snippets.

@geofflangdale
Created June 5, 2018 05:21
Show Gist options
  • Save geofflangdale/289a5b870af351a3756793f121399e10 to your computer and use it in GitHub Desktop.
Save geofflangdale/289a5b870af351a3756793f121399e10 to your computer and use it in GitHub Desktop.
template <typename T>
void match_multiple_smh(T & smh, std::vector<u8 *> & buffers, std::vector<size_t> & lengths,
std::vector<u32> & results) {
u32 i = 0;
#ifndef NO_UNROLL
for (; i+7 < buffers.size(); i+=8) {
results[i+0] = smh.match(buffers[i+0], lengths[i+0]); LFENCE
results[i+1] = smh.match(buffers[i+1], lengths[i+1]); LFENCE
results[i+2] = smh.match(buffers[i+2], lengths[i+2]); LFENCE
results[i+3] = smh.match(buffers[i+3], lengths[i+3]); LFENCE
results[i+4] = smh.match(buffers[i+4], lengths[i+4]); LFENCE
results[i+5] = smh.match(buffers[i+5], lengths[i+5]); LFENCE
results[i+6] = smh.match(buffers[i+6], lengths[i+6]); LFENCE
results[i+7] = smh.match(buffers[i+7], lengths[i+7]); LFENCE
}
#endif
for (; i < buffers.size(); ++i) {
results[i] = smh.match(buffers[i], lengths[i]); LFENCE
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment