Page 1 of 1

Total number of CPU cores

Posted: Fri Jun 14, 2024 11:06 pm
by PBJim
Is there a way to obtain information indicating the same total number of CPU cores that the Windows O/S reports and is also reported by other software I'm using?

For the PureBasic function CountCPUs() the documentation indicates that it returns "the total number of CPU cores installed in the computer", but it only shows me the result "2" whereas Windows shows me "2" cores x "2" logical processors — please see image below.

Code: Select all

Debug CountCPUs(#PB_System_CPUs);  * Returns 2
Another software that I happen to use, indicates the machine has 4 cores, the same as Windows reports :

Image

I see that CountCPUs() has a further 'type' of #PB_System_ProcessCPUs, showing the number of cores available to the process, which is also 2. I don't think this is the relevant value.

A thread on the forum, shows alternative code to establish the number of cores, presumably pre-dating the CountCPUs() function, but this also returns only a value of "2" — https://www.purebasic.fr/english/viewtopic.php?t=42544

Re: Total number of CPU cores

Posted: Fri Jun 14, 2024 11:22 pm
by boddhi
On Windows:

Code: Select all

Define.SYSTEM_INFO SystemInfo
GetSystemInfo_(SystemInfo)
Debug SystemInfo\dwNumberOfProcessors

Re: Total number of CPU cores

Posted: Fri Jun 14, 2024 11:26 pm
by STARGÅTE
Actually, you have only 2 CPUs.
I don't understand your calculation of "2" cores x "2" logical processors.
"2 logical processors" is already the total number of logical processors and it is returned by CountCPUs().
There is no multiplication of addition.
Not sure what is done in your first screenshot, but it seems wrong.

In my case, CountCPUs() gives 24.
Windows shows me: 12 cores and 24 processors.
So everything is correct.

Re: Total number of CPU cores

Posted: Sat Jun 15, 2024 10:00 am
by PBJim
Thanks Boddhi and STARGÅTE

It seems JPEGView's reporting of there being 4 cores may be incorrect, or perhaps it means something different in relation to the threads it launched.

STARGÅTE, for your Ryzen CPU, the reviews use the term "threads", rather than "processors".
The Ryzen 9 3900X is a 12-core/24-thread processor, a 50% increase in core counts right off the bat against the Core i9-9900K.
I always thought 1 processor could have multiple cores, for instance Intel's popular dual-core processor, which I assume was 1 processor, containing 2 cores — not the other way around, where you have half a core in each processor :D

PB's CountCPUs() function says it returns 'cores' according to the documentation, and your processor has 12 cores. But PB returns 24. So it isn't returning cores?

Re: Total number of CPU cores

Posted: Sat Jun 15, 2024 10:07 am
by DarkDragon
You probably have hyperthreading disabled, which was advised during spectre/meltdown era.

As STARGATE said, the Task manager shows the number of Cores inside your processor and the "virtual threads" as Logical processors