Текущий архив: 2002.04.18;
Скачать: CL | DM;
Вниз
WinApi Найти похожие ветки
← →
AndreySG (2002-02-15 09:12) [0]Как узнать сколько кэша на процессоре
← →
VuDZ (2002-02-15 11:44) [1]static DWORD proc_cache_l1[4] = { 0, 0, 0, 0 };
static DWORD proc_cache_l2[4] = { 0, 0, 0, 0 };
void cache(DWORD &l1, DWORD &l2){
_asm{
mov eax,080000000h ; Check for support of extended functions.
CPUID
; Check which extended functions can be called
cmp eax,080000001h ; Extended Feature Bits
jb $$ ; jump if not supported
cmp eax, 080000004h ; CPU Name string
jb $$ ; jump if not supported
cmp eax, 080000005h ; L1 Cache information
jb $$ ; jump if not supported
cmp eax, 080000006h ; L2 Cache information
jb short just_L1 ; jump if not supported
; Query and save L2 cache information
mov eax,080000006h ; L2 Cache Information
CPUID ; Interpretation is CPU specific, but
; fetching is not.
mov DWORD PTR [proc_cache_l2+0],eax
mov DWORD PTR [proc_cache_l2+4],ebx
mov DWORD PTR [proc_cache_l2+8],ecx
mov DWORD PTR [proc_cache_l2+12],edx
just_L1:
; Query and save L1 cache informatin
mov eax,080000005h ; L1 Cache Information
CPUID ; Interpretation is CPU specific, but
; fetching is not.
mov DWORD PTR [proc_cache_l1+0],eax
mov DWORD PTR [proc_cache_l1+4],ebx
mov DWORD PTR [proc_cache_l1+8],ecx
mov DWORD PTR [proc_cache_l1+12],edx
$$:
}
l2 = (proc_cache_l2[2] >> 16) & 0xffff;
l1 = (proc_cache_l1[2] >> 24) & 0xff;
}
void main()
{
DWORD d1, d2;
cache(d1, d2);
printf("L1 Size - %i\n", d1);
printf("L2 Size - %i\n", d2);
getch();
}
← →
AndreySG (2002-02-15 13:17) [2]Но ведь это, как бы Си,а мне бы на дельфях, но всеравно спасибо
← →
VuDZ (2002-02-15 13:21) [3]а что ассемблер сложно на делфи перевести?
пожалуйста
← →
Alx2 (2002-02-15 13:49) [4]Перевел, но не проверил: у меня CPU Name string not supported :(
Type
Word4Array = packed array [0..3] of DWORD;
Const proc_cache_l1 : WORD4Array = ( 0, 0, 0, 0 );
proc_cache_l2 : WORD4Array = ( 0, 0, 0, 0 );
procedure cache(Var l1, l2 : DWord); stdcall;
label just_L1, _exit;
begin
asm
mov eax,080000000h; // Check for support of extended functions.
// CPUID
db $0f
db $a2
// ; Check which extended functions can be called
cmp eax,080000001h //; Extended Feature Bits
jb _exit // jump if not supported
cmp eax, 080000004h // CPU Name string
jb _exit // jump if not supported
cmp eax, 080000005h // L1 Cache information
jb _exit // jump if not supported
cmp eax, 080000006h // L2 Cache information
jb just_L1 // jump if not supported
// Query and save L2 cache information
mov eax,080000006h // L2 Cache Information
// CPUID // Interpretation is CPU specific, but
db $0f
db $a2
// fetching is not.
mov DWORD PTR [proc_cache_l2+0],eax
mov DWORD PTR [proc_cache_l2+4],ebx
mov DWORD PTR [proc_cache_l2+8],ecx
mov DWORD PTR [proc_cache_l2+12],edx
just_L1:
// Query and save L1 cache informatin
mov eax,080000005h // L1 Cache Information
// CPUID // Interpretation is CPU specific, but
db $0f
db $a2
// fetching is not.
mov DWORD PTR [proc_cache_l1+0],eax
mov DWORD PTR [proc_cache_l1+4],ebx
mov DWORD PTR [proc_cache_l1+8],ecx
mov DWORD PTR [proc_cache_l1+12],edx
_exit:
end;
l2 := (proc_cache_l2[2] shr 16) and $ffff;
l1 := (proc_cache_l1[2] shr 24) and $ff;
end;
← →
VuDZ (2002-02-15 16:21) [5]а просто без проверки, сразу эти строки?
вообще, надо для каждого проца посмотреть. по-моему, это стандартный механизм, но он может поддерживаться не всеми процами
mov eax,080000006h // L2 Cache Information
// CPUID // Interpretation is CPU specific, but
db $0f
db $a2
← →
Alx2 (2002-02-15 16:32) [6]Нули дает в ответе (и Delphi и MSVC 6.0) :(
← →
VuDZ (2002-02-15 16:50) [7]а что за проц?
← →
Alx2 (2002-02-15 16:55) [8]PIII EB 800Mhz
← →
VuDZ (2002-02-15 18:13) [9]тогды надо идти к интелу на сайт и брать от туда доку... это метод для K6 & K7
Страницы: 1 вся ветка
Текущий архив: 2002.04.18;
Скачать: CL | DM;
Память: 0.46 MB
Время: 0.007 c