Wrong number of logical processors

delphi package - automated exception handling

Wrong number of logical processors

Postby Han312 » Thu Nov 28, 2019 4:07 pm

Within of a report we got:

processors : 16x AMD Ryzen 9 3900X 12-Core Processor


The 16x seems to be wrong.
Han312
 
Posts: 42
Joined: Mon Mar 14, 2016 3:49 pm

Re: Wrong number of logical processors

Postby madshi » Thu Nov 28, 2019 4:19 pm

Maybe you can debug the code on your side?

Code: Select all
function GetCpuCount : integer;
var i1 : integer;
begin
  result := 16;
  for i1 := 1 to 15 do
    if RegReadStr(HKEY_LOCAL_MACHINE, 'hardware\description\system\centralProcessor\' + IntToStrExW(i1), 'ProcessorNameString') = '' then begin
      result := i1;
      break;
    end;
end;
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm

Re: Wrong number of logical processors

Postby Han312 » Fri Nov 29, 2019 8:08 am

There are values for 0 to 23.

So you shouldn't stop at 15.
Since you check for an empty string a simple inc( i1 ) should also do?

I guess that cpu with more than 8 cores will become more and more common.
Han312
 
Posts: 42
Joined: Mon Mar 14, 2016 3:49 pm

Re: Wrong number of logical processors

Postby madshi » Fri Nov 29, 2019 8:11 am

Ah, makes perfect sense, I'll change the code accordingly.
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm

Re: Wrong number of logical processors

Postby madshi » Fri Nov 29, 2019 8:38 am

New version, should support up to 256 cores:

Code: Select all
function GetCpuCount : integer;
var i1, i2 : integer;
begin
  result := 256;
  for i1 := 0 to 15 do
    if RegReadStr(HKEY_LOCAL_MACHINE, 'hardware\description\system\centralProcessor\' + IntToStrExW(i1 * 16 + 16), 'ProcessorNameString') = '' then begin
      result := i1 * 16 + 16;
      for i2 := 1 to 15 do
        if RegReadStr(HKEY_LOCAL_MACHINE, 'hardware\description\system\centralProcessor\' + IntToStrExW(i1 * 16 + i2), 'ProcessorNameString') = '' then begin
          result := i1 * 16 + i2;
          break;
        end;
      break;
    end;
end;
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: Google [Bot] and 11 guests

cron