The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: hutch-- on April 23, 2010, 06:27:50 AM

Title: CPUID test piece.
Post by: hutch-- on April 23, 2010, 06:27:50 AM
I have the attached test piece tested on the hardware I have running here but there are old timers and AMD hardware that I don't have access at so if it is not to much innconvenience, I would appreciate people with different hardware to test this app and publish the results for each processor they have available.

These are the results I have on the Intel hardware I have running. 0 means not available, 1 means instruction set IS available.


GenuineIntel
Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz
1 SSE 4.2
1 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Press any key to continue ...

GenuineIntel
Intel(R) Core(TM)2 Quad CPU    Q9650  @ 3.00GHz
0 SSE 4.2
1 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Press any key to continue ...

GenuineIntel
Genuine Intel(R) CPU 3.80GHz
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Press any key to continue ...
Title: Re: CPUID test piece.
Post by: jj2007 on April 23, 2010, 06:36:01 AM
GenuineIntel
Intel(R) Celeron(R) M CPU        420  @ 1.60GHz
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX

:U
Title: Re: CPUID test piece.
Post by: MichaelW on April 23, 2010, 06:53:10 AM
P3:

GenuineIntel
☺☺☻♥
0 SSE 4.2
0 SSE 4.1
0 SSE 3
0 SSE 2
1 SSE
1 MMX
Title: Re: CPUID test piece.
Post by: hutch-- on April 23, 2010, 06:58:27 AM
My young brother can be useful occasionally, tested it on 2 AMD machines.


AuthenticAMD
AMD Athlon(tm) 64 X2 Dual Core Processor 6000+
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX


The next one is unusual, its an AMD Sempron that gave unusual results with the long ID string.
CPUZ says its a AMD Sempron LE-1150 (Sparta) Socket AM2(940)


AuthenticAMD
AMD Processor model unknown
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Title: Re: CPUID test piece.
Post by: Vortex on April 23, 2010, 07:40:20 AM
Intel(R) Pentium(R) 4 CPU 3.20GHz
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Title: Re: CPUID test piece.
Post by: clive on April 23, 2010, 09:56:29 AM
GenuineIntel
Intel(R) Atom(TM) CPU N270   @ 1.60GHz
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Title: Re: CPUID test piece.
Post by: rags on April 23, 2010, 10:34:39 AM

AuthenticAMD
AMD Athlon(tm) II X2 215 Processor
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Title: Re: CPUID test piece.
Post by: dedndave on April 23, 2010, 11:42:28 AM
prescott
GenuineIntel
Intel(R) Pentium(R) 4 CPU 3.00GHz
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Title: Re: CPUID test piece.
Post by: FORTRANS on April 23, 2010, 01:33:45 PM
Hi,


Pentium III Windows 2000

GenuineIntel
☺☺☻♥
0 SSE 4.2
0 SSE 4.1
0 SSE 3
0 SSE 2
1 SSE
1 MMX
Press any key to continue ...

Pentium MMX Windows 98

CPUFIX caused an invalid page fault in
module CPUFIX.EXE at 0167:0040133e.
Registers:
<snip>

Celeron Windows XP

GenuineIntel
Mobile Intel(R) Celeron(R) processor     600MHz
0 SSE 4.2
0 SSE 4.1
0 SSE 3
1 SSE 2
1 SSE
1 MMX
Press any key to continue ...


Steve
Title: Re: CPUID test piece.
Post by: hutch-- on April 23, 2010, 03:08:48 PM
I have done some work on the earlier one, this one calls each routine and returns results that are not printed locally in each proc. I used a suggestion of Dave's to try and pick up the earlier processors from PIIIs back to later 486s. problem is I have no way of testing old timers as I no longer have any that will run.

I get these types of results on the boxes I am using.


Manufacturer = GenuineIntel

Model ID string = Intel(R) Core(TM)2 Quad CPU    Q9650  @ 3.00GHz

Supported Instruction Sets
SSE4.2 NO
SSE4.1 YES
SSE3   YES
SSE2   YES
SSE    YES
MMX    YES
Press any key to continue ...


I don't target anything earlier than Win2000 but I would be interested to see how this version works on PIIIs and earlier. The processor cutoff will probably be something late enough to run Win2000 but I do not expect that it will run correctly on earlier hardware or win9x series OS versions.
Title: Re: CPUID test piece.
Post by: dedndave on April 23, 2010, 03:21:14 PM
the worst OS for this stuff is Windows CE (for embedded systems)
on the plus side, you'd think they already know what CPU they have if they developed an embedded system - lol

