This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/19920] RFE: test whether a block of memory is all 0
- From: "peter.maydell at linaro dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 07 Apr 2016 11:52:49 +0000
- Subject: [Bug libc/19920] RFE: test whether a block of memory is all 0
- Auto-submitted: auto-generated
- References: <bug-19920-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=19920
Peter Maydell <peter.maydell at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |peter.maydell at linaro dot org
--- Comment #1 from Peter Maydell <peter.maydell at linaro dot org> ---
(In reply to Dr. David Alan Gilbert from comment #0)
> The current qemu implementation is:
> size_t buffer_find_nonzero_offset(const void *buf, size_t len)
>
> that returns an index to the first !0 byte;
This isn't quite right -- it returns an index which is definitely
earlier than the first nonzero byte, and this is actually where
it gets a lot of the speedup from: you test the buffer 64 bytes
at a time (say), and your loop body only needs to check "is any of
these 64 bytes nonzero?" rather than "find the first", so it
can just do a SIMD logical OR of everything together (and then
if something came out nonzero you return the index of the start
of this 64-byte chunk).
> however all of our current
> uses are just for testing whether the whole buffer is zero.
A straightforward boolean return is probably a cleaner API in
any case, though.
--
You are receiving this mail because:
You are on the CC list for the bug.