Author Topic: CPU and instruction detection  (Read 15398 times)

Gunther

  • Member
  • *****
  • Posts: 3698
  • Forgive your enemies, but never forget their names
CPU and instruction detection
« on: January 28, 2013, 10:07:46 PM »
Here's a quote from the Intel® 64 and IA-32 Architectures Optimization Reference Manual, Order Number: 248966-026, p. 4-6:

Quote
Prior to using AVX, the application must identify that the operating system supports the XGETBV instruction, the YMM register state, in addition to processor’s support for YMM state management using XSAVE/XRSTOR and AVX instructions. The following simplified sequence accomplishes both and is strongly recommended.
1) Detect CPUID.1:ECX.OSXSAVE[bit 27] = 1 (XGETBV enabled for application use1)
2) Issue XGETBV and verify that XFEATURE_ENABLED_MASK[2:1] = ‘11b’ (XMM state and YMM state are enabled by OS).
3) detect CPUID.1:ECX.AVX[bit 28] = 1 (AVX instructions supported).
(Step 3 can be done in any order relative to 1 and 2)

Has anybody done these steps for the CPU and instruction set detection? Any source code available?

Gunther
Get your facts first, and then you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: CPU and instruction detection
« Reply #1 on: January 29, 2013, 12:14:50 AM »
the problem is that intel and amd don't write operating systems - lol
come to think of it, it would be nice if they did   :P

steps 1 and 3 are easy to do
i have never tried step 2

http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled
i would read the user comments also

Gunther

  • Member
  • *****
  • Posts: 3698
  • Forgive your enemies, but never forget their names
Re: CPU and instruction detection
« Reply #2 on: January 29, 2013, 12:48:17 AM »
Hi Dave,

http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled
i would read the user comments also

I know that link and it's a slightly modified code variant which Intel provides in the manual.

Gunther
Get your facts first, and then you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: CPU and instruction detection
« Reply #3 on: January 29, 2013, 12:54:29 AM »
it doesn't appear that you have to access the control registers

that is when feature identification becomes a little more painful
i guess you need a kernel mode driver to access those registers
and - on newer OS's, MS has this WHQL thing that falls in the "piss-me-off" catagory - lol
i am an XP fan, forever - even if i can't do 64-bit or AVX

Gunther

  • Member
  • *****
  • Posts: 3698
  • Forgive your enemies, but never forget their names
Re: CPU and instruction detection
« Reply #4 on: January 29, 2013, 03:23:15 AM »
Hi Dave,

i am an XP fan, forever - even if i can't do 64-bit or AVX

there's a 64 bit XP, too.  :lol: But of course, AVX isn't supported by that OS.

Gunther
Get your facts first, and then you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: CPU and instruction detection
« Reply #5 on: January 29, 2013, 04:55:34 AM »
yah - my understanding of xp-64 is that it has a lot of problems
i may have a 64-bit machine some time in the future, but my 32-bit XP's will always be my fave

Gunther

  • Member
  • *****
  • Posts: 3698
  • Forgive your enemies, but never forget their names
Re: CPU and instruction detection
« Reply #6 on: January 29, 2013, 05:39:36 AM »
Hi Dave,

i may have a 64-bit machine some time in the future, but my 32-bit XP's will always be my fave

so far as I know, the oldest Sempron or Celeron can handle 64 bit operating systems. Why not give it a try? You could run both systems in parallel with a good boot manager. But for 64 bit I would recommend Windows 7, not XP.

Gunther
Get your facts first, and then you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: CPU and instruction detection
« Reply #7 on: January 29, 2013, 10:11:16 AM »
i have a prescott that supports "em64"
kind of a lame duck, i think
it would probably run xp64

at some point, i will probably acquire a laptop with windows 7-64
i don't have a laptop, so i can kill 2 birds with one stone

wifee has a laptop that came with vista on it
she cried until i managed to get xp on it for her   :P

Gunther

  • Member
  • *****
  • Posts: 3698
  • Forgive your enemies, but never forget their names
Re: CPU and instruction detection
« Reply #8 on: January 30, 2013, 04:22:19 AM »
Hi Dave,

i have a prescott that supports "em64"
kind of a lame duck, i think
it would probably run xp64

it would run without any doubt a 64 bit Linux.

at some point, i will probably acquire a laptop with windows 7-64
i don't have a laptop, so i can kill 2 birds with one stone

that's a good idea. Go forward.

Gunther
Get your facts first, and then you can distort them.

Magnum

  • Member
  • *****
  • Posts: 2362
Re: CPU and instruction detection
« Reply #9 on: January 30, 2013, 05:33:06 AM »
the problem is that intel and amd don't write operating systems - lol
come to think of it, it would be nice if they did   :P


That would be nice if they did.

I think they could make a killer o.s. and would do it without having a 'tude.

I remember when they sent me some programming and chip manuals for free.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: CPU and instruction detection
« Reply #10 on: January 30, 2013, 05:43:47 AM »
probably something in the monopoly laws prevents them from doing so
otherwise - they certainly have the resources to do it - especially intel
if not by law - maybe by agreement with ms   :P

Magnum

  • Member
  • *****
  • Posts: 2362
Re: CPU and instruction detection
« Reply #11 on: January 30, 2013, 06:14:44 AM »
Do you think Intel would make chips that only ran their o.s. ?

Already some companies strong arm all kinds of sweet heart deals.

Monster O.S.'s need monster hard drives, etc.

You can infer a lot of the "back room activities" it by going deep and reading the specifics on some of the patches and updates.

On another funny side.

In my limited user, I had configured to use the oldest i.e.

Even though I had +R on i.e., it changed mysteriously to sp3 version.

But when I am using my admin account, it uses the sp2 version.  :t

Just for shi*s and grins, I added +S to iexplore.exe.

Laterz.





Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: CPU and instruction detection
« Reply #12 on: January 30, 2013, 06:23:17 AM »
Quote
Do you think Intel would make chips that only ran their o.s. ?

yah - i am pretty sure that would be a violation of laws
microsoft got sued for bundling IE with windows
how do you think the fed would react to an os that only ran on the same companies chips - lol

back in the day, i remember intel's x86 assembler
it was a bit clumsy, really - very basic
but, it was good enough for ibm to use for writing pc/xt bios code
in fact, it handled rom-able code better than masm, in some ways
well - masm is not intended for use, other than code to be run under ms operating systems
i have played some tricks and used it for my own rom-able code, though (personal use)

Magnum

  • Member
  • *****
  • Posts: 2362
Re: CPU and instruction detection
« Reply #13 on: January 30, 2013, 07:53:19 AM »
They got sued but it's still bundled with the o.s. except for Europe.  :icon13:

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: CPU and instruction detection
« Reply #14 on: January 30, 2013, 11:09:43 AM »
yah - i really didn't understand that one   :redface:
if i buy an operating system, i want one that comes with a browser
what do they think ? - i am going to buy one ? - or, maybe they think i can write one - lol