LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug with CPU Information

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. 

 

snip.png

 

 

0 Kudos
Message 11 of 15
(208 Views)

@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. 

 

snip.png

 

 


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

 

snippet.png

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).

0 Kudos
Message 12 of 15
(188 Views)

Hi Andrey,

 

the latest  CoreUltra200 come with P-cores without SMT:

And some even come with two different kind of E-cores ("low power" and "even lower power")…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 13 of 15
(179 Views)

@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.

 

0 Kudos
Message 14 of 15
(165 Views)

@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.

0 Kudos
Message 15 of 15
(152 Views)