Einzelnen Beitrag anzeigen

omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#8

Re: Anzahl der CPU KERNE rausfinden??

  Alt 15. Mai 2007, 01:47
Ich habe hier folgendes gefunden...

Delphi-Quellcode:
function GetCPUCount : DWord;
var
  SysInfo : TSystemInfo;
begin
  GetSystemInfo(SysInfo);
  Result := SysInfo.dwNumberOfProcessors;
end;

function GetCPULogicalProcessorCount: Integer;
const
  EFLAGS_ID_BIT = 1 shl 21;
asm
  push ebx

//detect CPUID support
  pushfd
  mov eax, [esp]
  xor dword ptr [esp], EFLAGS_ID_BIT
  popfd
  pushfd
  mov edx, [esp]
  mov [esp], eax
  popfd
  cmp eax, edx
  jz @NoHyperthreading // CPUID not supported; pre-pentium

  xor eax, eax
  cpuid
  cmp ebx, $756E6547
  jnz @NoHyperthreading // Not Genuine Intel; CPUID not relyable
  cmp edx, $49656E69
  jnz @NoHyperthreading // Not Genuine Intel; CPUID not relyable
  cmp ecx, $6C65746E
  jnz @NoHyperthreading // Not Genuine Intel; CPUID not relyable

  cmp eax, 1
  jb @NoHyperthreading // CPU doesn't support CPUID info level 1

  mov eax, 1
  cpuid
  shr ebx, 16
  and ebx, $FF
  mov eax, ebx
  mov edx, 1
  test eax, eax
  cmovz eax, edx
  jmp @Done

@NoHyperthreading:
  mov eax, 1

@Done:
  pop ebx
end;

procedure TForm.ButtonClick(Sender: TObject);
begin
  ShowMessage(IntToStr(GetCPUCount div GetCPULogicalProcessorCount));
end;
Gruss
Thorsten
  Mit Zitat antworten Zitat