KaFu Posted September 23, 2011 Posted September 23, 2011 (edited) HiHo, to further enhance my project I need to detect the installed CPU type. The program relies on the MPlayer, and there exist always four builds: P3, P4, Athlon and RTM (runtime detection for unknown CPUs). To decide which build to use I found a small app called cpuinfo.exe in one of the installers for MPlayer. Now my question is, are the checks I'm doing sufficient and correct? Also ripped em from the MPlayer installer . #include <Constants.au3> Local $iPID_CPUInfo = Run(@ScriptDir & "\cpuinfo.exe", @ScriptDir, @SW_HIDE, $STDOUT_CHILD) Local $sStdout_Buffer_CPUInfo, $s_CPU_Detected While 1 $sStdout_Buffer_CPUInfo &= StdoutRead($iPID_CPUInfo) If @error Then ExitLoop WEnd If StringInStr($sStdout_Buffer_CPUInfo, "3DNOWEXT") Then $s_CPU_Detected = "AMD Athlon" ElseIf StringInStr($sStdout_Buffer_CPUInfo, "SSE2") Then $s_CPU_Detected = "Intel P4" ElseIf StringInStr($sStdout_Buffer_CPUInfo, "SSE") Then $s_CPU_Detected = "Intel P3" Else $s_CPU_Detected = "Unknown CPU" EndIf MsgBox(0, "Your system is running on an", $s_CPU_Detected) Here's the detection part from the NSIS installer script, but the checks for MMX, CMOV and SSE seemed superfluous to me. !insertmacro CheckCPUExt "$2" "MMX" CPU_HAS_MMX Goto CPU_DETECTION_DONE CPU_HAS_MMX: !insertmacro CheckCPUExt "$2" "CMOV" CPU_HAS_CMOV Goto CPU_DETECTION_DONE CPU_HAS_CMOV: !insertmacro CheckCPUExt "$2" "SSE" CPU_HAS_SSE Goto CPU_DETECTION_DONE CPU_HAS_SSE: !insertmacro CheckCPUExt "$2" "3DNOWEXT" CPU_HAS_3DNOWEXT !insertmacro CheckCPUExt "$2" "SSE2" CPU_HAS_SSE2 StrCpy $4 3 #P3 Goto CPU_DETECTION_DONE CPU_HAS_3DNOWEXT: StrCpy $4 2 #AthlonXP Goto CPU_DETECTION_DONE CPU_HAS_SSE2: StrCpy $4 4 #P4 Goto CPU_DETECTION_DONE cpuinfo.zip Best Regards Edited September 23, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
BrewManNH Posted September 23, 2011 Posted September 23, 2011 (edited) Here's a script generated by that might help. expandcollapse popup; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\" & $strComputer & "ROOTCIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "AddressWidth: " & $objItem.AddressWidth & @CRLF $Output = $Output & "Architecture: " & $objItem.Architecture & @CRLF $Output = $Output & "Availability: " & $objItem.Availability & @CRLF $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF $Output = $Output & "CpuStatus: " & $objItem.CpuStatus & @CRLF $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF $Output = $Output & "CurrentClockSpeed: " & $objItem.CurrentClockSpeed & @CRLF $Output = $Output & "CurrentVoltage: " & $objItem.CurrentVoltage & @CRLF $Output = $Output & "DataWidth: " & $objItem.DataWidth & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF $Output = $Output & "ExtClock: " & $objItem.ExtClock & @CRLF $Output = $Output & "Family: " & $objItem.Family & @CRLF $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output = $Output & "L2CacheSize: " & $objItem.L2CacheSize & @CRLF $Output = $Output & "L2CacheSpeed: " & $objItem.L2CacheSpeed & @CRLF $Output = $Output & "L3CacheSize: " & $objItem.L3CacheSize & @CRLF $Output = $Output & "L3CacheSpeed: " & $objItem.L3CacheSpeed & @CRLF $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF $Output = $Output & "Level: " & $objItem.Level & @CRLF $Output = $Output & "LoadPercentage: " & $objItem.LoadPercentage & @CRLF $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF $Output = $Output & "MaxClockSpeed: " & $objItem.MaxClockSpeed & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "NumberOfCores: " & $objItem.NumberOfCores & @CRLF $Output = $Output & "NumberOfLogicalProcessors: " & $objItem.NumberOfLogicalProcessors & @CRLF $Output = $Output & "OtherFamilyDescription: " & $objItem.OtherFamilyDescription & @CRLF $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0) $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF $Output = $Output & "ProcessorId: " & $objItem.ProcessorId & @CRLF $Output = $Output & "ProcessorType: " & $objItem.ProcessorType & @CRLF $Output = $Output & "Revision: " & $objItem.Revision & @CRLF $Output = $Output & "Role: " & $objItem.Role & @CRLF $Output = $Output & "SocketDesignation: " & $objItem.SocketDesignation & @CRLF $Output = $Output & "Status: " & $objItem.Status & @CRLF $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF $Output = $Output & "Stepping: " & $objItem.Stepping & @CRLF $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF $Output = $Output & "UniqueId: " & $objItem.UniqueId & @CRLF $Output = $Output & "UpgradeMethod: " & $objItem.UpgradeMethod & @CRLF $Output = $Output & "Version: " & $objItem.Version & @CRLF $Output = $Output & "VoltageCaps: " & $objItem.VoltageCaps & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Processor" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc Edited September 23, 2011 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Envoi Posted September 23, 2011 Posted September 23, 2011 Here's a quick way to grab the CPU name. $PID = Run("wmic cpu get name", '', '', 0x2) While 1 $read = StdoutRead($PID) If @error Then ExitLoop MsgBox(0, '', $read) WEnd Hope this helps.
Ascend4nt Posted September 25, 2011 Posted September 25, 2011 (edited) Registry method: expandcollapse popup; =============================================================================================================================== ; Func _CPURegistryInfo() ; ; Get # of cores, name, and clock speed of CPU from Registry ; ; Returns: ; Success: An array of information, as follows: ; [0] = # of Reported CPU's (can include 'logical' processors as well (# CPU's * # of hyperthreads)) ; [1] = CPU Speed (Mhz) ; [2] = CPU Name ; [3] = Identifier (family, model, stepping) ; [4] = Vendor name ; [5] = Feature Set (unsure what values are which..) ; Failure: @error = same as returned by RegEnumKey(), with an empty array ([0] = -1 though) ; @error = 1 = unable to open requested key ; @error = 2 = unable to open requested Main key ; @error = 3 = unable to connect to *remote* registry (not likely a return here) ; @error = -1 = unable to retrieve requested subkey (key instance out of range) ; ; Author: tip (as _FasterCpuInfo), slight adjustments by Ascend4nt ; AutoIT forums thread: "Basic Cpu Info Script, Collects basic information about CPU." ; @ http://www.autoitscript.com/forum/index.php?showtopic=83373&hl=cpu++cores ; =============================================================================================================================== Func _CPURegistryInfo() Local $aCPUInfo[6] $aCPUInfo[0]=EnvGet("NUMBER_OF_PROCESSORS") If @error Then Return SetError(@error,0,$aCPUInfo) $aCPUInfo[1] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","~MHz") $aCPUInfo[2] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","ProcessorNameString") $aCPUInfo[3] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","Identifier") $aCPUInfo[4] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","VendorIdentifier") $aCPUInfo[5] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","FeatureSet") #cs ; Full Info Display MsgBox(64,"CPU Report from Registry","Processor Count [includes logical]: "&$aCPUInfo[0]&@CRLF& _ "Speed: "&$aCPUInfo[1]&" Mhz"&@CRLF& _ "Processor Name String: "&$aCPUInfo[2]&@CRLF& _ "Processor Identifier String: "&$aCPUInfo[3]&@CRLF& _ "Vendor Identifier String: "&$aCPUInfo[4]&@CRLF& _ "FeatureSet: "&Hex($aCPUInfo[5])) #ce Return $aCPUInfo EndFunc Edited September 25, 2011 by Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Ramzes Posted September 25, 2011 Posted September 25, 2011 You can also use ASM method: Func Demo6() ; Demo 6: Read CPUID FasmReset($Fasm) FasmAdd($Fasm, "use32") FasmAdd($Fasm, "push ebp") FasmAdd($Fasm, "mov ebp, esp") FasmAdd($Fasm, "pushad") FasmAdd($Fasm, "xor eax, eax") FasmAdd($Fasm, "cpuid") FasmAdd($Fasm, "mov edi, [ebp + 08]") FasmAdd($Fasm, "mov [edi], ebx") FasmAdd($Fasm, "mov [edi + 4], edx") FasmAdd($Fasm, "mov [edi + 8], ecx") FasmAdd($Fasm, "mov al, 0") FasmAdd($Fasm, "mov [edi + 12], al") FasmAdd($Fasm, "popad") FasmAdd($Fasm, "pop ebp") FasmAdd($Fasm, "ret 4") ConsoleWrite(String(FasmGetBinary($Fasm)) & @CRLF) Local $Ret = MemoryFuncCall("uint", FasmGetFuncPtr($Fasm), "str", "") MsgBox(0, "Demo 6: CPUID", "CPUID = " & $Ret[1]) EndFunc This is Demo #6 from examples. Script returns: CPUID = AuthenticAMD Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]
JohnOne Posted September 25, 2011 Posted September 25, 2011 I'm a fan of the reg method (tip/Ascend4nt) but does it work for 64bit OS? Anyone test? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
KaFu Posted September 25, 2011 Author Posted September 25, 2011 Thanks for the replies guys . After doing some more reading I guess I'll stick to my initial version. The feature sets I switch on (3DNOWEXT, SSE & SSE2) seem to be unique the different CPU builds and I need exactly the differentiation between P3, P4, Athlon and Unknown (as these are also the different MPlayer builds available). All other suggestions result in strings to parse... but how consistent are these strings really between the dozens of different CPU layouts ? OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Ascend4nt Posted September 25, 2011 Posted September 25, 2011 For checking on processor features, look at IsProcessorFeaturePresent. You can also check this stuff with CPUID. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
KaFu Posted September 25, 2011 Author Posted September 25, 2011 Nice, thanks for that hint m8, no need for an external app anymore ... Global $s_CPU_Detected = "Unknown CPU" If _IsProcessorFeaturePresent(7) Then $s_CPU_Detected = "AMD Athlon" ElseIf _IsProcessorFeaturePresent(10) Then $s_CPU_Detected = "Intel P4" ElseIf _IsProcessorFeaturePresent(6) Then $s_CPU_Detected = "Intel P3" EndIf MsgBox(0, "IsProcessorFeaturePresent", "3DNOW" & @TAB & _IsProcessorFeaturePresent(7) & @CRLF & "SSE" & @TAB & _IsProcessorFeaturePresent(6) & @CRLF & "SSE2" & @TAB & _IsProcessorFeaturePresent(10) & @CRLF & @CRLF & "=>" & @TAB & $s_CPU_Detected) Func _IsProcessorFeaturePresent($iFeature) #cs _IsProcessorFeaturePresent(7) ; PF_3DNOW_INSTRUCTIONS_AVAILABLE _IsProcessorFeaturePresent(6) ; PF_XMMI_INSTRUCTIONS_AVAILABLE (SSE) _IsProcessorFeaturePresent(10) ; PF_XMMI64_INSTRUCTIONS_AVAILABLE (SSE2) #ce ; http://msdn.microsoft.com/en-us/library/ms724482%28v=VS.85%29.aspx $iRes = DllCall("Kernel32.dll", "int", "IsProcessorFeaturePresent", "DWORD", $iFeature) Return $iRes[0] EndFunc ;==>_IsProcessorFeaturePresent OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Chimaera Posted September 25, 2011 Posted September 25, 2011 That returns for me3DNOW 0SSE 1SSE2 1 => Intel P4 But mine is this|Intel® Core™ i5 CPU 750 @ 2.67GHz Is there a way to include more cpus? If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
JohnOne Posted September 25, 2011 Posted September 25, 2011 I think the point is, that it identifies what build to use. In your case it would require P4 build. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
AdmiralAlkex Posted September 25, 2011 Posted September 25, 2011 That returns for me But mine is this|Intel® Core™ i5 CPU 750 @ 2.67GHz Is there a way to include more cpus?The name is irrelevant, it's the capabilities that is wanted. Your CPU have SSE2 so you want the Intel P4 build. Seems at least half the people in the thread missed that. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
trancexx Posted September 25, 2011 Posted September 25, 2011 (edited) About missing things, the results for me are:0, 1, 1 - x64 Autoit1, 1, 1 - x86 AutoitI don't have Intel's processor. Be smart and go with CPUID. Edited September 25, 2011 by trancexx ♡♡♡ . eMyvnE
Ascend4nt Posted September 25, 2011 Posted September 25, 2011 About missing things, the results for me are:0, 1, 1 - x64 Autoit1, 1, 1 - x86 AutoitI don't have Intel's processor. Be smart and go with CPUID.This has to do with the bit-mode you are running in of course. In 64-bit mode, 3DNow and MMX will be reported as unavailable by the O/S because with 64-bit programming they are considered deprecated: MSDN:The x87, MMX, and 3DNow! instruction sets are deprecated in 64-bit modes. The instructions sets are still present for backward compatibility for 32-bit mode; however, to avoid compatibility issues in the future, their use in current and future projects is discouraged.AMD:3DNow! instructions are being deprecated and will not be supported in certain upcoming AMD processors. In those processors, the 3DNow! Instructions feature flag bit will not be set.Current AMD processors support SSE, SSE2 & SSE3, so the check for 'best-mode' for KaFu should go in the order SSE2, SSE, 3DNow. And of course if he's running a 64-bit version of MPlayer, 3DNow shouldn't be used (and probably in general given what AMD says). If its important to check for AMD vs. Intel, the registry 'VendorIdentifier' key (in the script I posted) will either read 'GenuineIntel' or 'AuthenticAMD' (the same strings CPUID returns), so that's one key way to distinguish CPU's. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
KaFu Posted September 26, 2011 Author Posted September 26, 2011 (edited) JohnOne and AdmiralAlkex are right , for me it's all about determining which of the available MPlayer builds to use. More detailed analysis could be done checking for SSE3 (P5) with IsProcessorFeaturePresent, but that flag seems only available on Vista+ Systems. So a more in depth check of the CPUID would be the way to go. trancexx hint (even as everything is 32bit only) and Ascend4nt research on the 3DNOW flag 3DNow! instructions are being deprecated and will not be supported in certain upcoming AMD processors. In those processors, the 3DNow! Instructions feature flag bit will not be set. convinced me it is better to use the CPUID... thanks for all the input ! expandcollapse popup#AutoIt3Wrapper_UseX64=n #include <Memory.au3> Global $s_CPU_Detected = "Unknown CPU" Switch _VendorID_from_CPUID() Case "AuthenticAMD" $s_CPU_Detected = "AMD Athlon" Case "GenuineIntel" If _IsProcessorFeaturePresent(10) Then $s_CPU_Detected = "Intel P4" ElseIf _IsProcessorFeaturePresent(6) Then $s_CPU_Detected = "Intel P3" EndIf EndSwitch MsgBox(0, "_VendorID_from_CPUID & IsProcessorFeaturePresent", "VendorID from CPUID" & @TAB & _VendorID_from_CPUID() & @CRLF & "SSE" & @TAB & @TAB & @TAB & _IsProcessorFeaturePresent(6) & @CRLF & "SSE2" & @TAB & @TAB & @TAB & _IsProcessorFeaturePresent(10) & @CRLF & @CRLF & "=>" & @TAB & $s_CPU_Detected) Func _IsProcessorFeaturePresent($iFeature) #cs _IsProcessorFeaturePresent(6) ; PF_XMMI_INSTRUCTIONS_AVAILABLE (SSE) _IsProcessorFeaturePresent(10) ; PF_XMMI64_INSTRUCTIONS_AVAILABLE (SSE2) #ce ; http://msdn.microsoft.com/en-us/library/ms724482%28v=VS.85%29.aspx $iRes = DllCall("Kernel32.dll", "int", "IsProcessorFeaturePresent", "DWORD", $iFeature) Return $iRes[0] EndFunc ;==>_IsProcessorFeaturePresent ConsoleWrite(_VendorID_from_CPUID() & @CRLF) Func _VendorID_from_CPUID() ; Extracted from trancexxs code for parsing the CPUID ; http://www.autoitscript.com/forum/topic/120314-getting-system-cpu-info/page__view__findpost__p__836097 ; ; Allocating memory with $PAGE_EXECUTE_READWRITE Local $pRemoteCode = _MemVirtualAlloc(0, 512, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; Standard allocation in reserved address Local $tCodeBuffer = DllStructCreate("byte[512]", $pRemoteCode) Local $tBuffer = DllStructCreate("char[12]") Local $pBuffer = DllStructGetPtr($tBuffer) DllStructSetData($tCodeBuffer, 1, _ "0x" & _ "" & _; 10. SET eax AND CALL "B8" & SwapEndian(0) & _ ; mov eax, 0 "0FA2" & _ ; cpuid "" & _ ; 20. ARRANGE DATA "891D" & SwapEndian($pBuffer) & _ ; mov dword[$pBuffer], ebx "8915" & SwapEndian($pBuffer + 4) & _ ; mov dword[$pBuffer + 4], edx "890D" & SwapEndian($pBuffer + 8) & _ ; mov dword[$pBuffer + 8], ecx "" & _ ; 30. RETURN "C3" _ ) Local $iRet = _RunAtAddress($pRemoteCode) If @error Then Return SetError(1, 0, 0) _MemVirtualFree($pRemoteCode, 512, $MEM_DECOMMIT) Return DllStructGetData($tBuffer, 1) EndFunc ;==>_VendorID_from_CPUID Func _RunAtAddress($pCode) Local $aCall = DllCall("user32.dll", "dword_ptr", "CallWindowProcW", "ptr", $pCode, "ptr", 0, "dword", 0, "wparam", 0, "lparam", 0) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ;==>_RunAtAddress Func SwapEndian($iValue, $iSize = 0) If $iSize Then Local $sPadd = "00000000" Return Hex(BinaryMid($iValue, 1, $iSize)) & StringLeft($sPadd, 2 * ($iSize - BinaryLen($iValue))) EndIf Return Hex(Binary($iValue)) EndFunc ;==>SwapEndian Edited September 26, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Ascend4nt Posted September 26, 2011 Posted September 26, 2011 KaFu, I think you're missing something important here - SSE and SSE2 should perform much better than 3D-Now instructions, so if an AMD chipset supports them, why not install the best-performing version rather than worry about the processor? Also - the CPUID function you call is much simpler as a one-line Registry read My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
KaFu Posted September 26, 2011 Author Posted September 26, 2011 Of course you're right about the regread, missed that ... Global $s_CPU_Detected = "Unknown CPU" Switch RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","VendorIdentifier") Case "AuthenticAMD" $s_CPU_Detected = "AMD Athlon" Case "GenuineIntel" If _IsProcessorFeaturePresent(10) Then $s_CPU_Detected = "Intel P4" ElseIf _IsProcessorFeaturePresent(6) Then $s_CPU_Detected = "Intel P3" EndIf EndSwitch MsgBox(0, "_VendorID_from_CPUID & IsProcessorFeaturePresent", "VendorID" & @TAB & @TAB & RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","VendorIdentifier") & @CRLF & "SSE" & @TAB & @TAB & _IsProcessorFeaturePresent(6) & @CRLF & "SSE2" & @TAB & @TAB & _IsProcessorFeaturePresent(10) & @CRLF & @CRLF & "=>" & @TAB & $s_CPU_Detected) Func _IsProcessorFeaturePresent($iFeature) #cs _IsProcessorFeaturePresent(6) ; PF_XMMI_INSTRUCTIONS_AVAILABLE (SSE) _IsProcessorFeaturePresent(10) ; PF_XMMI64_INSTRUCTIONS_AVAILABLE (SSE2) #ce ; http://msdn.microsoft.com/en-us/library/ms724482%28v=VS.85%29.aspx $iRes = DllCall("Kernel32.dll", "int", "IsProcessorFeaturePresent", "DWORD", $iFeature) Return $iRes[0] EndFunc ;==>_IsProcessorFeaturePresent The SSE and SSE2 featureset check is not really about the features themselves but just a way to distinguish between P3 and P4 as MPlayer comes in four builds: Athlon, P3, P4 & RTM (for unknown CPUs). What exactly the differences between the builds are... I dont know ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
AdmiralAlkex Posted September 26, 2011 Posted September 26, 2011 So SSE was actually never needed? That's confusing. What about 3DNow? AMD dropped it in 2011. Also some older VIA cpu's had 3DNow so they would benefit. Processors supporting 3DNow! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
KaFu Posted September 26, 2011 Author Posted September 26, 2011 So SSE was actually never needed?In context of my question it is needed to identify that an Intel CPU is at least a P3 (_IsProcessorFeaturePresent(6) ; PF_XMMI_INSTRUCTIONS_AVAILABLE (SSE)). That's confusing. What about 3DNow? AMD dropped it in 2011. Also some older VIA cpu's had 3DNow so they would benefit.Yeah, that's why I dropped the query for 3DNow and switched to the regread of the VendorIdentifier key to identify an AMD CPU ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now