일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
- 인스피론
- 환경변수
- 여객선
- inspiron 15 7590
- 사용자매크로
- Jetson Nano
- 가벼워
- SetThreadAffinityMask
- Thread
- VisualStudio
- MFC
- 영상처리
- Today
- Total
MuTa
시스템 현재 코어 개수 구하기 본문
//코어 갯수 구하기
#include <Windows.h>
#include <process.h>
int GetNumberOfCores()
{
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pProcessorInformations = NULL;
DWORD length = 0;
BOOL result = GetLogicalProcessorInformation(pProcessorInformations, &length);
if (!result)
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
pProcessorInformations = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)new BYTE[length];
}
}
result = GetLogicalProcessorInformation(pProcessorInformations, &length);
if (!result)
{
// error
return -1;
}
int numOfCores = 0;
for (int i = 0; i < length / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); i++)
{
if (pProcessorInformations[i].Relationship == RelationProcessorCore)
numOfCores++;
}
delete[] pProcessorInformations;
return numOfCores;
}
//
'MFC-C++' 카테고리의 다른 글
대용량 메모리 할당 Massive Memory Alloc (0) | 2016.05.27 |
---|---|
C++ 11 핵심 (0) | 2016.05.16 |
폴더내 파일 리스트 가져오기 (0) | 2016.05.13 |
Visual C++ Tips & Tricks (0) | 2016.05.13 |
3차원 vector c++11 (0) | 2016.05.11 |