the problem is - some versions of CE are "buildable" and the designer has the opportunity
to trim down the OS - i don't know what that entails, nor was i able to find a clear answer for
whether or not CE supports multiple cores
i suspect, in the near future, it will have to

muliple cores means there is a possibility that CPUID will execute on one package one time
and another package the next time - however likely or unlikely
with most motherboards, the packages are the same device, so it makes no real difference unless you are reading cache parms
there are a few instances where the packages may be different, however
that makes it a good idea to affinitize to a single core, i think

if a programmer is to use this routine in an app that is distributed, he may want it to work on all systems
Title: Re: CPUID test piece.
Post by: hutch-- on April 23, 2010, 04:01:40 PM
Dave,

The only part of the example that I see as important is the available instruction sets and its primarily so a program can choose whether it uses SSE2 or SSE4.1 rather than and real interest in the old stuff, most of which cannot run Win2000 or later. Microsoft will shortly pension off XP SP3 so I don't see the point of wasting the effort on very early AMD or Cyrix hardware.

The ID strings are OK as headings on sysinfo dialogs but they are not much real use in determining if you can use an SSE instruction or not.
Title: Re: CPUID test piece.
Post by: dioxin on April 23, 2010, 04:09:03 PM
Hutch,
your tests aren't exhaustive. The Phenom has SSE4a (not SSE4.1 or SSE4.2)
The K6-III has 3DNow!
Neither of these is detected in your tests but maybe you aren't interested in looking for them.

Paul.

Phenom X4 945
AuthenticAMD

AMD Phenom(tm) II X4 945 Processor

0             SSE 4.2
0             SSE 4.1
1             SSE 3
1             SSE 2
1             SSE
1             MMX



Intel Atom N270
GenuineIntel

         Intel(R) Atom(TM) CPU N270   @ 1.60GHz

0             SSE 4.2
0             SSE 4.1
1             SSE 3
1             SSE 2
1             SSE
1             MMX




Intel Celeron
GenuineIntel

Intel(R) Celeron(R) M processor          900MHz

0             SSE 4.2
0             SSE 4.1
0             SSE 3
1             SSE 2
1             SSE
1             MMX




AMD Athlon XP (Barton)
AuthenticAMD

AMD Athlon(tm) XP 2600+

0             SSE 4.2
0             SSE 4.1
0             SSE 3
0             SSE 2
1             SSE
1             MMX




AMD k6-III
AuthenticAMD

AMD-K6(tm) 3D+ Processor

0             SSE 4.2
0             SSE 4.1
0             SSE 3
0             SSE 2
0             SSE
1             MMX
Title: Re: CPUID test piece.
Post by: clive on April 23, 2010, 05:28:45 PM
Some of the older chips (pre CPUID) could be identified by looking at things like the barrel shift, flag bits, prefetch queue size (self modifying code). For instance the the 386DX and 386SX could be identified by different prefetch queue sizes. I need to dig up the DOS code I had that would identifiy 8080/86,V20/30 thru Pentium III Coppermine.
Title: Re: CPUID test piece.
Post by: FORTRANS on April 23, 2010, 05:37:08 PM
Hi,


Pentium III Windows 2000

Model ID string = Pentium Pro, II or Celeron Processor

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   NO
SSE    YES
MMX    YES
Press any key to continue ...
Manufacturer = GenuineIntel

Pentium MMX  Windows 98

Model ID string = i486 or early Pentium Processor

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   NO
SSE    NO
MMX    YES
Press any key to continue ...


Cheers,

Steve N.
Title: Re: CPUID test piece.
Post by: Greenhorn__ on April 23, 2010, 05:38:40 PM
Hi Hutch,

here's my result ...
AuthenticAMD
AMD Phenom(tm) II X4 955 Processor
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
Press any key to continue ...

:wink

Regards
Greenhorn
Title: Re: CPUID test piece.
Post by: dedndave on April 23, 2010, 05:38:55 PM
Clive - those methods are discouraged by intel and amd

but....
1) ALL pentium class CPU's support CPUID, although it may be disabled on some Cyrix devices
2) you may easily distinquish a 386-class CPU from a 486-class CPU by toggling bit 18 of the EFLAGS register
3) the 386 may not be used for anything after windows 95

the documentation states that a 486 is required for windows 95, but i seem to remember installing it on a 386
my memory is not what it used to be, so the documentation could be right

