Click here to Skip to main content
15,908,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SHFileOperation and Vista64 Pin
khb28-Jun-09 22:38
khb28-Jun-09 22:38 
GeneralRe: SHFileOperation and Vista64 Pin
«_Superman_»28-Jun-09 22:39
professional«_Superman_»28-Jun-09 22:39 
GeneralRe: SHFileOperation and Vista64 Pin
khb28-Jun-09 22:48
khb28-Jun-09 22:48 
GeneralRe: SHFileOperation and Vista64 Pin
«_Superman_»28-Jun-09 22:51
professional«_Superman_»28-Jun-09 22:51 
GeneralRe: SHFileOperation and Vista64 Pin
khb28-Jun-09 23:06
khb28-Jun-09 23:06 
GeneralRe: SHFileOperation and Vista64 Pin
Randor 29-Jun-09 5:03
professional Randor 29-Jun-09 5:03 
GeneralRe: SHFileOperation and Vista64 Pin
khb29-Jun-09 5:14
khb29-Jun-09 5:14 
QuestionHow to remove the carriage return to newline conversion in C. Pin
Razanust28-Jun-09 20:05
Razanust28-Jun-09 20:05 
AnswerRe: How to remove the carriage return to newline conversion in C. Pin
khb28-Jun-09 22:08
khb28-Jun-09 22:08 
AnswerRe: How to remove the carriage return to newline conversion in C. Pin
Rajesh R Subramanian28-Jun-09 22:14
professionalRajesh R Subramanian28-Jun-09 22:14 
QuestionHow to find Number of processor or Cores ? Pin
ERLN28-Jun-09 20:04
ERLN28-Jun-09 20:04 
AnswerRe: How to find Number of processor or Cores ? Pin
«_Superman_»28-Jun-09 22:17
professional«_Superman_»28-Jun-09 22:17 
GeneralRe: How to find Number of processor or Cores ? Pin
ERLN28-Jun-09 23:26
ERLN28-Jun-09 23:26 
GeneralRe: How to find Number of processor or Cores ? Pin
«_Superman_»28-Jun-09 23:32
professional«_Superman_»28-Jun-09 23:32 
QuestionRe: How to find Number of processor or Cores ? Pin
ERLN28-Jun-09 23:42
ERLN28-Jun-09 23:42 
AnswerRe: How to find Number of processor or Cores ? Pin
«_Superman_»28-Jun-09 23:44
professional«_Superman_»28-Jun-09 23:44 
GeneralRe: How to find Number of processor or Cores ? Pin
ERLN29-Jun-09 0:00
ERLN29-Jun-09 0:00 
GeneralRe: How to find Number of processor or Cores ? Pin
Stuart Dootson29-Jun-09 0:05
professionalStuart Dootson29-Jun-09 0:05 
GeneralRe: How to find Number of processor or Cores ? Pin
«_Superman_»29-Jun-09 0:06
professional«_Superman_»29-Jun-09 0:06 
AnswerRe: How to find Number of processor or Cores ? Pin
Stuart Dootson29-Jun-09 0:01
professionalStuart Dootson29-Jun-09 0:01 
GeneralRe: How to find Number of processor or Cores ? Pin
ERLN29-Jun-09 0:35
ERLN29-Jun-09 0:35 
GeneralRe: How to find Number of processor or Cores ? Pin
Stuart Dootson29-Jun-09 0:42
professionalStuart Dootson29-Jun-09 0:42 
AnswerRe: How to find Number of processor or Cores ? Pin
Randor 29-Jun-09 4:11
professional Randor 29-Jun-09 4:11 
You can use the cpuid assembly instruction to get this information, it will require some assembly knowledge. I wrote the following functions a few years ago, you may want to check that they return the correct values.

__inline BOOL IsHyperThreaded()
{
	BOOL bHyperthread = 0;
	__asm
	{
		xor	eax, eax
		cpuid
		cmp	eax, 1
		jb end
		xor eax, eax
		inc eax
		cpuid
		test edx, 0x10000000
		jz end
		mov	dword ptr [bHyperthread], 1
	end:
	}
	return bHyperthread;
}

__inline unsigned int PhysicalCores()
{
unsigned int cores = 1;

__asm
{
	xor	eax, eax
	cpuid
	cmp	eax, 4
	jb	end
	mov	eax, 4
	xor	ecx, ecx
	cpuid
	shr	eax, 26
	and	eax, 0x1F
	add	eax, 1
	mov	dword ptr [cores], eax
end:
}
return cores;
}

__inline unsigned int CpuCores()
{
unsigned int cores = 0;
__asm
{
	xor eax, eax
	cpuid
	cmp eax, 4
	jl single
	mov eax, 4
	xor ecx, ecx
	cpuid
	mov cores, eax
	jmp multi
single:
	xor eax, eax
multi:
}
return (unsigned int)((cores & 0xFC000000) >> 26)+1;
}

__inline unsigned int LogicalCores()
{
unsigned int cores = 1;
__asm
{
	xor	eax, eax
	cpuid
	cmp	eax, 1
	jb	end
	xor eax, eax
	inc eax
	cpuid
	test edx, 0x10000000
	jz end
	mov eax, ebx
	and eax, 0x00FF0000
	shr eax, 16
	mov cores, eax
end:
}
return cores;
}


My code will not work on the MSVC 64 bit compiler, if you are creating a 64 bit application then you will need to use the CPUID intrinsics[^]

Best Wishes,
-David Delaune
Questionneed help of c code of imresize matlab function Pin
ashish_2418828-Jun-09 19:42
ashish_2418828-Jun-09 19:42 
AnswerRe: need help of c code of imresize matlab function Pin
chandu00428-Jun-09 20:38
chandu00428-Jun-09 20:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.