Pop-Up Thingie
Sidebar
d0p3 BBS
Home
Forum
Files
Dark
Register
Log in
Username
Password
Sidebar
Forum
Fidonet
COMP.LANG.C++
The fastest strlen() ever
From
Bonita Montero
@3:633/10 to
All
on Wed Nov 19 15:02:01 2025
size_t xstrlen( char const *s )
{
ÿ ÿ char const *begin = s;
ÿ ÿ __m512i zero = _mm512_setzero_si512();
ÿ ÿ uintptr_t
ÿ ÿ ÿ ÿ up = (uintptr_t)s,
ÿ ÿ ÿ ÿ base = up & ~(uintptr_t)63;
ÿ ÿ unsigned skip = (unsigned)(up - base);
ÿ ÿ s = (char *)base;
ÿ ÿ uint64_t matches = _mm512_cmpeq_epi8_mask( _mm512_load_si512( (void
*)s ), zero );
ÿ ÿ matches = matches >> skip;
ÿ ÿ if( matches )
ÿ ÿ ÿ ÿ return countr_zero( matches );
ÿ ÿ s += 64;
ÿ ÿ for( ; ; s += 64 )
ÿ ÿ ÿ ÿ if( matches = _mm512_cmpeq_epi8_mask( _mm512_load_si512( (void
*)s ), zero ); matches )
ÿ ÿ ÿ ÿ ÿ ÿ return s - begin + countr_zero( matches );
}
Everything with AVX-512.
--- PyGate Linux v1.5
* Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
Who's Online
Recent Visitors
John F Kennedy
Thu Nov 20 14:53:19 2025
from
crazyworldbbs.com:2323
via
Telnet
Guest
Sat Nov 22 17:37:30 2025
from
Meh. Nah
via
Telnet
Guest
Wed Nov 26 06:46:07 2025
from
Gremlintown, Az
via
Telnet
Guest
Thu Nov 27 12:02:51 2025
from
Gremlintown, Az
via
Raw
System Info
Sysop:
Tetrazocine
Location:
Melbourne, VIC, Australia
Users:
14
Nodes:
8 (
0
/
8
)
Uptime:
09:26:50
Calls:
184
Files:
21,502
Messages:
79,221