Old 17th February 2013, 14:52   #1
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
CPUFeatures plug-in

Hi!

I recently created a plug-in to detect the CPU features (MMX, SSE, AVX, etc) at runtime. Since I didn't want to re-invent the wheel, I simply created a wrapper-library around the CPU detection code from x264 and then built the NSIS plug-in on top. This was mainly created for my own needs, but I though it might be useful for others too.

Note: Some CPU features are not currently detected, such as "3DNow!", because it probably was never relevant for x264. I maybe will hack that in at a later time, if anybody still needs that nowadays. Also there are some x264-specifc flags you can simply ignore...

Wiki page:
http://nsis.sourceforge.net/CPUFeatures_plug-in

Testing on different CPU's would be appreciated, so I have attached test app
Attached Files
File Type: zip CPUFeatures-TestApp.zip (32.6 KB, 130 views)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 17th February 2013, 21:13   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
As a matter of fact I was in need of a 3DNow CPU just two weeks ago. Thanks for sharing!
MSG is offline   Reply With Quote
Old 21st February 2013, 14:29   #3
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Okay, I hacked in support for 3DNow! and 3DNow!Ex. And I also added a function to get the no. of CPU cores:
http://nsis.sourceforge.net/CPUFeatures_plug-in

(3DNow! support is completely untested, as my last AMD machine died a while ago)
Attached Files
File Type: zip CPUFeatures-TestApp.zip (33.0 KB, 114 views)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 21st February 2013, 20:16   #4
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Quote:
Originally Posted by LoRd_MuldeR View Post
Okay, I hacked in support for 3DNow! and 3DNow!Ex. And I also added a function to get the no. of CPU cores:
http://nsis.sourceforge.net/CPUFeatures_plug-in

(3DNow! support is completely untested, as my last AMD machine died a while ago)
Okay, I ask a friend to test the new version on his AMD and 3DNow!(Ex) detection seems to work as expected.

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 22nd February 2013, 08:24   #5
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
This is going to be really helpful to some people, thank you.
MSG is offline   Reply With Quote
Old 22nd February 2013, 19:42   #6
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
You're welcome.

I just added another function to check for multiple features at once. Might simplify things a bit in some situations, I think.

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 24th February 2013, 18:07   #7
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
If you feel crazy, you could maybe write wrapper macros for ${If} ${Supports3DNow!} or ${If} ${CPUSupports} "MMX" or something. But only if you feel crazy. :-)
MSG is offline   Reply With Quote
Old 24th February 2013, 18:19   #8
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Unfortunately I'm not enough crazy to understand LogicLib

(I mean that I understand how to use it, actually I use it extensively, but I have not been able to follow its code)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 25th February 2013, 09:06   #9
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
code:
!macro _CPUSupports _a _b _t _f
!insertmacro _LOGICLIB_TEMP
push `${_b}`
CPUFeatures::CheckCPUFeature /NOUNLOAD
Pop $_LOGICLIB_TEMP
!insertmacro _= $_LOGICLIB_TEMP `yes` `${_t}` `${_f}`
!macroend
!define CPUSupports `"" _CPUSupports`



Didn't test this, but it looks ok to me.

By the way, I see you're still using /NOUNLOAD. If you're still using the old plugin model, you might want to update it..
MSG is offline   Reply With Quote
Old 25th February 2013, 13:45   #10
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Quote:
Originally Posted by MSG View Post
code:
!macro _CPUSupports _a _b _t _f
!insertmacro _LOGICLIB_TEMP
push `${_b}`
CPUFeatures::CheckCPUFeature /NOUNLOAD
Pop $_LOGICLIB_TEMP
!insertmacro _= $_LOGICLIB_TEMP `yes` `${_t}` `${_f}`
!macroend
!define CPUSupports `"" _CPUSupports`



Didn't test this, but it looks ok to me.
Okay, thanks! I will give that code a try. And if it works, I will commit.

Quote:
Originally Posted by MSG View Post
By the way, I see you're still using /NOUNLOAD. If you're still using the old plugin model, you might want to update it..
Actually I think I do use the new model (with callback function), so I might be able to simply drop the /NOUNLOAD.

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 25th February 2013, 21:23   #11
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Okay, I added the LogicLib support macros, as suggested.

But in the last line it must be _== instead of _=. That gave me quite a headache!

New version here:
http://nsis.sourceforge.net/CPUFeatures_plug-in
Attached Files
File Type: zip CPUFeatures-TestApp.zip (33.6 KB, 120 views)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump