MCPcopy Create free account
hub / github.com/numpy/numpy / count_zero_bytes_u8

Function count_zero_bytes_u8

numpy/core/src/multiarray/item_selection.c:2403–2420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2401#if NPY_SIMD
2402/* Count the zero bytes between `*d` and `end`, updating `*d` to point to where to keep counting from. */
2403NPY_FINLINE NPY_GCC_OPT_3 npyv_u8
2404count_zero_bytes_u8(const npy_uint8 **d, const npy_uint8 *end, npy_uint8 max_count)
2405{
2406 const npyv_u8 vone = npyv_setall_u8(1);
2407 const npyv_u8 vzero = npyv_zero_u8();
2408
2409 npy_intp lane_max = 0;
2410 npyv_u8 vsum8 = npyv_zero_u8();
2411 while (*d < end && lane_max <= max_count - 1) {
2412 // we count zeros because `cmpeq` cheaper than `cmpneq` for most archs
2413 npyv_u8 vt = npyv_cvt_u8_b8(npyv_cmpeq_u8(npyv_load_u8(*d), vzero));
2414 vt = npyv_and_u8(vt, vone);
2415 vsum8 = npyv_add_u8(vsum8, vt);
2416 *d += npyv_nlanes_u8;
2417 lane_max += 1;
2418 }
2419 return vsum8;
2420}
2421
2422NPY_FINLINE NPY_GCC_OPT_3 npyv_u16x2
2423count_zero_bytes_u16(const npy_uint8 **d, const npy_uint8 *end, npy_uint16 max_count)

Callers 1

count_zero_bytes_u16Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected