Example #1
0
int32
Filter::NumberOfThreads()
{
	const int32 units = GetNumberOfUnits();
	int32 n;
	n = units / 32; // at least 32 units per CPU
	if (n > CPUCount()) {
		n = CPUCount();
	} else if (n <= 0) {
		n = 1; // at least one thread!
	}
	return n;
}
unsigned int GetLogicalProcssingUnitCount(void)
{

   unsigned int  TotAvailLogical   = 0,  // Number of available logical CPU per CORE
				 TotAvailCore  = 0,      // Number of available cores per physical processor
                 PhysicalNum   = 0;      // Total number of physical processors

   unsigned char StatusFlag = 0; 
/* Not sure what this does - ignore
   if (CpuIDSupported() < 4) { // CPUID does not report leaf 4 information
	   printf("\nUser Warning:\n CPUID Leaf 4 is not supported or disabled. Please check  \
			 \n BIOS and correct system configuration error if leaf 4 is disabled. \n");
   }
*/	
StatusFlag = CPUCount(&TotAvailLogical, &TotAvailCore, &PhysicalNum);
if( USER_CONFIG_ISSUE == StatusFlag) {
	printf("User Configuration Error: Not all logical processors in the system are enabled \
	while running this process.\n");
	return 1;
}