News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Instruction Set detection for 64 bit Operating Systems

Started by Gunther, February 01, 2013, 05:50:10 AM

Previous topic - Next topic

Gunther

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
You have to know the facts before you can distort them.

frktons

There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

mineiro

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

Hi mineiro and Frank,

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

Gunther
You have to know the facts before you can distort them.

Gunther

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:

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
You have to know the facts before you can distort them.

Gunther

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:

        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:

        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
You have to know the facts before you can distort them.

sinsi

My test box - Windows 7 Ultimate x64

        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


Gunther

Hi sinsi,

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

Gunther
You have to know the facts before you can distort them.

sinsi


Gunther

Hi Sinsi,

Quote from: sinsi on April 27, 2014, 08:04:42 PM
Kaveri, based on the Steamroller microarchitecture.

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

Gunther
You have to know the facts before you can distort them.

dedndave

so, Gunther,

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

Gunther

Dave,

Quote from: dedndave 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 ?

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
You have to know the facts before you can distort them.

dedndave

thanks   :t
one more question.....

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

Gunther

Dave,

Quote from: dedndave on June 25, 2014, 01:36:08 AM
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
You have to know the facts before you can distort them.

dedndave

thanks again, Gunther   :t

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