CallNtPowerInformation fails with Processor Group

On a system which has more than 32 processors CallNtPowerInformation fails. I Googled found even on the CallNtPowerInformation MSDN page a Microsoft Employee also has complained the same thing but no one seems to know what is the alternate call, method to get the power information. I have to deal with 72, 144 processor systems so any help, pointer would be highly appreciated.

Some days I feel like a broken record: “We want to help you. Please explain to us the overall, larger, goal you are trying to accomplish so we CAN try to help you.”

Peter
OSR
@OSRDrivers

Wow! I am honored that you read my appeal!! I inherited a tool which has been working fine in the past and tried it on a 72 proc system and saw that it returned with data for only P0-P31. Processor 32 and beyond were all zeros. I Googled and found lot of people had complained on this but no one seems to know the solution.

I am calling it with ProcessorInformation(11) and expecting the data back in PROCESSOR_POWER_INFORMATION. I am running on Windows Server 2012 R2 which is NOT a supported OS. I am including PowrProf.h and powrprof.lib. Normally MSFT provides a call like ExCallNtPowerInformation() or there must be a total different way to fill the PROCESSOR_POWER_INFORMATION or a similar structure which will provide the information I want. I hope you have given all possible info. Thanks in advance.

Ah! I got break through!! It seems I have to set the Group Affinity to the corresponding group to see the information for P36 to P72. In this case I have to set it to Group 2 and redo the CallNtPowerInformation call. So Peter please hold on let me work on that and if it works then I come back ans close this case. On a 144 proc system I will have to run CallNtPowerInformation() 4 times setting the group affinity each time.

Problem solved and case closed. I am surprised that this question has been asked by so many and no one has answered. Peter just the fact that there is some one to back you you up helps. Thanks! Here is the full solution. Please include powrprof.lib. I used VS2010 Ultimate for the compile and tested on a Windows Server 2012 R2 72 and 144 proc systems

*******************************************************
#include <windows.h>
#include <stdio.h>
#include <winioctl.h>
#include <intrin.h>
#include <powrprof.h>

typedef struct _PROCESSOR_POWER_INFORMATION {
ULONG Number;
ULONG MaxMhz;
ULONG CurrentMhz;
ULONG MhzLimit;
ULONG MaxIdleState;
ULONG CurrentIdleState;
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;

int GetCurrentFreqPercentVista(HANDLE hThread, int noOfLogicalCores)
{
int RetVal;
PROCESSOR_POWER_INFORMATION ProcessorPowerInformation[36];
int FreqPercent = 0;
GROUP_AFFINITY ga;

memset(ProcessorPowerInformation, 0xFF, sizeof(ProcessorPowerInformation));
GetThreadGroupAffinity(hThread, &ga); // Confirmning the thread did get afdfinitized to the correct group
printf(“Getting power info of processors in Group %d\n”, ga.Group);
RetVal = CallNtPowerInformation(ProcessorInformation,
NULL,
0,
&ProcessorPowerInformation,
sizeof(PROCESSOR_POWER_INFORMATION) * noOfLogicalCores);
return RetVal;
}

void
main()
{
int grp;
HANDLE hThread;
GROUP_AFFINITY ga, pga;
int grCount = 4;
int procCount = 36;

ZeroMemory(&ga, sizeof(GROUP_AFFINITY));

ga.Mask = 0xFFFFFFFF;

hThread = GetCurrentThread();
for (grp = 0; grp < grCount; grp++) {
ga.Group = grp;
if (!SetThreadGroupAffinity(hThread, &ga, &pga)) {
printf(“SetThreadGroupAffinity failed!!\n”);
ExitProcess(1);
}
GetCurrentFreqPercentVista(hThread, procCount);
}

}
******************************************* </powrprof.h></intrin.h></winioctl.h></stdio.h></windows.h>