there may be some 386 class devices in embedded systems running windows CE - not sure about that one   :P
Title: Re: CPUID test piece.
Post by: clive on April 23, 2010, 05:59:10 PM
Quote from: dedndave on April 23, 2010, 05:38:55 PM
Clive - those methods are discouraged by intel and amd

Absent other "approved" methods from the offending parties there aren't many other options. Anyhow the code mainly found it's way into diagnostic applications rather than DOS or Windows drivers, because end users were particularly hopeless identifying what hardware they had to my tech support group. If self modifying code is scary, the code to probe and identify North bridge, South bridge (motherboard chipsets), and Multi-IO chips gets to be very dicey. Typically you'd look at the CPU, and things like the number of address bits decoded, stuck at bits, etc before using magic sequences to unlock the hardware. The PCI configuration is now quite stable/defined, but the initial chipsets and first couple of years saw a number of rather unstable implementations.

Most of this stuff is so old as to be mostly irrelevant.
Title: Re: CPUID test piece.
Post by: dedndave on April 23, 2010, 06:32:23 PM
QuoteMost of this stuff is so old as to be mostly irrelevant

that's the thing - we are writing a 32-bit routine - no use in worrying about 16-bit CPU's - lol
for this kind of routine, however, it is nice to support back to windows 3.1 and 386's
that way, the programmer that is incorporating the routine into an app is not limited by the support of one routine
there are still quite a few windows 98 users out there
we have a few guys in here that have windows 3.1 systems to test on, too   :P
discerning 386's and 486's is very simple
the real problem areas are Pentium 2/3 class CPUs
some of the later Pentium 3's support brand strings, too
the ones that don't are a mess - lol
Title: Re: CPUID test piece.
Post by: frktons on April 23, 2010, 10:16:30 PM
GenuineIntel
Intel(R) Core(TM)2 CPU          6600  @ 2.40GHz
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX
----------------------------------------------------------------------------------------------------
Manufacturer = GenuineIntel

Model ID string = Intel(R) Core(TM)2 CPU          6600  @ 2.40GHz

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   YES
SSE2   YES
SSE    YES
MMX    YES
------------------------------------------------------------------------------------------------------

Cheers
Title: Re: CPUID test piece.
Post by: hutch-- on April 24, 2010, 12:00:19 AM
Thanks guys, I picked this stuff out of the current Intel instruction manual and so far the Intel specific functions seem to work on most hardware. I used a suggestion of Dave's to put some form of ID string for hardware earlier than PIVs which appears to be working but I know the variation in pre-PIV hardware made reliable identification difficult. I need to get access at AMD specific data to pick up the 3DNOW even though its ancient but the late Phenom II series will need to be handled as well as they are a popular processor. (Was tempted to buy one for the newest box Phenom II X4 965 BE but settled on an i7 860 because of its advantage with hyperthreading.)

The drift of this type of function is so you can reliably determine if you can use SSE instruction sets, the ID strings are only of limited use in things like Sysinfo apps.
Title: Re: CPUID test piece.
Post by: dedndave on April 24, 2010, 12:41:53 AM
it would greatly simplify the routine for older CPUs if you could just do:

1) 80386 Class CPU
2) 80486 Class CPU
3) Pentium Class CPU
4) Pentium II Class CPU
5) Pentium III Class CPU

except for Pentium III's, within any one family, the differences are small
later Pentium III's support brand string - no problem there
the real problem is earier Pentium III's - there are a lot of different ones - many were called Celeron's or Xeon's
just call them Pentium III Class and be done with it   :P

EDIT
Intel
if extended model is not 0, brand string is supported
if family is greater than 6, brand string is supported
for family 6, model 0Bh and up support brand string (i am pretty sure this is correct - i will verify)

AMD
all AMD chips support brand string, which makes it easy   :P

3DNow!...
CPUID, eax=80000001, edx bit 31     3DNow!  (AMD only)
CPUID, eax=80000001, edx bit 30     3DNow!+ (AMD only)

these bits should be masked off for non-AMD parts
AMD acquired one or two of the little CPU companies (transmeta maybe ?) - so, a few of their chips support 3DNow also

let me see if i can find specific details......
here we go
for these devices, EDX bits 30 and 31 are valid

All AMD processors after K6-2 (inclusive)
National Semiconductor Geode, later AMD Geode
VIA C3 (also known as Cyrix III) "Samuel", "Ezra", and "Eden" cores
IDT Winchip 2

what i was doing was creating FeatureBitMask's according to the different vendor strings
Title: Re: CPUID test piece.
Post by: dedndave on April 24, 2010, 12:48:59 AM
here is a table i was making that combines Intel and AMD signatures
it isn't quite complete, but many of the Intel documentation errors have been corrected

