Processor Capacity(size) in c++

-4

how to get processor capacity(maxclockspeed) in generic way windows.

Here I tried withe this sample its working fine for the Intel processor but fails in AMD processor.

// Get extended ids.
char ProcessorName[0x200];
int CPUInfo[4] = {-1};
__cpuid(CPUInfo, 0x80000000);
unsigned int nExIds = CPUInfo[0];

// Get the information associated with each extended ID.
for( unsigned int i=0x80000000; i<=nExIds; ++i)
{
    __cpuid(CPUInfo, i);

    // Interpret CPU brand string and cache information.
   if  (i == 0x80000008)
    {
        memcpy( ProcessorName, CPUInfo, sizeof(CPUInfo));
    }
    else if( i == 0x80000009 )
    {
        memcpy( ProcessorName + 16, CPUInfo, sizeof(CPUInfo));
    }
    else if( i == 0x80000007 )
    {
        memcpy(ProcessorName + 32, CPUInfo, sizeof(CPUInfo));
    }
}

fprintf_s(log_file,"Processor Name : %s",ProcessorName);

OUTPUT :  Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz

using above output I read only 3.30GHz CPU capacity, but the above code not works for AMD.

Please suggest me any generic method in c++ API or methods to get CPU capacity in both Intel and AMD.

c++
intel
amd
processor
asked on Stack Overflow Jul 23, 2018 by Krish

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0