Author Topic: Instruction Set detection for 64 bit Operating Systems  (Read 12331 times)

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Instruction Set detection for 64 bit Operating Systems
« on: February 01, 2013, 05:50:10 AM »
The archive iset.zip contains an assembly language procedure for detecting the available instruction sets. There are 2 sub-folders - one for Windows the other for Linux. An appropriate test program is included, too. The procedure detrects the instruction sets up to AVX2 properly.

The source is included and well commented. Comments and proposal for improvements are welcome.

Gunther
« Last Edit: December 20, 2017, 05:32:16 AM by Gunther »
Get your facts first, and then you can distort them.

frktons

  • Member
  • ***
  • Posts: 491
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #1 on: February 01, 2013, 06:11:11 AM »
Waiting for 32 bit version.  :t

mineiro

  • Guest
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #2 on: February 01, 2013, 12:18:02 PM »
Hello Gunther;
Good work Sir, worked fine.

A minor suggestion on linux side is; I noticed that build_features.sh have crlf, I changed it to lf and was able to compile.
To compile it using g++, I changed the line in features.c:
extern long long int Iset(void);
to
extern "C" long long int Iset(void);
and changed all gcc to g++ inside build_features.sh

Again, good work, long life and prosper, congrats.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #3 on: February 01, 2013, 05:52:36 PM »
Hi mineiro and Frank,

thank you for the flowers. The 32 bit version is coming soon.

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

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #4 on: September 29, 2013, 05:54:18 AM »
Under the first post of this thread is now the new instruction set detection procedure. The archive is ISET1.ZIP. It checks now for RDRAND support, too and indicates it if the check had success.

RDRAND generates random numbers with hardware support. It was introduced by Intel in 2012 with the Ivy Bridge architecture; older processors won't support this instruction.

Here's the output of the test program on my Windows 7 machine:
Code: [Select]
Supported by Processor and installed Operating System:
------------------------------------------------------

     MMX, CMOV and FCOMI, SSE, SSE2, SSE3, SSSE3, SSE4.1,
     POPCNT, SSE4.2, AVX, RDRAND, PCLMUL and AES

     featurenumber = 16
The archive contains the sources for Windows, Linux, BSD and MacOS.

There's nothing wrong by using RDRAND for Monte Carlo Simulations and the like. But if one has plans to use it for enryption purposes, that needs increased caution. You should check this and this post before.

Comments and proposal for improvements are welcome. Good luck.

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

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #5 on: April 25, 2014, 09:18:21 AM »
Under the first post of this thread is now the archive IsetU1.zip. It's a major update of the instruction detection procedure. I've changed a bit the logic of the application. It uses now several routines for detecting basic instruction sets and special instructions. As a major result, this archive contains only the 64-bit source for Windows; the Linux program needs another thread. That has to do with the very different application binary interfaces for both operating systems.

I've used gcc for the C source. Since it has not much special, it should also compile with VS, but that's not tested. The assembly language source is written for jWasm, but ml should also do the job. For a more detailed description of the source files, please have a look into the readme.txt file.

Here is the output from my desktop PC, running Windows 7:
Code: [Select]
        Supported Features by Processor and Operating System
        ====================================================

Vendor String: GenuineIntel
Brand  String: Intel(R)Core(TM)i7-3770CPU@3.40GHz

        Instruction Sets
        ----------------

MMX  SSE  SSE2  SSE3  SSSE3  SSE4.1  SSE4.2  AVX

        Supported Special Instructions
        ------------------------------

Conditional Moves
FXSAVE and FXSTOR
XSAVE and XSTOR for processor extended state management.
POPCNT
RDRAND
AES (Advanced Encryption Standard) Instruction Set
16-bit floating-point Conversion Instructions

Please, press enter to end the application ...

That's the output from the small laptop, running Windows 8:
Code: [Select]
        Supported Features by Processor and Operating System
        ====================================================

Vendor String: GenuineIntel
Brand  String: Intel(R)Core(TM)i5-3210MCPU@2.50GHz

        Instruction Sets
        ----------------

MMX  SSE  SSE2  SSE3  SSSE3  SSE4.1  SSE4.2  AVX

        Supported Special Instructions
        ------------------------------

Conditional Moves
FXSAVE and FXSTOR
XSAVE and XSTOR for processor extended state management.
POPCNT
RDRAND
AES (Advanced Encryption Standard) Instruction Set
16-bit floating-point Conversion Instructions

Please, press enter to end the application ...

I haven't an AMD box running 64-bit Windows, but I hope it won't only run on newer Intel processors. But that all must be tested with different processors and other configurations. Your help and test results are very welcome.

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

sinsi

  • Member
  • *****
  • Posts: 1035
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #6 on: April 25, 2014, 01:23:49 PM »
My test box - Windows 7 Ultimate x64
Code: [Select]
        Supported Features by Processor and Operating System
        ====================================================

Vendor String: AuthenticAMD
Brand  String: AMDA10-7850KAPUwithRadeon(TM)R7Graphics

        Instruction Sets
        ----------------

MMX  SSE  SSE2  SSE3  SSSE3  SSE4.1  SSE4.2  AVX

        Supported Special Instructions
        ------------------------------

Conditional Moves
FXSAVE and FXSTOR
XSAVE and XSTOR for processor extended state management.
POPCNT
AES (Advanced Encryption Standard) Instruction Set
FMA (Fused Multiply Add) extensions using YMM state.
16-bit floating-point Conversion Instructions
I can walk on water but stagger on beer.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #7 on: April 25, 2014, 10:24:20 PM »
Hi sinsi,

thank you for testing the software. Seems that your CPU is a Bulldozer follower. It comes with FMA.

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

sinsi

  • Member
  • *****
  • Posts: 1035
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #8 on: April 27, 2014, 08:04:42 PM »
Kaveri, based on the Steamroller microarchitecture.
I can walk on water but stagger on beer.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #9 on: April 27, 2014, 08:10:38 PM »
Hi Sinsi,

Kaveri, based on the Steamroller microarchitecture.

thank you for the information. Interesting product line by AMD.

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

dedndave

  • Member
  • *****
  • Posts: 8779
  • Still using Abacus 2.0
    • DednDave
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #10 on: June 24, 2014, 10:33:51 PM »
so, Gunther,

did you figure out whether or not a 64-bit OS is required to use AVX instruction sets ?

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #11 on: June 24, 2014, 11:11:31 PM »
Dave,

so, Gunther,

did you figure out whether or not a 64-bit OS is required to use AVX instruction sets ?

To use AVX instructions properly you'll need a 64-bit OS. So, AVX, AVX2, AVX512 etc. are not available for 32-bit operating systems. Therefore that thread. But I had no answers.

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

dedndave

  • Member
  • *****
  • Posts: 8779
  • Still using Abacus 2.0
    • DednDave
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #12 on: June 25, 2014, 01:36:08 AM »
thanks   :t
one more question.....

what about a 32-bit program under 64-bit OS - can you use AVX then ?

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #13 on: June 25, 2014, 02:49:18 AM »
Dave,

what about a 32-bit program under 64-bit OS - can you use AVX then ?

Yes, a 32-bit client can use at least AVX under a 64-bit environment without re-compilng. That's tested.

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

dedndave

  • Member
  • *****
  • Posts: 8779
  • Still using Abacus 2.0
    • DednDave
Re: Instruction Set detection for 64 bit Operating Systems
« Reply #14 on: June 25, 2014, 02:56:58 AM »
thanks again, Gunther   :t

working on a 32-bit hardware ID routine and wanted to know if AVX was pertinent