http://www.4shared.com/file/WHXNrzwq/Signature.html
Title: Re: CPUID test piece.
Post by: clive on April 24, 2010, 02:34:19 AM
I put this list together from my old DOS notes, last updated 1999. Based on personal observation, or customer logs

; Generic ID, probably match DX at reset, hard to say

; 0010 8088/8086
; 0020 V20/V30
; 0110 80188/80186
; 0200 80286
; 0300 80386 Generic
; 0310 80386DX (14 byte prefetch)
; 0320 80386SX (12 byte prefetch)
; 0330 80376
; 0340 80386SL (ID via SL chipset register)

; GenuineIntel

; Mask CPUID w/0xFFF

; 0400 80486 Generic
; 041x 80486DX  (Stepping  )
; 042x 80486SX  (Stepping 3+) 042A 80486DX SL
; 043x 80486DX2 (Stepping 5+) 0435 80486DX2 SL (Possibly 80487)
; 044x 80486SL  (ID via SL chipset register)
; 045x 80486SX2
; 046x ?
; 047x 80486DX2WB
; 048x 80486DX4
; 049x 80486DX4WB

; 05xx Pentium
; 0510 Pentium 5v 60/66 MHz (Stepping 7+ Fixes FDIV)
; 0520 Pentium 3.3v 75/90/100/120 Mhz (Stepping 4+ Fixes FDIV)
; 0530 Pentium P24T
; 0540 Overdrive for Pentium 3.3v
; 0550 Overdrive for 80486DX4
; 0560 Overdrive for Penitum 5v
; 0580 Pentium MMX (Tillamook)

; 06xx 80686 Generic
; 061x Pentium Pro
; 063x Pentium II (Klamath)
; 065x Pentium II (Deschutes)
; 066x Pentium II (Mendocino)
; 0660            Slot1
; 0665            PPGA
; 066A Pentium II (Dixon) 128/256K L2
; 067x Pentium III (Katmai)
; 068x Pentium III (Coppermine)

; AuthenticAMD

; 043x AMD80486DX2
; 047x AMD80486DX2WB
; 048x AMD80486DX4
; 049x AMD80486DX4WB
; 04Ex AMD80486Plus   AMD5x86
; 04Fx AMD80486PlusWB AMD5x86WB
; 050x AMD5k86 (SSA5)
; 051x AMD5k86
; 056x AMD6k86

; My ID# (Not AMD or Intel by signature)
; 04Ex IBM486 (10 byte prefetch)
; 04Fx Cyrix486 (14 byte prefetch)
Title: Re: CPUID test piece.
Post by: clive on April 24, 2010, 02:42:09 AM
This looks quite good also
http://www.rom.by/comment/39298

http://www.ukcpu.net/Programming/OS/cpuid.txt

Christian's site would also be highly credible, he's probably had all these on the bench.
http://www.sandpile.org/ia32/cpuid.htm

ECX Bit 29 AVX (Advanced Vectorization)
ECX Bit 25 AES (Encryption)
ECX Bit 23 POPCNT (Population Count)

ECX Bit 5 VMX (Vanderpool) Virtualization

ECX Bit 0 SSE3
ECX Bit 9 SSE3E (Core Duo 2 New Instructions)
ECX Bit 19 SSE4.1
ECX Bit 20 SSE4.2 (SSE4E)

EDX Bit 23 MMX
EDX Bit 25 SSE
EDX Bit 26 SSE2
EDX Bit 28 HTT (Jackson) Hyperthreading
Title: Re: CPUID test piece.
Post by: hutch-- on April 24, 2010, 03:37:36 AM
The list on Christian's site is close enough to comprehensive but its pointed at a different target, if you were doing legacy processor identification it would be a goldmine but what I am chasing apart from the two easy to get processor strings is the instruction set capability and the Intel data on Intel hardware here seems to be OK. Intel seem to be reasonably stable at the moment with their top line of i3 i5 and i7 processors but AMD are changing their lines very fast at the moment, 4 core Phenom II and recently the 6 core versions and i have not yet decyphered the AMD manual on CPUID that I downloaded this morning.

