Recent

Author Topic: Avaiable instruction set  (Read 477 times)

LemonParty

  • Full Member
  • ***
  • Posts: 167
Avaiable instruction set
« on: April 19, 2025, 03:51:20 pm »
How to identify which instruction set is currently enabled? Like SSE2 or AVX.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Thaddy

  • Hero Member
  • *****
  • Posts: 16937
  • Ceterum censeo Trump esse delendam
Re: Avaiable instruction set
« Reply #1 on: April 19, 2025, 04:15:02 pm »
fpc -icf ? Will list available cpu and fpu.
But the instruction set that is enabled depends on the programmer.
There is no way to detect that otherwise.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

paule32

  • Sr. Member
  • ****
  • Posts: 441
Re: Avaiable instruction set
« Reply #2 on: April 19, 2025, 05:20:20 pm »
Hello,

on my github.com Account, you can find a Python based Script that can help you to determine the CPU and BIOS Information's.

It comes with a compiled Microsoft Windows Executable that can be download under the Release Link (right side of github page).

Here the Link:
https://github.com/paule32/WindowsVersion

HTH - Hope This Helps
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

LemonParty

  • Full Member
  • ***
  • Posts: 167
Re: Avaiable instruction set
« Reply #3 on: April 19, 2025, 05:22:58 pm »
No. I mean what conditional defines defined for different instruction sets?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Thaddy

  • Hero Member
  • *****
  • Posts: 16937
  • Ceterum censeo Trump esse delendam
Re: Avaiable instruction set
« Reply #4 on: April 19, 2025, 06:30:56 pm »
That is different from your original question but that is quite easy.
Assume you compile with -CfAVX2 then your code will obey:
Code: Pascal  [Select][+][-]
  1. {$if defined(AVX2)}.....{$endif}
It is a bit cumbersome to test for any and all possible combinations, though.
What are you trying to achieve? To my mind this is in most cases an erronious way to improve your code. It is only of interest when you write inline assembler code that supports that particular define and you really know what you are doing otherwise the compiler does probably a better job.
(That's the trap beginners and intermediate level programmers make, there are few programmers that can make it stick, but there are some on this forum, like Marcov)
But possible.
(But the question is really if you are naive or an expert? That is something you have to answer to yourself.)
« Last Edit: April 19, 2025, 06:51:10 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

LemonParty

  • Full Member
  • ***
  • Posts: 167
Re: Avaiable instruction set
« Reply #5 on: April 20, 2025, 09:26:31 am »
I found.
This is not correct
Code: Pascal  [Select][+][-]
  1. {$IfDef AVX2}...
The correct variant is
Code: Pascal  [Select][+][-]
  1. {$IfDef FPUAVX2}...
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

 

TinyPortal © 2005-2018