Модераторы: feodorv, GremlinProg, xvr, Fixin
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Параметры процессора 
:(
    Опции темы
Kirk_Lee_Hammet
  Дата 8.9.2006, 18:59 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 6
Регистрация: 8.9.2006

Репутация: нет
Всего: нет



Народ помогите надо код проги которая определяет параметры процессора.
плиз очень надо... smile  smile 
PM MAIL   Вверх
_hunter
Дата 8.9.2006, 19:26 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Участник Клуба
Сообщений: 8564
Регистрация: 24.6.2003
Где: Europe::Ukraine:: Kiev

Репутация: 13
Всего: 98



о каких параметрах идет разговор?


--------------------
Tempora mutantur, et nos mutamur in illis...
PM ICQ   Вверх
Kirk_Lee_Hammet
Дата 9.9.2006, 12:30 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 6
Регистрация: 8.9.2006

Репутация: нет
Всего: нет



Название, частота, .....пять шесть любых параметров. Все что знаете.
PM MAIL   Вверх
586
Дата 9.9.2006, 12:51 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Завсегдатай
Сообщений: 2243
Регистрация: 8.5.2006

Репутация: 39
Всего: 146



PM   Вверх
Bishop
Дата 10.9.2006, 09:24 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 188
Регистрация: 3.6.2005
Где: Минск, Беларусь

Репутация: нет
Всего: 16



Kirk_Lee_Hammet
возможно, тебе будет достаточно сведений, хранящихся в реестре в разделе:
Код

HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor

PM WWW ICQ   Вверх
Damarus
Дата 10.9.2006, 11:38 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Awaiting Authorisation
Сообщений: 671
Регистрация: 6.5.2006

Репутация: 4
Всего: 29



Цитата(Kirk_Lee_Hammet @  8.9.2006,  19:59 Найти цитируемый пост)
Народ помогите надо код проги которая определяет параметры процессора.плиз очень надо...    

В MSDN есть пример:
Код

// cpuid.cpp 
// processor: x86, x64
// Use the __cpuid intrinsic to get information about a CPU

#include <stdio.h>
#include <string.h>
#include <intrin.h>

const char* szFeatures[] =
{
    "x87 FPU On Chip",
    "Virtual-8086 Mode Enhancement",
    "Debugging Extensions",
    "Page Size Extensions",
    "Time Stamp Counter",
    "RDMSR and WRMSR Support",
    "Physical Address Extensions",
    "Machine Check Exception",
    "CMPXCHG8B Instruction",
    "APIC On Chip",
    "Unknown1",
    "SYSENTER and SYSEXIT",
    "Memory Type Range Registers",
    "PTE Global Bit",
    "Machine Check Architecture",
    "Conditional Move/Compare Instruction",
    "Page Attribute Table",
    "Page Size Extension",
    "Processor Serial Number",
    "CFLUSH Extension",
    "Unknown2",
    "Debug Store",
    "Thermal Monitor and Clock Ctrl",
    "MMX Technology",
    "FXSAVE/FXRSTOR",
    "SSE Extensions",
    "SSE2 Extensions",
    "Self Snoop",
    "Hyper-threading Technology",
    "Thermal Monitor",
    "Unknown4",
    "Pend. Brk. EN."
};

int main(int argc, char* argv[])
{
    char CPUString[0x20];
    char CPUBrandString[0x40];
    int CPUInfo[4] = {-1};
    int nSteppingID = 0;
    int nModel = 0;
    int nFamily = 0;
    int nProcessorType = 0;
    int nExtendedmodel = 0;
    int nExtendedfamily = 0;
    int nBrandIndex = 0;
    int nCLFLUSHcachelinesize = 0;
    int nAPICPhysicalID = 0;
    int nFeatureInfo = 0;
    int nCacheLineSize = 0;
    int nL2Associativity = 0;
    int nCacheSizeK = 0;
    int nRet = 0;
    unsigned    nIds, nExIds, i;
    bool    bSSE3NewInstructions = false;
    bool    bMONITOR_MWAIT = false;
    bool    bCPLQualifiedDebugStore = false;
    bool    bThermalMonitor2 = false;


    // __cpuid with an InfoType argument of 0 returns the number of
    // valid Ids in CPUInfo[0] and the CPU identification string in
    // the other three array elements. The CPU identification string is
    // not in linear order. The code below arranges the information 
    // in a human readable form.
    __cpuid(CPUInfo, 0);
    nIds = CPUInfo[0];
    memset(CPUString, 0, sizeof(CPUString));
    *((int*)CPUString) = CPUInfo[1];
    *((int*)(CPUString+4)) = CPUInfo[3];
    *((int*)(CPUString+8)) = CPUInfo[2];

    // Get the information associated with each valid Id
    for (i=0; i<=nIds; ++i)
    {
        __cpuid(CPUInfo, i);
        printf_s("\nFor InfoType %d\n", i); 
        printf_s("CPUInfo[0] = 0x%x\n", CPUInfo[0]);
        printf_s("CPUInfo[1] = 0x%x\n", CPUInfo[1]);
        printf_s("CPUInfo[2] = 0x%x\n", CPUInfo[2]);
        printf_s("CPUInfo[3] = 0x%x\n", CPUInfo[3]);

        // Interpret CPU feature information.
        if  (i == 1)
        {
            nSteppingID = CPUInfo[0] & 0xf;
            nModel = (CPUInfo[0] >> 4) & 0xf;
            nFamily = (CPUInfo[0] >> 8) & 0xf;
            nProcessorType = (CPUInfo[0] >> 12) & 0x3;
            nExtendedmodel = (CPUInfo[0] >> 16) & 0xf;
            nExtendedfamily = (CPUInfo[0] >> 20) & 0xff;
            nBrandIndex = CPUInfo[1] & 0xff;
            nCLFLUSHcachelinesize = ((CPUInfo[1] >> 8) & 0xff) * 8;
            nAPICPhysicalID = (CPUInfo[1] >> 24) & 0xff;
            bSSE3NewInstructions = (CPUInfo[2] & 0x1) || false;
            bMONITOR_MWAIT = (CPUInfo[2] & 0x8) || false;
            bCPLQualifiedDebugStore = (CPUInfo[2] & 0x10) || false;
            bThermalMonitor2 = (CPUInfo[2] & 0x100) || false;
            nFeatureInfo = CPUInfo[3];
        }
    }

    // Calling __cpuid with 0x80000000 as the InfoType argument
    // gets the number of valid extended IDs.
    __cpuid(CPUInfo, 0x80000000);
    nExIds = CPUInfo[0];
    memset(CPUBrandString, 0, sizeof(CPUBrandString));

    // Get the information associated with each extended ID.
    for (i=0x80000000; i<=nExIds; ++i)
    {
        __cpuid(CPUInfo, i);
        printf_s("\nFor InfoType %x\n", i); 
        printf_s("CPUInfo[0] = 0x%x\n", CPUInfo[0]);
        printf_s("CPUInfo[1] = 0x%x\n", CPUInfo[1]);
        printf_s("CPUInfo[2] = 0x%x\n", CPUInfo[2]);
        printf_s("CPUInfo[3] = 0x%x\n", CPUInfo[3]);

        // Interpret CPU brand string and cache information.
        if  (i == 0x80000002)
            memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
        else if  (i == 0x80000003)
            memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
        else if  (i == 0x80000004)
            memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
        else if  (i == 0x80000006)
        {
            nCacheLineSize = CPUInfo[2] & 0xff;
            nL2Associativity = (CPUInfo[2] >> 12) & 0xf;
            nCacheSizeK = (CPUInfo[2] >> 16) & 0xffff;
        }
    }

    // Display all the information in user-friendly format.

    printf_s("\n\nCPU String: %s\n", CPUString);

    if  (nIds >= 1)
    {
        if  (nSteppingID)
            printf_s("Stepping ID = %d\n", nSteppingID);
        if  (nModel)
            printf_s("Model = %d\n", nModel);
        if  (nFamily)
            printf_s("Family = %d\n", nFamily);
        if  (nProcessorType)
            printf_s("Processor Type = %d\n", nProcessorType);
        if  (nExtendedmodel)
            printf_s("Extended model = %d\n", nExtendedmodel);
        if  (nExtendedfamily)
            printf_s("Extended family = %d\n", nExtendedfamily);
        if  (nBrandIndex)
            printf_s("Brand Index = %d\n", nBrandIndex);
        if  (nCLFLUSHcachelinesize)
            printf_s("CLFLUSH cache line size = %d\n",
            nCLFLUSHcachelinesize);
        if  (nAPICPhysicalID)
            printf_s("APIC Physical ID = %d\n", nAPICPhysicalID);

        if  (nFeatureInfo || bSSE3NewInstructions ||
            bMONITOR_MWAIT || bCPLQualifiedDebugStore ||
            bThermalMonitor2)
        {
            printf_s("\nThe following features are supported:\n");

            if  (bSSE3NewInstructions)
                printf_s("\tSSE3 New Instructions\n");
            if  (bMONITOR_MWAIT)
                printf_s("\tMONITOR/MWAIT\n");
            if  (bCPLQualifiedDebugStore)
                printf_s("\tCPL Qualified Debug Store\n");
            if  (bThermalMonitor2)
                printf_s("\tThermal Monitor 2\n");

            i = 0;
            nIds = 1;
            while (i < (sizeof(szFeatures)/sizeof(const char*)))
            {
                if  (nFeatureInfo & nIds)
                {
                    printf_s("\t");
                    printf_s(szFeatures[i]);
                    printf_s("\n");
                }

                nIds <<= 1;
                ++i;
            }
        }
    }

    if  (nExIds >= 0x80000004)
        printf_s("\nCPU Brand String: %s\n", CPUBrandString);

    if  (nExIds >= 0x80000006)
    {
        printf_s("Cache Line Size = %d\n", nCacheLineSize);
        printf_s("L2 Associativity = %d\n", nL2Associativity);
        printf_s("Cache Size = %dK\n", nCacheSizeK);
    }

    return  nRet;
}


PM MAIL ICQ Jabber   Вверх
Kirk_Lee_Hammet
Дата 13.9.2006, 16:40 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 6
Регистрация: 8.9.2006

Репутация: нет
Всего: нет



Большое всем спасибки. smile  smile 
PM MAIL   Вверх
bel_nikita
Дата 13.9.2006, 22:57 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Эксперт
Сообщений: 2304
Регистрация: 12.10.2003
Где: Поезд №21/22 ( ст . Прага )

Репутация: 4
Всего: 47



Вот, метода для измерение реальной частоты в реальном времени:
Код
FLOAT MeasureClockSpeed()
{
    DWORD            ticks;              // Microseconds elapsed during test
    DWORD            cycles;             // Clock cycles elapsed during test
    DWORD            stamp0, stamp1;     // Time Stamp Variable for beginning and end of test                                            
  DWORD         freq = 0;
    DWORD         freq2 =0;           // 2nd most current frequ. calc.
    DWORD         freq3 =0;           // 3rd most current frequ. calc.
    DWORD         total;              // Sum of previous three frequency calculations
    int           tries=0;            // Number of times a calculation has been made on this call
    LARGE_INTEGER t0,t1;              // Variables for High-Resolution Performance Counter reads                    
    LARGE_INTEGER count_freq;           // High Resolution Performance Counter frequency

    // Checks whether the high-resolution counter exists and returns an error if it does not exist.
    if (!QueryPerformanceFrequency( &count_freq ) ) return 0.0f;
  
  // Get a copy of the current thread and process priorities
#if !defined (PHARLAP)
  DWORD priority_class     = GetPriorityClass(GetCurrentProcess());
#endif
  int  thread_priority    = GetThreadPriority(GetCurrentThread());

  // Make this thread the highest possible priority so we get the best timing
#if !defined (PHARLAP)
  SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
#endif
  SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);

    // Compare elapsed time on the High-Resolution Counter with elapsed cycles on the Time Stamp Register.
    do 
    {
    // This do loop runs up to 20 times or until the average of the previous  three calculated
        // frequencies is within 1 MHz of each of the individual calculated frequencies. 
        // This resampling increases the accuracy of the results since outside factors could affect
        // this calculation            

        tries++;        //Increment number of times sampled on this call to cpuspeed
        freq3 = freq2;  //Shift frequencies back to make
        freq2 = freq;   //room for new frequency measurement
    
    //Get high-resolution performance counter time
    QueryPerformanceCounter(&t0);
    t1.LowPart  = t0.LowPart;        // Set Initial time
    t1.HighPart = t0.HighPart;

        // Loop until 50 ticks have passed since last read of hi-res counter.
        // This accounts for overhead later.
    while ( (DWORD)t1.LowPart - (DWORD)t0.LowPart<50)
    {
      QueryPerformanceCounter(&t1);
    }
    
    _asm
    {
      rdtsc
        mov stamp0, EAX
    }

        t0.LowPart  = t1.LowPart;     // Reset Initial 
        t0.HighPart = t1.HighPart;        // Time
    
    // Loop until 1000 ticks have passed since last read of hi-res counter.
    // This allows for elapsed time for sampling.
    while ((DWORD)t1.LowPart-(DWORD)t0.LowPart<1000 )
    {
      QueryPerformanceCounter(&t1);
    }
    
    _asm
    {
      rdtsc
        mov        stamp1, EAX
    }
    
    cycles = stamp1 - stamp0;
    ticks = (DWORD) t1.LowPart - (DWORD) t0.LowPart;    

        // Note that some seemingly arbitrary mulitplies and divides are done below.
        // This is to maintain a high level of precision without truncating the most 
        // significant data. 

        ticks = ticks * 100000;                
        ticks = ticks / ( count_freq.LowPart/10 );        
        
        if ( ticks%count_freq.LowPart > count_freq.LowPart/2 )
        {
      ticks++;            // Round up if necessary
    }
        
        freq = cycles/ticks;    // Cycles / us  = MHz
                                         
    if ( cycles%ticks > ticks/2 )
    {
      freq++;                // Round up if necessary
        }
    
    total = ( freq + freq2 + freq3 );
  } while (    (tries < 3 ) || (tries < 20) && (( abs( (int)(3 * freq -total) ) > 3 ) ||
        (abs( (int)(3 * freq2-total) ) > 3) || (abs( (int)(3 * freq3-total) > 3) ) ));
        
    if ( total / 3  !=  ( total + 1 ) / 3 )
  {
        total ++;                // Round up if necessary
    }

    // restore the thread priority
#if !defined (PHARLAP)
    SetPriorityClass(GetCurrentProcess(), priority_class);
#endif
    SetThreadPriority(GetCurrentThread(), thread_priority);
  
  //return float(total) / 3.0f;
  return float(total) / 3.01f;
}