The end result would be to know what instruction set you can use and the actual core count not including hyperthreading. The ID strings don't in themselves do anything that is particularly useful. I also need to do a check for support of the CPUID opcode to see if its available but for anything that will run Win2000 or later I think from memory that they all support it.
Title: Re: CPUID test piece.
Post by: clive on April 25, 2010, 07:43:11 PM
P4 Willamette
GenuineIntel
Intel(R) Celeron(R) CPU 1.80GHz
0 SSE 4.2
0 SSE 4.1
0 SSE 3
1 SSE 2
1 SSE
1 MMX


Manufacturer = GenuineIntel

Model ID string = Intel(R) Celeron(R) CPU 1.80GHz

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   YES
SSE    YES
MMX    YES
Title: Re: CPUID test piece.
Post by: hutch-- on April 25, 2010, 11:50:30 PM
Clive,

A quick question, the Willamette series PIVs from memory went from 1.5 to about 2.0 gig versions before the Northwood core took over, vaguely I remember the main differences from the Celeron to the PIV of that era was cache size and not much else ?
Title: Re: CPUID test piece.
Post by: clive on April 26, 2010, 12:33:43 AM
Yes, the Willamette was the 180 nm part (1.3 to 2.0 GHz), and the Northwood the 130 nm, with some fixes, tweaked the pipelines and added Hyper Threading (or at least exposed it). I had a conversation with Christian years ago about "Jackson Technology" which was the code name for HT.

As I recall the Celeron part had the smaller cache and restricted FSB.

This bad boy is in a system with an 845GL chipset (400 MHz FSB), and is a total dog even with 1GB of DDR at (133/266). I was shopping around on eBay for a Northwood that might run in it.

-Clive
Title: Re: CPUID test piece.
Post by: hutch-- on April 26, 2010, 01:57:47 AM
I remember the main advantage of the 1.5 gig PIV I had was you could thrash it for hours and it never went over about 25c. I had to install a copper cooler on the 2.8 gig Northwood to keep it under 35c with long loads.

I used it for years as it was still faster than the later Prescotts on most code but the board was taken out by a power supply that went bang. Put a new one in but the old power supply took out the northbridge chip when it went bang.
Title: Re: CPUID test piece.
Post by: Magnum on April 26, 2010, 02:17:53 AM
I get this on a P-3 Coppermine.

Model ID string = Pentium Pro, II or Celeron Processor

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   NO
SSE    YES
MMX    YES
Title: Re: CPUID test piece.
Post by: MichaelW on April 26, 2010, 02:57:17 AM
Now on my Slot-1 P3 I get:

Manufacturer = GenuineIntel

Model ID string = Pentium Pro, II or Celeron Processor

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   NO
SSE    YES
MMX    YES
Title: Re: CPUID test piece.
Post by: hutch-- on April 26, 2010, 05:31:05 AM
It looks like with the PIII results that 80000000 return function with the value 00000002h is wrong. It is suposed to return 00000003h for a PIII.
Title: Re: CPUID test piece.
Post by: sinsi on April 26, 2010, 05:58:30 AM
The processor serial number can be switched off in the BIOS, but I don't know whether the PSN bit is still cleared.
(If this is what you mean by a value of 00000003).
Title: Re: CPUID test piece.
Post by: MichaelW on April 26, 2010, 08:33:42 AM
I think after all the bad press the processor serial number is switched off by default for most BIOSes.

Back when I did this, for the Intel processors I identified the specific processor by using the "brand index" returned in EBX bits 7-0 by CPUID function 1 to index a table of strings extracted from the Intel manual, specifically 25366615.pdf, "Mapping of Brand Indices and IA-32 Processor Brand Strings". It worked for the Intel processors that I had access to at the time. It did not work for some of the later processors, and I recall the conclusion that I came to was that Intel had switched directions somewhere after the Pentium 4 was introduced and adopted the AMD method (possibly hanging it off of a different set of extended functions, I never took the time to check this out). For the AMD method the processor brand string returned by extended functions 80000002-80000004 specified the processor name, and it worked correctly at least back to the K5.
Title: Re: CPUID test piece.
Post by: Magnum on April 26, 2010, 11:41:20 AM
Quote from: hutch-- on April 26, 2010, 05:31:05 AM
It looks like with the PIII results that 80000000 return function with the value 00000002h is wrong. It is suposed to return 00000003h for a PIII.

I had my serial number disabled. When I enabled it I got this.

When I ran cpufix.exe, the debugger came up and stopped at mov edi, dword ptr ds:[eax]. ??

Manufacturer = GenuineIntel

Model ID string = Pentium III Processor

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   NO
SSE    YES
MMX    YES
Press any key to continue ...

