Denis Yaroshevskiy
So, what's this about?
std::size_t strlen(const char* s) {
using wide = eve::wide<char>;
const wide zeroes{0};
aligned_ptr aligned_s =
previous_aligned_address<sizeof(wide)>(s);
wide cur{aligned_s};
ignore_first ignore(s - aligned_s.get());
std::optional match = first_true(cur == zeroes, ignore);
while (!match) {
aligned_s += wide::static_size;
cur = wide{aligned_s};
match = first_true(cur == zeroes, ignore_none);
}
return static_cast<std::size_t>(aligned_s.get() + *match - s);
}
std::size_t strlen(const char* s) {
using wide = eve::wide<char>;
const wide zeroes{0};
aligned_ptr aligned_s =
previous_aligned_address<sizeof(wide)>(s);
wide cur = load_unsafe(aligned_s, as_<wide>{});
ignore_first ignore(s - aligned_s.get());
std::optional match = first_true(cur == zeroes, ignore);
while (!match) {
aligned_s += wide::static_size;
cur = load_unsafe(aligned_s, as_<wide>{});
match = first_true(cur == zeroes, ignore_none);
}
return static_cast<std::size_t>(aligned_s.get() + *match - s);
}
write strlen
https://denisyaroshevskiy.github.io/my_first_simd_1_presentation
template <typename Slide, /*...*/>
NOINLINE void benmark_body(Slide slide, benchmark::State& state, /* ... */) {
noop_slide(slide); // asm volatile("nop");
for (auto _ : state) {
// measure this
}
}