_cpuid extension

_cpuid extension

I would like to suggest an extension for __cpuid whereby you can supply the ECX value as well as the EAX value. Implemented as an overload __cpuid(CPUinfo, CpuType, ecxValue) or as a seperate intrinsic __cpuidEX(CPUinfo, CpuType, ecxValue) . Example:

DWORD index = 0;
struct DeterministicCacheParameters
{
  unsigned CacheType : 5;
  unsigned CacheLevel : 3;
  unsigned SelfInitializing : 1;
  unsigned FullyAssociative : 1;
  unsigned ReservedEAX : 4;
  unsigned MaxThreadsLess1 : 12;
  unsigned MaxCoresLess1 : 6;
  unsigned SystemCoherencyLineSizeLess1 : 12;
  unsigned PhysicalLinesPartitionsLess1 : 10;
  unsigned WaysOfAssociativityLess1 : 10;
  unsigned NumberOfSetsLess1 : 32;
  unsigned PrefetchStride : 10;
  unsigned ReservedEDX : 22;
};
union
{
  int CPUInfoCacheParameters[4];
  DeterministicCacheParameters CacheParameters;
};
while(true)
{
  __cpuidEX(CPUInfoCacheParameters, 4, index);
  if((CPUInfoCacheParameters[0]&15) == 0) break;
  ... // extract and disseminate info
  ++index;
}

Jim Dempsey

www.quickthreadprogramming.com
1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.