GetCpuFreq
Obtain the CPU frequency:
HmppResult HMPP_GetCpuFreqMhz (int32_t *mhz);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
mhz |
Pointer to the CPU frequency |
The value cannot be NULL. |
Output |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The mhz pointer is NULL. |
HMPP_STS_NOT_SUPPORT |
Failed to obtain information. |
Example
void GetCpuFreq_Example()
{
int32_t mhz;
HmppResult result = HMPP_GetCpuFreqMhz(&mhz);
printf("%s\n", HMPP_GetStatusString(result));
printf("cpu frequency = %d Mhz\n", mhz);
}
Output:
No Error cpu frequency = 2600 Mhz
- The correct value can be returned only when this interface is called by the root user.
- The actual output may be different. You can call dmidecode -t processor | grep "Current" to compare the outputs.
Parent topic: Basic Functions