--------------------
user posted image — регистрация доменов от 150 руб.
PM MAIL WWW ICQ   Вверх
Android80
Дата 27.9.2006, 16:26 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 1
Регистрация: 27.9.2006

Репутация: нет
Всего: нет



To Damarus

а не подскажешь что еще нужно в этот код добавить, чтобы еще проверить наличие 3DNow и 3DNow Ext
PM MAIL   Вверх
Damarus
Дата 27.9.2006, 18:39 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Awaiting Authorisation
Сообщений: 671
Регистрация: 6.5.2006

Репутация: 4
Всего: 29



Цитата(Android80 @  27.9.2006,  17:26 Найти цитируемый пост)
а не подскажешь что еще нужно в этот код добавить, чтобы еще проверить наличие 3DNow и 3DNow Ext

Для 3DNow примерно так:
Код
int CPUInfo[4] = { -1 };
__cpuid(CPUInfo, 0x80000001);
if (CPUInfo[3] & 0x80000000)
    printf_s("3DNow! Extensions");

Для 3DNow Ext. примерно также, смотреть документацию по процессорам AMD.

PS. Это теоретически, т.к. проверить не на чем.
PM MAIL ICQ Jabber   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "C/C++: Системное программирование и WinAPI"
Fixin
GremlinProg
xvr
feodorv
  • Большое количество информации и примеров с использованием функций WinAPI можно найти в MSDN
  • Описание сообщений, уведомлений и примеров с использованием компонент WinAPI (BUTTON, EDIT, STATIC, и т.п.), можно найти в MSDN Control Library
  • Непосредственно, перед созданием новой темы, проверьте заголовок и удостоверьтесь, что он отражает суть обсуждения.
  • После заполнения поля "Название темы", обратите внимание на наличие и содержание панели "А здесь смотрели?", возможно Ваш вопрос уже был решен.
  • Приводите часть кода, в которой предположительно находится проблема или ошибка.
  • Если указываете код, пользуйтесь тегами [code][/code], или их кнопочными аналогами.
  • Если вопрос решен, воспользуйтесь соответствующей ссылкой, расположенной напротив названия темы.
  • Один топик - один вопрос!
  • Перед тем как создать тему - прочтите это .

На данный раздел распространяются Правила форума и Правила раздела С++:Общие вопросы .


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Chipset, Step, Fixin, GremlinProg, xvr. feodorv.

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | C/C++: Системное программирование и WinAPI | Следующая тема »


 




[ Время генерации скрипта: 0.0863 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.