mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-29 07:14:12 +08:00
Proper CPUID
This commit is contained in:
parent
cdd8fdc32e
commit
e409795d6b
@ -1048,14 +1048,21 @@ inline void queryCacheSizes_intel(int& l1, int& l2, int& l3, int max_std_funcs)
|
|||||||
{
|
{
|
||||||
if(max_std_funcs>=4)
|
if(max_std_funcs>=4)
|
||||||
queryCacheSizes_intel_direct(l1,l2,l3);
|
queryCacheSizes_intel_direct(l1,l2,l3);
|
||||||
else
|
else if(max_std_funcs>=2)
|
||||||
queryCacheSizes_intel_codes(l1,l2,l3);
|
queryCacheSizes_intel_codes(l1,l2,l3);
|
||||||
|
else
|
||||||
|
l1 = l2 = l3 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void queryCacheSizes_amd(int& l1, int& l2, int& l3)
|
inline void queryCacheSizes_amd(int& l1, int& l2, int& l3)
|
||||||
{
|
{
|
||||||
int abcd[4];
|
int abcd[4];
|
||||||
abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
|
abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
|
||||||
|
|
||||||
|
// First query the max supported function.
|
||||||
|
EIGEN_CPUID(abcd,0x80000000,0);
|
||||||
|
if(abcd[0] >= 0x80000006)
|
||||||
|
{
|
||||||
EIGEN_CPUID(abcd,0x80000005,0);
|
EIGEN_CPUID(abcd,0x80000005,0);
|
||||||
l1 = (abcd[2] >> 24) * 1024; // C[31:24] = L1 size in KB
|
l1 = (abcd[2] >> 24) * 1024; // C[31:24] = L1 size in KB
|
||||||
abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
|
abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
|
||||||
@ -1063,6 +1070,11 @@ inline void queryCacheSizes_amd(int& l1, int& l2, int& l3)
|
|||||||
l2 = (abcd[2] >> 16) * 1024; // C[31;16] = l2 cache size in KB
|
l2 = (abcd[2] >> 16) * 1024; // C[31;16] = l2 cache size in KB
|
||||||
l3 = ((abcd[3] & 0xFFFC000) >> 18) * 512 * 1024; // D[31;18] = l3 cache size in 512KB
|
l3 = ((abcd[3] & 0xFFFC000) >> 18) * 512 * 1024; // D[31;18] = l3 cache size in 512KB
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l1 = l2 = l3 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
@ -1077,7 +1089,7 @@ inline void queryCacheSizes(int& l1, int& l2, int& l3)
|
|||||||
|
|
||||||
// identify the CPU vendor
|
// identify the CPU vendor
|
||||||
EIGEN_CPUID(abcd,0x0,0);
|
EIGEN_CPUID(abcd,0x0,0);
|
||||||
int max_std_funcs = abcd[1];
|
int max_std_funcs = abcd[0];
|
||||||
if(cpuid_is_vendor(abcd,GenuineIntel))
|
if(cpuid_is_vendor(abcd,GenuineIntel))
|
||||||
queryCacheSizes_intel(l1,l2,l3,max_std_funcs);
|
queryCacheSizes_intel(l1,l2,l3,max_std_funcs);
|
||||||
else if(cpuid_is_vendor(abcd,AuthenticAMD) || cpuid_is_vendor(abcd,AMDisbetter_))
|
else if(cpuid_is_vendor(abcd,AuthenticAMD) || cpuid_is_vendor(abcd,AMDisbetter_))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user