Re: [RFD] optimized versions of openssl
>> Michael Stone <mstone@debian.org> writes:
> Now for the real overachiever, what would be really cool is if you
> hacked openssl to do *runtime* detection of which optimizations to use.
That would be indeed much better. I blindly assumed he was talking
about compiler flags and I further assumed that openssl for some reason
exhibits an actual speedup thanks to those flags -- as opposed to the
usual 1% or so. If OpenSSL actually has hand-crafted processor
specific optimizations runtime detection would be indeed the way to go.
Even further, abstracting all this CPU detection stuff inside a library
would be the coolest thing. Something like:
struct cpu_optimized_function do_foobar_table[] = {
{ CPUDETECT_GENERIC, do_foobar_generic },
#if defined(INTEL...)
{ CPUDETECT_SSE, do_foobar_sse },
{ CPUDETECT_MMX, do_foobar_mmx },
#endif
#if defined(SPARC...)
{ CPUDETECT_SPARCV8, do_foobar_sv8 },
#endif
{ NULL, NULL }
};
/* ... */
do_foobar = pick_optimized_function(do_foobar_table);
Even better, hide the conditional inside a macro:
struct cpu_optimized_function do_foobar_table[] = {
CPUDETECT_GENERIC_ENTRY(do_foobar_generic)
CPUDETECT_SSE_ENTRY(do_foobar_sse)
CPUDETECT_MMX_ENTRY(do_foobar_mmx)
CPUDETECT_SV8_ENTRY(do_foobar_sv8)
CPUDETECT_LAST_ENTRY
};
something along those lines...
My guess is that this would foster runtime CPU detection since it
becomes a no-brainer.
--
Marcelo | "I can bite your leg if you like."
mmagallo@debian.org | -- Gaspode the wonder dog
| (Terry Pratchett, Moving Pictures)
Reply to: