[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] cpuid on MSVC
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 24 Jun 2010 09:40:48 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=SmSEji4B692aP8dJ36KNbp6caECuurakDb6YlNZoQqs=; b=ggoq5bpgSITKOLHFaqEBEqgsWIUT31/YSZgNAupIgH0uL3kuw2vHdI74QlE/i/FzPM 0t7YRlyjpr/zuWtHwxlKqTYDdfzocNVrMXQHLT2abk7udCjCYlbAe+A3ox7SaO2YVgX8 sxG/NP2hcMwRnrjMkDgufZfwLVwwBX1M+f5ks=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=SlrwILSxnd81CDdDaKKo3H5Y7VCg6UroIj7Z6AKyQuw7m9JvfjLEPdOUS5u6w+UJ7t bi5xqdsiFw3/h1r+1PeJFmRgakHtQ5MZ5ii/MkmikV0cDTjEE/0vWtZt8/YMZh/uB1Sa opIhaPLNSmy5tbgfuW6gfa7cBZgNNPWO/872E=
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 :)
gael