I'm working on some MMX/SSE/SSE2/3DNOW/etc optimizations.  Distribution
maintainers will probably not want to provide umpteen different binaries
for each variant, so it would be best that, as an option, all 
optimizations can be compiled in at once and selected after a cpuid
test at runtime.  Should we centralize the cpuid test?  In libgg
or libggi?  e.g. something like:

/* In libgg */

enum _gg_swar_type {
        GG_SWAR_NONE,
        GG_SWAR_64BITC,
        GG_SWAR_MMX,
        GG_SWAR_SSE,
        GG_SWAR_SSE2,
        GG_SWAR_3DNOW,

        /* ... more for other architectures and chipset sub-variants */
}

enum gg_swar_type ggWhatSwar(void);

/* In sublib code */

static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh,
                        const char *args, void *argptr, uint32 *dlret)
{
        enum gg_swar_type swar;
        swar = _ggWhatSwar();

        switch (swar) {
#ifdef _GGI_CONF_SWAR_NONE_SELECTED
#define __GOT_SWAR
        case GG_SWAR_NONE:
        myswarfunctable = myswarfuncs_noswar;
        break;
#endif
#ifdef _GGI_CONF_SWAR_MMX_SELECTED
#define __GOT_SWAR
        case GG_SWAR_NONE:
        myswarfunctable = myswarfuncs_mmx;
        break;
#endif  
        default:
        fprintf(stderr, "sublib not compiled for requested SWAR!")
        };

        /*...*/

}

#ifndef __GOT_SWAR
#error SWAR_NONE or SWAR_MMX must be selected to compile this sublib!
#endif

FYI: SWAR == SIMD Within A Register     

Any thoughts?

--
Brian

Reply via email to