Total number of CPU cores

Just starting out? Need help? Post your questions and find answers here.
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Total number of CPU cores

Post 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
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Total number of CPU cores

Post by boddhi »

On Windows:

Code: Select all

Define.SYSTEM_INFO SystemInfo
GetSystemInfo_(SystemInfo)
Debug SystemInfo\dwNumberOfProcessors
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
User avatar
STARGÅTE
Addict
Addict
Posts: 2260
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Total number of CPU cores

Post 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.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Re: Total number of CPU cores

Post 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?
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Total number of CPU cores

Post 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
bye,
Daniel
Post Reply