Re: [eigen] Performance gap between gcc and msvc ?

[ Thread Index | Date Index | More Archives ]

If that might help, I use the following code in one of my project to get a working 'cpuid' across compilers:
(inside a proper #ifdef for x86/amd64, of course):

#if defined(__GNUC__)
#    if defined(__PIC__) && defined(__i386__)
#    define cpuid(abcd,func) \
        __asm__ __volatile__ ("xchgl %%ebx, %%esi;cpuid; xchgl %%ebx,%%esi": "=a" (abcd[0]), "=S" (abcd[1]), "=c" (abcd[2]), "=d" (abcd[3]) : "a" (func));
#    else
#    define cpuid(abcd,func) \
        __asm__ __volatile__ ("cpuid": "=a" (abcd[0]), "=b" (abcd[1]), "=c" (abcd[2]), "=d" (abcd[3]) : "a" (func) );
#    endif
#elif defined(_MSC_VER)
#    define cpuid(abcd,func) __cpuid((int*)abcd,func)

#ifndef cpuid
#error "Failed to find a way to get cpuid() for this architecture."

(and wikipedia describes what you can get, very useful :-)

Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>

In data venerdì 18 giugno 2010 23:42:50, Benoit Jacob ha scritto:
> ok, looks what we need is just the CPUID instruction.
> apparently this is what linux uses for /proc/cpuinfo.

Mail converted by MHonArc 2.6.19+