Title: Re: CPUID test piece.
Post by: dedndave on April 26, 2010, 12:17:47 PM
CPUID leaf 80000000h returns the largest supported extended leaf
to ID the Pentium 1/Pro/2/3's, use the Processor Signature from leaf 00000001h EAX register
the Intel document 241618.pdf has quite a few errors in the Signature table
i have corrected most, if not all, of these errors in the Signature table pic...

http://www.4shared.com/file/WHXNrzwq/Signature.html

the Signature table in the pdf mentioned above has a number of small mistakes
if you read the footnotes, it points you to the individual update pdf's for the Pentium 1/Pro/2/3 Family/Models
this is primarily where i got the correct info, along with sites like cpuworld, etc, that have partial CPUID dumps

you may also want the Brand Index and L2 Cache type to identify specific chips
i think, for your level of identification, the Processor Signature Family and Model values should be enough
the Family and Model values are combined in the low-order byte of the 00000001h leaf EAX Signature (AL)
for later 486's that support CPUID, the Family bits are 0100
for the Pentium I's, the Family bits are 0101
all the Pentium Pro/2/3's are in Family 0110 - use the low 4 bits (Model) to sort them out
Title: Re: CPUID test piece.
Post by: Igor on November 13, 2010, 08:56:12 AM
@hutch--
Intel docs "Intel Processor Identification and the CPUID Instruction (AP-485) (http://www.intel.com/Assets/PDF/appnote/241618.pdf)" say that you first need to check for presence of cpuid instruction by checking ability to set bit 21 in EFLAGS, my understanding is that 386 or earlier don't have cpuid and only some 486 have cpuid instruction. I guess it's not needed if you are sure that your code won't be run on 386 and 486, which possibly includes users with Win95 (minimum 386 cpu), Win98 (minimum 486) and WinNT (minimum 486).

Quote from: dedndave on April 23, 2010, 05:38:55 PM
the documentation states that a 486 is required for windows 95, but i seem to remember installing it on a 386
my memory is not what it used to be, so the documentation could be right
System requirements for installing Windows 95: Personal computer with a 386DX or higher processor (486 recommended)
http://support.microsoft.com/kb/138349
Title: Re: CPUID test piece.
Post by: hutch-- on November 13, 2010, 09:28:34 AM
Igor,

This is the version I use to test for CPUID.

The structure used.


    X86ST STRUCT
      sse4a dd ?
      sse42 dd ?
      sse41 dd ?
      ssse3 dd ?
      sse3  dd ?
      sse2  dd ?
      sse   dd ?
      mmx   dd ?
      mmxx  dd ?
      amd3D dd ?
      amd3x dd ?
    X86ST ENDS


The procedure.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

; "mmi" Multi media Instructions

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

mmi proc pStruct:DWORD

  ; returns 0 if no CPUID, 1 if it is supported.
  ; if supported tests from MMX to SSE4.2 and
  ; writes results to structure

  ; -------------------------------------------------
  ; test for CPUID so it does not crash on old timers
  ; -------------------------------------------------
    pushfd
    pop eax

    mov ecx, eax
    xor eax, 00000000001000000000000000000000b          ; set bit 21 of eflags
    push eax
    popfd
    pushfd
    pop eax

    xor eax, ecx            ; test if its changed
    jnz exists              ; if changed then CPUID
    xor eax, eax            ; returns 0 if no CPUID
    ret 4
  ; -------------------------------------------------

  exists:
  ; -------------------
  ; zero fill structure
  ; -------------------
    mov ecx, SIZEOF X86ST / 4

    mov eax, [esp+4]        ; pStruct
  @@:
    mov DWORD PTR [eax], 0
    add eax, 4
    sub ecx, 1
    jnz @B

  ; INTEL

    mov eax, 1
    cpuid

    mov eax, [esp+4]                                ; pStruct

    bt ecx, 20                                      ; sse4.2
    setc BYTE PTR (X86ST PTR [eax]).sse42

    bt ecx, 19                                      ; sse4.1
    setc BYTE PTR (X86ST PTR [eax]).sse41

    bt ecx, 9                                       ; ssse3
    setc BYTE PTR (X86ST PTR [eax]).ssse3

    bt ecx, 0                                       ; sse3
    setc BYTE PTR (X86ST PTR [eax]).sse3

    bt edx, 26                                      ; sse2
    setc BYTE PTR (X86ST PTR [eax]).sse2

    bt edx, 25                                      ; sse
    setc BYTE PTR (X86ST PTR [eax]).sse

    bt edx, 23                                      ; mmx
    setc BYTE PTR (X86ST PTR [eax]).mmx

  ; AMD

    mov eax, 80000001h
    cpuid

    mov eax, [esp+4]                                ; pStruct

    bt edx, 22                                      ; AMD mmx extended
    setc BYTE PTR (X86ST PTR [eax]).mmxx

    bt ecx, 6                                       ; AMD sse4a
    setc BYTE PTR (X86ST PTR [eax]).sse4a

    bt edx, 31                                      ; AMD 3DNow
    setc BYTE PTR (X86ST PTR [eax]).amd3D

    bt edx, 30                                      ; AMD 3DNowExt
    setc BYTE PTR (X86ST PTR [eax]).amd3x

    mov eax, 1
    ret 4

