[C/C++] Détection de l'hyperthreading :(

Détection de l'hyperthreading :( [C/C++] - C++ - Programmation

Marsh Posté le 07-11-2003 à 18:52:14    

Hello !
 
j'avais trouvé il y a longtemps une fonction me permettant de détecter l'hyperthreading, et malheureusement, je l'ai perdue :(  
 
Auriez vous un lien ou une fonction ( C/C++/delphi m'en fiche) me permettant de savoir si l'HT est activé ou non sur le processeur courant ?
 
j'ai épluché google et la MSDN sans succès. j'ai reregardé le site d'intel sans trop de succès aussi :(
 
merci encore !

Reply

Marsh Posté le 07-11-2003 à 18:52:14   

Reply

Marsh Posté le 07-11-2003 à 18:55:47    

Pas une feinte au CPUID ?

Reply

Marsh Posté le 07-11-2003 à 18:58:16    

Si je me rapelle bien, il fallait passer par le nombre de CPU physique et le comparer au nombre de CPU logiques...
 
mais bon, j'aimerai bien retrouver la fonction, je sais que je l'avais trouvée sur un datasheet de chez intel, mais y en a des tonnes :-(

Reply

Marsh Posté le 08-11-2003 à 01:24:26    

tetedeiench a écrit :

Si je me rapelle bien, il fallait passer par le nombre de CPU physique et le comparer au nombre de CPU logiques...
 
mais bon, j'aimerai bien retrouver la fonction, je sais que je l'avais trouvée sur un datasheet de chez intel, mais y en a des tonnes :-(


 

Code :
  1. #define HT_BIT 0x10000000 // Bit 28 indicates Hyper-Threading Technology support
  2. #define FAMILY_ID 0x0f00 // Bits 11 through 8 is family processor id
  3. #define EXT_FAMILY_ID 0x0f00000 // Bits 23 through 20 is extended family processor id
  4. #define PENTIUM4_ID 0x0f00 // Pentium 4 family processor id
  5. // Returns non-zero if Hyper-Threading Technology supported zero if not.
  6. // Hyper-Threading Technology still may not be enabled due to BIOS or OS settings.
  7. unsigned int Is_HT_Supported(void)
  8. {
  9. unsigned int reg_eax = 0;
  10. unsigned int reg_edx = 0;
  11. unsigned int vendor_id[3] = {0, 0, 0};
  12. __try { // verify cpuid instruction is supported
  13. __asm {
  14. xor eax, eax // call cpuid with eax = 0 (faster than mov ax, 1)
  15. cpuid // to get vendor id string
  16. mov vendor_id, ebx
  17. mov vendor_id + 4, edx
  18. mov vendor_id + 8, ecx
  19. mov eax, 1 // call cpuid with eax = 1
  20. cupid // to get the CPU family information
  21. mov reg_eax, eax // eax contains cpu family type info
  22. mov reg_edx, edx // edx has Hyper-Threading info
  23. }
  24. }
  25. __except (EXCEPTION_EXECUTE_HANDLER ) {
  26. return 0; // The CPUID call is not supported
  27. }
  28. // Is this a Pentium 4 or later processor?
  29. if (((reg_eax & FAMILY_ID) == PENTIUM4_ID) || (reg_eax & EXT_FAMILY_ID))
  30. if (vendor_id[0] == 'uneG')
  31. if (vendor_id[1] == 'Ieni')
  32. if (vendor_id[2] == 'letn')
  33. return (reg_edx & HT_BIT); // Intel Processor Hyper-Threading
  34. return 0; // The processor is not Intel.
  35. }


 
http://www.intel.com/cd/ids/develo [...] htm?page=3  :o

Reply

Marsh Posté le 08-11-2003 à 09:54:42    

C'est ca, merci :)  
 
Mais il manque deux trois fonctions autour, car cette fonction renvoie vrai sur mon P4 non HT ;)
 
Mais je l'ai eue, merci ^^

Reply

Marsh Posté le 08-11-2003 à 15:09:06    

ça t'embête de poster le truc complet ? ou bien un lien pour le reste ?
Merci !

Reply

Marsh Posté le 08-11-2003 à 20:25:15    

tetedeiench a écrit :

C'est ca, merci :)  
 
Mais il manque deux trois fonctions autour, car cette fonction renvoie vrai sur mon P4 non HT ;)
 
Mais je l'ai eue, merci ^^


 
non HT, ou HT présent mais désactivé ?

Reply

Marsh Posté le 09-11-2003 à 15:31:54    

BJOne a écrit :


 
non HT, ou HT présent mais désactivé ?


 
HT présent mais désactivé ( P4B inside ).
 
le lien se trouve lla :
 
http://www.intel.com/cd/ids/develo [...] /19122.htm
 

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed