01-08-2025 04:32 PM
Surprised this thread got that much traction. A few things, yes to caching the result. I like UIs to be responsive, and did not appreciate the lag in my system information window when querying this value. I did not include the caching aspect here.
The System Configuration VIs work, but, there seems to be an issue with its mutex. I called the function in two different locations, non reentrant VIs, one call was for the CPU core count, the other call was to determine if there were any PXI chassis connected. Not always, but enough to easily notice, I would get a weird error from the System Configuration Initialization vi. So beware if you use that call in multiple spots.
Lastly, below and v2019 attached, is another way to get the core count. The first call to the function is also slow. This was inspired by Andrey Dmitriev's 20 year old thread. It is not pretty. 🙂 It can probably be cleaned up by a dotNET savant.
01-09-2025 02:11 AM
@mcduff wrote:
...
Lastly, below and v2019 attached, is another way to get the core count. The first call to the function is also slow. This was inspired by Andrey Dmitriev's 20 year old thread. It is not pretty. 🙂 It can probably be cleaned up by a dotNET savant.
Well, nowadays I'll do probably something like that:
int GetCPUinfo (int *LVtotalLogical, int *LVtotalCores, int *LVpCores, int *LVeCores)
{
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
int totalLogicalProcessors = sysInfo.dwNumberOfProcessors;
DWORD length = 0;
GetLogicalProcessorInformationEx(RelationProcessorCore, NULL, &length);
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buffer = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)malloc(length);
if (!buffer || !length) return -1;
GetLogicalProcessorInformationEx(RelationProcessorCore, buffer, &length);
int totalCores = 0;
int pCores = 0;
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *ptr = buffer;
while ((char *)ptr < (char *)buffer + length) {
if (ptr->Relationship == RelationProcessorCore) {
totalCores++;
if (ptr->Processor.Flags == LTP_PC_SMT) {
pCores++;
}
}
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)((char *)ptr + ptr->Size);
}
int eCores = totalCores - pCores;
*LVtotalLogical = totalLogicalProcessors;
*LVtotalCores = totalCores;
*LVpCores = pCores;
*LVeCores = eCores;
free(buffer);
return 0;
}
Then
Test project (downgraded to LV2018) in the attachment, but I haven't appropriate CPU to test it.
NI CVI 2020 was used for DLL. (zip attachment with binaries wasn't accepted, therefore 7z).
01-09-2025 02:46 AM - edited 01-09-2025 02:52 AM
01-09-2025 04:06 AM
@GerdW wrote:
Hi Andrey,
the latest CoreUltra200 come with P-cores without SMT:
Good to know, thank you. May be I can modify this lib if time permit also in absence of real CPU with help of intel emulator.
01-09-2025 06:17 AM
@Andrey_Dmitriev wrote:
@GerdW wrote:
Hi Andrey,
the latest CoreUltra200 come with P-cores without SMT:
Good to know, thank you. May be I can modify this lib if time permit also in absence of real CPU with help of intel emulator.
No, I was too optimistic, the Intel Software Development Emulator can emulate any CPU in term of commands set (like SHA/AVX512 etc), but not P and E cores. On the other hand, impossible is nothing, it should be possible with help of cpuid, but this is which I can't do clearly without physical CPU for some reasons. Have to wait until I'll get it in my hands.