mmi endp

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Title: Re: CPUID test piece.
Post by: Igor on November 13, 2010, 09:48:25 AM
OK then, I didn't see it in the code that you uploaded so I thought I should mention it.

Title: Re: CPUID test piece.
Post by: frktons on November 13, 2010, 01:15:43 PM
Hi Hutch. I have a question about your CPU identification code.
Do you consider the SSSE3 just a subset of SSE3 and for this reason
you don't display it?


Manufacturer = GenuineIntel

Model ID string = Intel(R) Core(TM)2 CPU          6600  @ 2.40GHz

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   YES
SSE2   YES
SSE    YES
MMX    YES



Frank
Title: Re: CPUID test piece.
Post by: dedndave on November 13, 2010, 01:42:05 PM
hiyas Frank

the percentage of computers in use that support SSSE3 is not that high (i think Core2's and i7's at this time)
therefore, it isn't used that often in software
SSE4, of some flavour, is probably more common
that's probably why Hutch left it out   :P

not too many instructions in SSSE3:
http://softpixel.com/~cwright/programming/simd/ssse3.php

i think if you want to use SSE3 or above, you should probably provide some fall-back option for older CPU's
that means writing seperate routines to support different processors
Title: Re: CPUID test piece.
Post by: frktons on November 13, 2010, 02:05:50 PM
Quote from: dedndave on November 13, 2010, 01:42:05 PM
hiyas Frank

the percentage of computers in use that support SSSE3 is not that high (i think Core2's and i7's at this time)
therefore, it isn't used that often in software
SSE4, of some flavour, is probably more common
that's probably why Hutch left it out   :P

not too many instructions in SSSE3:
http://softpixel.com/~cwright/programming/simd/ssse3.php

i think if you want to use SSE3 or above, you should probably provide some fall-back option for older CPU's
that means writing seperate routines to support different processors

Thanks for the insight Dave  :U

Frank
Title: Re: CPUID test piece.
Post by: hutch-- on November 13, 2010, 03:28:35 PM
The original topis was a test piece, check the last algo I posted that handles all up to sse4.2.
Title: Re: CPUID test piece.
Post by: clive on November 20, 2010, 05:22:04 AM
AMD with SSE4A
AuthenticAMD
AMD Athlon(tm) II X2 215 Processor
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX


Processor 1 ID = 0
Number of cores 2 (max 2)
Number of threads 2 (max 2)
Name AMD Athlon II X2 215
Codename Regor
Specification AMD Athlon(tm) II X2 215 Processor
Package Socket AM3 (938)
CPUID F.6.2
Extended CPUID 10.6
Brand ID 12
Core Stepping DA-C2
Technology 45 nm
Core Speed 803.6 MHz
Multiplier x FSB 4.0 x 200.9 MHz
HT Link speed 803.6 MHz
Stock frequency 2700 MHz
Instructions sets MMX (+), 3DNow! (+), SSE, SSE2, SSE3, SSE4A, x86-64, AMD-V
L1 Data cache 2 x 64 KBytes, 2-way set associative, 64-byte line size
L1 Instruction cache 2 x 64 KBytes, 2-way set associative, 64-byte line size
L2 cache 2 x 512 KBytes, 16-way set associative, 64-byte line size
FID/VID Control yes
FID range 4.0x - 13.5x
Max VID 1.350 V
P-State FID 0xB - VID 0x10 - IDD 23 (13.5x - 1.350 V)
P-State FID 0x5 - VID 0x18 - IDD 17 (10.5x - 1.250 V)
P-State FID 0x10E - VID 0x20 - IDD 15 (7.5x - 1.150 V)
P-State FID 0x100 - VID 0x2C - IDD 8 (4.0x - 1.000 V)

