staticbool cpu_supports_x86_64_v3() { conststaticbool result = ([] { #ifdef __AVX2__ // All known CPUs with AVX2 support x86-64-v3. If that's available at // build-time, the CPU we're building for must support it. // // This saves a few cycles in ifuncs, and potentially lets the linker's // `--gc-sections` remove x86_64_v2 functions when they'll never be used. returntrue; #else
__builtin_cpu_init(); return __builtin_cpu_supports("avx2"); #endif
})(); return result;
}
extern"C" {
DEFINE_IFUNC_FOR(memchr) { if (cpu_supports_x86_64_v3()) RETURN_FUNC(memchr_func_t, portable_simd_memchr_avx2);
RETURN_FUNC(memchr_func_t, portable_simd_memchr_sse);
}
MEMCHR_SHIM()
// While we do want to keep alphabetical order, memcpy calls this, so place it // above that.
DEFINE_IFUNC_FOR(memmove) { if (cpu_supports_x86_64_v3()) RETURN_FUNC(memmove_func_t, memmove_avx2);
RETURN_FUNC(memmove_func_t, memmove_generic);
}
MEMMOVE_SHIM()
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.