cpuinfo module

Share your advanced PureBasic knowledge/code with the community.
alen
New User
New User
Posts: 7
Joined: Mon Sep 15, 2008 11:07 pm
Location: Germany

Re: cpuinfo module

Post by alen »

Hello,

Very nice !

Works great on my two Linux distributions with different Hardware:
- Fedora 23 - 64 Bit
- Manjaro Linux (Archlinux) - 64 Bit

Mini ITX Intel® Quad-Core Processor J1900 @ 2 Ghz
Dell Latitude E5430 with Intel® i5-3340M Processor @ 2,7 Ghz


Regards,
Alen
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: cpuinfo module

Post by RSBasic »

Image
GenuineIntel
Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz
4 cores
Running on core number 6
Running at 3300 mhz
SSE2 mode
(Tested on Windows 10 too.)
Image
Image
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: cpuinfo module

Post by idle »

RSBasic wrote:Image
GenuineIntel
Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz
4 cores
Running on core number 6
Running at 3300 mhz
SSE2 mode
(Tested on Windows 10 too.)
thanks for testing it
I'll have a look and see if I can check for threads per core since it says it's running on core 6 out of 4 cores
Windows 11, Manjaro, Raspberry Pi OS
Image
Helle
Enthusiast
Enthusiast
Posts: 178
Joined: Wed Apr 12, 2006 7:59 pm
Location: Germany
Contact:

Re: cpuinfo module

Post by Helle »

Hi idle,
even APIC_ID´s are for the phys.Cores (start with 0), odd APIC_ID´s are for the log.Cores (start with 1, if HT). Without HT the APIC_ID must div.2 for GetActiveCore():

Code: Select all

APIC_ID.l
j = 1
hThread = GetCurrentThread_()
OldThreadAffinityMask = SetThreadAffinityMask_(hThread, j) ;Save
While SetThreadAffinityMask_(hThread, j)
  Number_Threads + 1
  !MOV eax,1
  !CPUID
  !SHR ebx,24                ;Initial APIC ID. Bit24: 0=phys., 1=log.Core
  !TEST ebx,1
  !JNZ @f
  !mov [v_APIC_ID],ebx
 Debug APIC_ID               ;0, 2, 4, 6... with/without HT
  Number_Cores + 1 
  Core_Sequence$ + "P"
  !JMP NextCore
!@@:
  !mov [v_APIC_ID],ebx
 Debug APIC_ID               ;1, 3, 5, 7... with HT 
  Core_Sequence$ + "L"
  Hyper_Threading + 1
!NextCore:
  j << 1
Wend
SetThreadAffinityMask_(hThread, OldThreadAffinityMask)     ;Restore

If Hyper_Threading
  Hyper_Threading$ = "Yes"
 Else 
  Hyper_Threading$ = "No"
EndIf

Debug "----------"
Debug Number_Cores
Debug Number_Threads
Debug Core_Sequence$         ;Horror with AMD, I saw this with Bulldozer, confirmed with Pscheck (AMD Prog.)
Debug Hyper_Threading$
GetFrequency(): On CPUs with Invariant TSC (all new CPUs) this gives the Base-Clock (e.g. for Timings), not the "Running at ..."!

Helle
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: cpuinfo module

Post by davido »

Two of my machines produce the following:

PC - Windows 10
GenuineIntel
Intel(R) Core(TM) i7-5960X CPU @ 3.00GHz
16 cores
Running on core number 5
Running at 3030 mhz
SSE2 mode

MacBook Pro
GenuineIntel
Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
4 cores
Running on core number 1
Running at 3115 mhz
SSE2 mode
DE AA EB
BarryG
Addict
Addict
Posts: 4127
Joined: Thu Apr 18, 2019 8:17 am

Re: cpuinfo module

Post by BarryG »

How do you use #PB_CPU_HYPERVISOR from the original post in this thread? I tried the following line but I get an error about the constant #PB_CPU_HYPERVISOR not found, but it's in the Enumerations?

Code: Select all

Debug CPUInfo::IsCPU(#PB_CPU_HYPERVISOR)
tester
User
User
Posts: 34
Joined: Sun Dec 28, 2014 1:12 pm

Re: cpuinfo module

Post by tester »

BarryG wrote:How do you use #PB_CPU_HYPERVISOR from the original post in this thread? I tried the following line but I get an error about the constant #PB_CPU_HYPERVISOR not found, but it's in the Enumerations?

Code: Select all

Debug CPUInfo::IsCPU(#PB_CPU_HYPERVISOR)

Code: Select all

Debug CPUInfo::IsCPU(CPUInfo::#PB_CPU_HYPERVISOR)
BarryG
Addict
Addict
Posts: 4127
Joined: Thu Apr 18, 2019 8:17 am

Re: cpuinfo module

Post by BarryG »

Thanks, tester!
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: cpuinfo module

Post by idle »

updated module and changed IsCpu parameter to a string, so it can work with a map to print the features
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: cpuinfo module

Post by idle »

updated v1.1 added GetCPUSerialNumber - jassing
Post Reply