Package Type 0x1
Model 15
String 1 0x3
String 2 0x6
Page 0x0
CmpCap 2
TDP Limit 62 Watts
TDC Limit 46 Amps
Attached device PCI device at bus 0, device 24, function 0
Attached device PCI device at bus 0, device 24, function 1
Attached device PCI device at bus 0, device 24, function 2
Attached device PCI device at bus 0, device 24, function 3
Attached device PCI device at bus 0, device 24, function 4


Thread dumps
-------------------------------------------------------------------------

CPU Thread 0
APIC ID 0
Topology Processor ID 0, Core ID 0, Thread ID 0
Type 0200400Bh
Max CPUID level 00000005h
Max CPUID ext. level 8000001Bh
Cache descriptor Level 1, I, 64 KB, 1 thread(s)
Cache descriptor Level 1, D, 64 KB, 1 thread(s)
Cache descriptor Level 2, U, 512 KB, 1 thread(s)

CPUID
0x00000000 0x00000005 0x68747541 0x444D4163 0x69746E65
0x00000001 0x00100F62 0x00020800 0x00802009 0x178BFBFF
0x00000002 0x00000000 0x00000000 0x00000000 0x00000000
0x00000003 0x00000000 0x00000000 0x00000000 0x00000000
0x00000004 0x00000000 0x00000000 0x00000000 0x00000000
0x00000005 0x00000040 0x00000040 0x00000003 0x00000000
0x80000000 0x8000001B 0x68747541 0x444D4163 0x69746E65
0x80000001 0x00100F62 0x100018F6 0x000037FF 0xEFD3FBFF
0x80000002 0x20444D41 0x6C687441 0x74286E6F 0x4920296D
0x80000003 0x32582049 0x35313220 0x6F725020 0x73736563
0x80000004 0x0000726F 0x00000000 0x00000000 0x00000000
0x80000005 0xFF30FF10 0xFF30FF20 0x40020140 0x40020140
0x80000006 0x20800000 0x42004200 0x02008140 0x00000000
0x80000007 0x00000000 0x00000000 0x00000000 0x000001F9
0x80000008 0x00003030 0x00000000 0x00002001 0x00000000
0x80000009 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000A 0x00000001 0x00000040 0x00000000 0x0000000F
0x8000000B 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000C 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000D 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000E 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000F 0x00000000 0x00000000 0x00000000 0x00000000
0x80000010 0x00000000 0x00000000 0x00000000 0x00000000
0x80000011 0x00000000 0x00000000 0x00000000 0x00000000
0x80000012 0x00000000 0x00000000 0x00000000 0x00000000
0x80000013 0x00000000 0x00000000 0x00000000 0x00000000
0x80000014 0x00000000 0x00000000 0x00000000 0x00000000
0x80000015 0x00000000 0x00000000 0x00000000 0x00000000
0x80000016 0x00000000 0x00000000 0x00000000 0x00000000
0x80000017 0x00000000 0x00000000 0x00000000 0x00000000
0x80000018 0x00000000 0x00000000 0x00000000 0x00000000
0x80000019 0xF0300000 0x60100000 0x00000000 0x00000000
0x8000001A 0x00000003 0x00000000 0x00000000 0x00000000
0x8000001B 0x0000001F 0x00000000 0x00000000 0x00000000

MSR 0x0000001B 0x00000000 0xFEE00900
MSR 0xC0010114 0x00000000 0x00000008
MSR 0xC0010061 0x00000000 0x00000030
MSR 0xC0010062 0x00000000 0x00000003
MSR 0xC0010063 0x00000000 0x00000003
MSR 0xC0010064 0x800001E1 0x3C00200B
MSR 0xC0010065 0x800001AB 0x3C003005
MSR 0xC0010066 0x8000019A 0x3C00404E
MSR 0xC0010067 0x8000014B 0x3C005840
MSR 0xC0010068 0x0000014B 0x3C005840
MSR 0xC0010071 0x30B60083 0x3C035840
MSR 0xC0010015 0x00000000 0x01000010
MSR 0xC001001F 0x42584000 0x00000008
MSR 0xC0010058 0x00000000 0xFC000015
MSR 0xC0010004 0x00006AD0 0x738643CB
MSR 0xC0010071 0x30B60083 0x3C00200B
MSR 0xC0010070 0x00000000 0x3C00200B
Title: Re: CPUID test piece.
Post by: joxley on June 29, 2011, 01:13:47 PM
GenuineIntel
Intel(R) Core(TM)2 Duo CPU      E6550   @ 2.33Ghz
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 MMX
Press any key to continue ...