string getDeviceInfo() { const CPUInfo cinfo = DeviceManager::getInstance().getCPUInfo(); ostringstream info; info << "ArrayFire v" << AF_VERSION << " (CPU, " << get_system() << ", build " << AF_REVISION << ")" << endl; string model = cinfo.model(); size_t memMB = getDeviceMemorySize(getActiveDeviceId()) / 1048576; info << string("[0] ") << cinfo.vendor() << ": " << ltrim(model); if (memMB) info << ", " << memMB << " MB, "; else info << ", Unknown MB, "; info << "Max threads(" << cinfo.threads() << ") "; #ifndef NDEBUG info << AF_COMPILER_STR; #endif info << endl; return info.str(); }
void devprop(char* d_name, char* d_platform, char* d_toolkit, char* d_compute) { const CPUInfo cinfo = DeviceManager::getInstance().getCPUInfo(); snprintf(d_name, 64, "%s", cinfo.vendor().c_str()); snprintf(d_platform, 10, "CPU"); // report the compiler for toolkit snprintf(d_toolkit, 64, "%s", AF_COMPILER_STR); snprintf(d_compute, 10, "%s", "0.0"); }
CString GetCPUName() { CString Response; CPUInfo cpu; if (cpu.DoesCPUSupportCPUID()) { Response = cpu.GetExtendedProcessorName(); } if(Response.GetLength() == 0) { Response = "Not Detected"; } Response.TrimLeft(); Response.TrimRight(); return "\nProcessor:\n" + Response + "\n"; }
void DumpSystemToLog() { CPUInfo cpu; WCHAR wszTime[9], wszDate[9]; _wstrtime_s(wszTime, 9); _wstrdate_s(wszDate, 9); LOG_INFO(" -- System To Log --"); #if defined(DEBUG) || defined(_DEBUG) LOG_INFO("RUNNING -DEBUG- BUILD AT: " << wszDate << " -- " << wszTime ); #else LOG_INFO("RUNNING -RELEASE- BUILD AT: " << wszDate << " -- " << wszTime ); #endif LOG_INFO(""); LOG_INFO(DXUTGetWindowTitle()); LOG_INFO("Processor Speed: " << cpu.GetProcessorClockFrequency() << "MHz"); LOG_INFO("Processors: " << cpu.GetLogicalProcessorsPerPhysical()); LOG_INFO("Processor: " << cpu.GetExtendedProcessorName()); LOG_INFO(DXUTGetFrameStats(false)); LOG_INFO(DXUTGetDeviceStats()); LOG_INFO(""); dprintf("Processor Speed: %dMHz\n", cpu.GetProcessorClockFrequency()); dprintf("Processors: %d\n", cpu.GetLogicalProcessorsPerPhysical()); dprintf("Processor: %s\n", cpu.GetExtendedProcessorName()); char pszDest[256]; WCharStringToCharString(DXUTGetFrameStats(false), pszDest, 255); dprintf("STATS:\n%s\n", pszDest); WCharStringToCharString(DXUTGetDeviceStats(), pszDest, 255); dprintf("%s\n", pszDest); dprintf("\n\n"); }
static void get_cpu_cores( char* dest ) { sprintf( dest, "%d\n", cpu_info.GetLogicalProcessorsPerPhysical() ); }
static void get_cpu_freq( char* dest ) { sprintf( dest, "%dMHz\n", cpu_info.GetProcessorClockFrequency() ); }
static void get_cpu_name( char* dest ) { sprintf( dest, "%s (stepping %s)\n", cpu_info.GetVendorString(), cpu_info.GetSteppingCode() ); }
DWORD WINAPI GetProcessorInformation (LPVOID lpParameter) { PPROCESSORINFO pProcessorInfo = (PPROCESSORINFO) lpParameter; CPUInfo * CPU = new CPUInfo (); if (!CPU->DoesCPUSupportCPUID ()) { delete CPU; return 0; } //the processor serial number. if (CPU->DoesCPUSupportFeature (SERIALNUMBER_FEATURE)) { sprintf_s(pProcessorInfo->szSerialNumber, CPU->GetProcessorSerialNumber()); } // Add the hardware specification node. // State the APIC ID if one is present. if (CPU->DoesCPUSupportFeature (APIC_FEATURE)) { pProcessorInfo->bAPICPresent = true; // Attempt to display the ID of the APIC. pProcessorInfo->APICID = CPU->GetProcessorAPICID (); } // State if the processor supports the Advanced Configuration and Power Interface [ACPI]. if (CPU->DoesCPUSupportFeature (ACPI_FEATURE)) { pProcessorInfo->bACPICapable = true; } // State if the processor supports a thermal monitor. if (CPU->DoesCPUSupportFeature (THERMALMONITOR_FEATURE)) { pProcessorInfo->bOnChipThermalMonitor = true; } if (CPU->DoesCPUSupportFeature (L1CACHE_FEATURE)) { pProcessorInfo->bL1Cache = true; pProcessorInfo->L1CacheSize = CPU->GetProcessorCacheXSize (L1CACHE_FEATURE); } // State the size of the L2 cache if present. if (CPU->DoesCPUSupportFeature (L2CACHE_FEATURE)) { pProcessorInfo->bL2Cache = true; pProcessorInfo->L2CacheSize = CPU->GetProcessorCacheXSize (L2CACHE_FEATURE); } // State the size of the L3 cache if present. if (CPU->DoesCPUSupportFeature (L3CACHE_FEATURE)) { pProcessorInfo->bL3Cache = true; pProcessorInfo->L3CacheSize = CPU->GetProcessorCacheXSize (L3CACHE_FEATURE); } // State if a temperature sensing diode is present. if (CPU->DoesCPUSupportFeature (TEMPSENSEDIODE_FEATURE)) { pProcessorInfo->bTemperatureSensingDiode = true; } // State if a frequency ID control is present. if (CPU->DoesCPUSupportFeature (FREQUENCYID_FEATURE)) { pProcessorInfo->bFrequencyIDControl = true; } // State if a voltage ID control is present. if (CPU->DoesCPUSupportFeature (VOLTAGEID_FREQUENCY)) { pProcessorInfo->bVoltageIDControl = true; } //Supported Features // State if CMOV instructions are present. if (CPU->DoesCPUSupportFeature (CMOV_FEATURE)) { pProcessorInfo->bCMOVInstructions = true; } // State if MTRR instructions are present. if (CPU->DoesCPUSupportFeature (MTRR_FEATURE)) { pProcessorInfo->bMTRRInstructions = true; } // State if MMX instructions are present. if (CPU->DoesCPUSupportFeature (MMX_FEATURE)) { pProcessorInfo->bMMXInstructions = true; } // State if MMX+ instructions are present. if (CPU->DoesCPUSupportFeature (MMX_PLUS_FEATURE)) { pProcessorInfo->bMMXPlusInstructions = true; } // State if SSE instructions are present. if (CPU->DoesCPUSupportFeature (SSE_FEATURE)) { pProcessorInfo->bSSEInstructions = true; } // State if SSE FP instructions are present. if (CPU->DoesCPUSupportFeature (SSE_FP_FEATURE)) { pProcessorInfo->bSSEFPInstructions = true; } // State if SSE MMX instructions are present. if (CPU->DoesCPUSupportFeature (SSE_MMX_FEATURE)) { pProcessorInfo->bMMXInstructions = true; } // State if SSE2 instructions are present. if (CPU->DoesCPUSupportFeature (SSE2_FEATURE)) { pProcessorInfo->bSSE2Instructions = true; } // State if 3DNow! instructions are present. if (CPU->DoesCPUSupportFeature (AMD_3DNOW_FEATURE)) { pProcessorInfo->bAMD3DNowInstructions = true; } // State if 3DNow!+ instructions are present. if (CPU->DoesCPUSupportFeature (AMD_3DNOW_PLUS_FEATURE)) { pProcessorInfo->bAMD3DNowPlusInstructions = true; } // State if Hyperthreading instructions are present. if (CPU->DoesCPUSupportFeature (HYPERTHREAD_FEATURE)) { pProcessorInfo->bHyperthreadingInstructions = true; pProcessorInfo->LogicalProcessorsPerPhysical = CPU->GetLogicalProcessorsPerPhysical (); } // State if the processor is MP capable. if (CPU->DoesCPUSupportFeature (MP_CAPABLE)) { pProcessorInfo->bMultiprocessorCapable = true; } // State if IA64 instructions are present. if (CPU->DoesCPUSupportFeature (IA64_FEATURE)) { pProcessorInfo->bIA64Instructions = true; } delete CPU; return 0; }
void printCPUInfo(int processor, const CPUInfo& info) { printf("Processor %d:\n", processor); if (!info.supportsCPUID) { printf(" No CPUID Support\n"); printf("\n"); return; } printf(" Vendor: %s\n", info.getVendorName()); printf(" Name: %s\n", info.getProcessorName().c_str()); printf(" Type: %s\n", info.getProcessorTypeName()); printf(" Brand: %s\n", info.getProcessorBrandName().c_str()); printf(" Classical Name: %s\n", info.getClassicalProcessorName()); printf("\n"); printf(" Family: %d\n", info.identity.family); printf(" Model: %d\n", info.identity.model); printf(" Stepping: %d\n", info.identity.stepping); printf("\n"); printf(" Frequency: %d MHz\n", info.frequency); printf("\n"); printf(" Features:\n"); bool featureflag = false; #define F(flag, desc) \ if (info.features.flag) { \ featureflag = true; \ printf(" %8s: %s\n", #flag, desc); \ } F(fpu, "Floating Point Unit"); F(vme, "Virtual-8086 Mode Enhancement"); F(de, "Debugging Extensions"); F(pse, "Page Size Extensions"); F(tsc, "Time Stamp Counter"); F(msr, "RDMSR and WRMSR Support"); F(pae, "Physical Address Extensions"); F(mce, "Machine Check Exception"); F(cx8, "CMPXCHG8B Instruction"); F(apic, "APIC on Chip"); F(sep, "SYSENTER and SYSEXIT"); F(mtrr, "Memory Type Range Registers"); F(pge, "PTE Global Bit"); F(mca, "Machine Check Architecture"); F(cmov, "Conditional Move/Compare Instructions"); F(pat, "Page Attribute Table"); F(pse36, "Page Size Extension"); F(serial, "Serial Number Available"); F(clfsh, "CLFLUSH Instruction"); F(ds, "Debug Store"); F(acpi, "Thermal Monitor and Clock Control"); F(mmx, "MMX Technology"); F(fxsr, "FXSAVE/FXRSTOR Instructions"); F(sse, "SSE Extensions"); F(ssefp, "SSE Floating Point"); F(sse2, "SSE2 Extensions"); F(ss, "Self Snoop"); F(htt, "Hyper-Threading Technology"); F(thermal, "Thermal Monitor"); F(ia64, "IA64 Instructions"); F(pbe, "Pending Break Enable"); F(sse3, "SSE3 Extensions"); F(monitor, "MONITOR/MWAIT"); F(ds_cpl, "CPL Qualified Debug Store"); F(est, "Enhanced Intel SpeedStep Technology"); F(tm2, "Thermal Monitor 2"); F(cnxt_id, "L1 Context ID"); F(_3dnow, "3DNow! Instructions"); F(_3dnowPlus, "3DNow! Instructions Extensions"); F(ssemmx, "SSE MMX"); F(mmxPlus, "MMX+"); F(supportsMP, "Supports Multiprocessing"); #undef F if (!featureflag) { printf(" None\n"); } printf("\n"); if (info.features.serial) { printf(" Serial Number: %s\n", info.features.serialNumber); } if (info.features.htt) { printf(" Logical Processors per Physical: %d\n", info.features.logicalProcessorsPerPhysical); } if (info.features.clfsh) { printf(" CLFLUSH Cache Line Size: %d bytes\n", info.features.CLFLUSHCacheLineSize); } if (info.features.apic) { printf(" APIC ID: %d\n", info.features.APIC_ID); } printf("\n"); printf(" Cache:\n"); if (info.cache.L1CacheSize != -1) { printf(" L1 Size: %d kB\n", info.cache.L1CacheSize); } if (info.cache.L2CacheSize != -1) { printf(" L2 Size: %d kB\n", info.cache.L2CacheSize); } if (info.cache.L3CacheSize != -1) { printf(" L3 Size: %d kB\n", info.cache.L3CacheSize); } printf("\n"); printf(" Enhanced Power Management:\n"); bool pmflag = false; #define PM(flag, desc) \ if (info.powerManagement.flag) { \ pmflag = true; \ printf(" %8s: %s\n", #flag, desc); \ } PM(ts, "Temperature Sensor"); PM(fid, "Frequency ID"); PM(vid, "Voltage ID"); PM(ttp, "Thermal Trip"); PM(tm, "Thermal Monitoring"); PM(stc, "Software Thermal Control"); #undef PM if (!pmflag) { printf(" None\n"); } printf("\n\n"); }
CString CTranCmn::fnAPP_GetAtmSysInfo(int nSystmInfo) { CString cstrGetSytemInfo(""); //cpu정보 if(nSystmInfo == 1) //클럭수 얻기 { CPUInfo * CPU = new CPUInfo (); TCHAR szCPU[60] = {0}; memcpy(szCPU, CPU->GetExtendedProcessorName (), strlen(CPU->GetExtendedProcessorName ())); delete CPU; cstrGetSytemInfo.Format("%s",szCPU); } else //memory 크기 if(nSystmInfo == 2) { MEMORYSTATUS ms; TCHAR szMemSize[20] = {0}; ms.dwLength = sizeof(MEMORYSTATUS); ::GlobalMemoryStatus(&ms); DWORD dwPhysicalMemory; dwPhysicalMemory=ms.dwTotalPhys; wsprintf(szMemSize, "%012d", (int)(dwPhysicalMemory / (1024))); cstrGetSytemInfo.Format("%s",szMemSize); } else //cpu and memory 사용율 if(nSystmInfo == 3) { TCHAR szCpuUsage[16] = {0}; TCHAR szMemUsage[16] = {0}; UINT nCpuUsage = 0; UINT nMemUsage = 0; resMonitor.Initialize(); resMonitor.GetResourceInfo(nCpuUsage, nMemUsage); //한 번만 했을 경우는 cpu가 99% 이므로 Sleep(100); resMonitor.GetResourceInfo(nCpuUsage, nMemUsage); //두번째 값을 취한다. if(nCpuUsage < 1) nCpuUsage = 1; wsprintf(szCpuUsage, " %d%%", nCpuUsage); wsprintf(szMemUsage, " %d%%", nMemUsage); cstrGetSytemInfo.Format("CPU%s - MEM%s Rate", szCpuUsage, szMemUsage); MsgDump(TRACE_CODE_MODE, "Log", __FILE__, __LINE__, "fnAPP_GetAtmSysInfo (%s)", cstrGetSytemInfo); } else if(nSystmInfo == 4) { TCHAR szCpuUsage[16] = {0}; TCHAR szMemUsage[16] = {0}; UINT nCpuUsage = 0; UINT nMemUsage = 0; resMonitor.Initialize(); resMonitor.GetResourceInfo(nCpuUsage, nMemUsage); //한 번만 했을 경우는 cpu가 99% 이므로 Sleep(100); resMonitor.GetResourceInfo(nCpuUsage, nMemUsage); //두번째 값을 취한다. if(nCpuUsage < 1) nCpuUsage = 1; wsprintf(szCpuUsage, " %d%%", nCpuUsage); wsprintf(szMemUsage, " %d%%", nMemUsage); cstrGetSytemInfo.Format("CPU%s - MEM%s Rate", szCpuUsage, szMemUsage); MsgDump(TRACE_CODE_MODE, "Log", __FILE__, __LINE__, "fnAPP_GetAtmSysInfo (%s)", cstrGetSytemInfo); } else //os 정보 if(nSystmInfo == 5) { TCHAR szOS[64] = {0}; OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); ::GetVersionEx(&osvi); switch(osvi.dwPlatformId){ case VER_PLATFORM_WIN32s: strcpy(szOS, "Windows 3.1 "); cstrGetSytemInfo.Format("%s",szOS); break; case VER_PLATFORM_WIN32_WINDOWS: if(osvi.dwMinorVersion == 0) { strcpy(szOS, "Windows 95 "); cstrGetSytemInfo.Format("%s",szOS); }else if(osvi.dwMinorVersion == 10) { strcpy(szOS, "Windows 98 "); cstrGetSytemInfo.Format("%s",szOS); }else if(osvi.dwMinorVersion == 90) { strcpy(szOS, "Windows me "); cstrGetSytemInfo.Format("%s",szOS); }else { strcpy(szOS, "Unknown System "); cstrGetSytemInfo.Format("%s",szOS); } break; case VER_PLATFORM_WIN32_NT: switch(osvi.dwMajorVersion){ case 3: strcpy(szOS, "Windows NT 3.51 "); cstrGetSytemInfo.Format("%s",szOS); break; case 4: strcpy(szOS, "Windows NT 4.0 "); cstrGetSytemInfo.Format("%s",szOS); break; case 5: switch(osvi.dwMinorVersion ){ case 0: strcpy(szOS, "Windows 2000 "); cstrGetSytemInfo.Format("%s",szOS); break; case 1: strcpy(szOS, "Windows xp "); cstrGetSytemInfo.Format("%s",szOS); break; default: strcpy(szOS, "Unknown System "); cstrGetSytemInfo.Format("%s",szOS); break; } break; default: strcpy(szOS, "Unknown System "); cstrGetSytemInfo.Format("%s",szOS); break; } break; default: strcpy(szOS, "Unknown System "); cstrGetSytemInfo.Format("%s",szOS); break; } } else if(nSystmInfo == 6) { BOOL bResult; //GetDiskFreeSpaceEx는 98이상의 디스크 정보를 가지고 오기 위한 함수 P_GDFSE pGetDiskFreeSpaceEx = NULL; //pGetDiskFreeSpaceEx의 매개변수 unsigned __int64 i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes; //kernel32.dll에서 어떤 파일 시스템인가를 확인한다. //여기서 True or FALSe를 반환한다. pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (GetModuleHandle ("kernel32.dll"), "GetDiskFreeSpaceExA"); TCHAR szHDD[40] = {0}; TCHAR szHDD1[40] = {0}; //95이상의 파일 시스템 일경우 if (pGetDiskFreeSpaceEx) { //HDD 디스크 사이즈 "C:\" bResult = pGetDiskFreeSpaceEx ("C:\\", (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes); if (bResult) { //HDD 디스크 사이즈 "C:\" wsprintf(szHDD, TEXT("%010d"), i64TotalBytes/(1024)); wsprintf(szHDD1, TEXT("%010d"), i64FreeBytes/(1024)); cstrGetSytemInfo.Format("%s%s",szHDD,szHDD1); } } } else if(nSystmInfo == 7) { BOOL bResult; //GetDiskFreeSpaceEx는 98이상의 디스크 정보를 가지고 오기 위한 함수 P_GDFSE pGetDiskFreeSpaceEx = NULL; //pGetDiskFreeSpaceEx의 매개변수 unsigned __int64 i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes; //kernel32.dll에서 어떤 파일 시스템인가를 확인한다. //여기서 True or FALSe를 반환한다. pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (GetModuleHandle ("kernel32.dll"), "GetDiskFreeSpaceExA"); TCHAR szHDD[40] = {0}; TCHAR szHDD1[40] = {0}; //95이상의 파일 시스템 일경우 if (pGetDiskFreeSpaceEx) { //HDD 디스크 사이즈 "C:\" bResult = pGetDiskFreeSpaceEx ("D:\\", (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes); if (bResult) { //HDD 디스크 사이즈 "C:\" wsprintf(szHDD, TEXT("%010d"), i64TotalBytes/(1024)); wsprintf(szHDD1, TEXT("%010d"), i64FreeBytes/(1024)); cstrGetSytemInfo.Format("%s%s",szHDD,szHDD1); } } } else //FLOPPY 정보//CD-ROM 정보 if(nSystmInfo == 8) { char strtmp[3]; CString strDrive; int realDrive = 0; memset(strtmp, 0x30, sizeof(strtmp)); for (int nDrive = 0 ; nDrive < 26 ; nDrive++) { if (::GetLogicalDrives() & (1 << nDrive)) { UINT nType; strDrive.Format("%c:\\", nDrive + 'A'); nType = ::GetDriveType(strDrive); if(nType == DRIVE_REMOVABLE) { //플로피 디스크 있음 strtmp[0] = 0x31; }else if(nType == DRIVE_CDROM) { //CD-ROM 있음 strtmp[1] = 0x31; } } } strtmp[2] = 0x00; cstrGetSytemInfo.Format("%s",strtmp); } else//IE 버전정보 얻어오기 if(nSystmInfo == 9) { HKEY hTemp = NULL; DWORD dwType; DWORD dwBytes = 16; long lRet = 0; unsigned char szIEBuf[16]; memset(szIEBuf, 0x00, sizeof(szIEBuf)); TCHAR szSubKey[] = _T("Software\\Microsoft\\Internet Explorer"); RegOpenKeyEx(HKEY_LOCAL_MACHINE, szSubKey, 0, KEY_READ, &hTemp); if(hTemp != NULL) { lRet = RegQueryValueEx(hTemp, _T("Version"), 0, &dwType, szIEBuf, &dwBytes); RegCloseKey(hTemp); } if(lRet == ERROR_SUCCESS) cstrGetSytemInfo.Format("IE%s",szIEBuf); else cstrGetSytemInfo.Format("%s","UNKNOWN"); } return cstrGetSytemInfo; }