RE: [eigen] cpuid on MSVC

[ Thread Index | Date Index | More Archives ]

There are two version of the __cpuid intrinsic (at least on 2008 and 2010).
There is a __cpuidex which explicitly takes the ecx register as a parameter.

I hope that's what you where looking for.


-----Original Message-----
From: Listengine [mailto:listengine@xxxxxxxxxxxxxxxxx] On Behalf Of Gael Guennebaud
Sent: Donnerstag, 24. Juni 2010 09:41
To: eigen
Subject: [eigen] cpuid on MSVC

Hi msvc developers,

as some of you probably known, we are now using the cpuid instruction
to retrieve CPU cache sizes. To do so I need to provide to cpuid two
information: the function code in the eax register and the cache id in
ecx. However, the msvc __cpuid intrinsics seems to be too limited
since it only allows to set the function code. So I'd some help from
msvc gurus to write inline assembly code doing that. For the record
here is the GCC version:

define EIGEN_CPUID(abcd,func,id) \
       __asm__ __volatile__ ("cpuid": "=a" (abcd[0]), "=b" (abcd[1]),
"=c" (abcd[2]), "=d" (abcd[3]) : "a" (func), "c" (id) );

The assembly is one instruction only: cpuid, thes next four items
after the ":" are the outputs where "a" means eax register, "b" ==
ebx, etc. and the last two item are the inputs which are put into the
eax and ecx registers respectively.

The code is in eigen/Eigen/src/Core/util/Memory.h line 598.

thanks a lot :)


Mail converted by MHonArc 2.6.19+