General Category > General Discussion about just::thread

thread::hardware_concurrency static Member Function

(1/2) > >>

Kenneth Carter:
based on the documentation you mentioned that this should return the number of processors.

so I was expecting it to return '2'. I was surprised to recieve the number '2036182'.

which leads to the question of how that number was picked and why?

Kenneth

Anthony Williams:

--- Quote from: Kenneth Carter on November 19, 2008, 09:39:58 PM ---based on the documentation you mentioned that this should return the number of processors.

so I was expecting it to return '2'. I was surprised to recieve the number '2036182'.

which leads to the question of how that number was picked and why?

--- End quote ---

Wow, you've got a lot of processors in your system ;-)

This function uses the
--- Code: ---GetSystemInfo
--- End code ---
Windows API call, which supposedly cannot fail. On my dual-core machines it returns "2". What system are you running on?

Kenneth Carter:
amd x2 processor with 4 GB of memory running on vista ultimate x64

the below code I have found is far more accurate on my system. it uses the GetNativeSystemInfo found in the kernel32.dll  and returns 2 for the dwNumberOfProcessors everytime. to be honest based on the code below I have never ran GetSystemInfo on my computer because GetNativeSystemInfo has been successfull every time I have ran this code.


typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);



ZeroMemory( &SysInfo, sizeof( SYSTEM_INFO ) );
           
PGNSI pGNSI;
           
pGNSI = (PGNSI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
           
if( pGNSI != NULL )
{
     pGNSI( &SysInfo );
} else GetSystemInfo( &SysInfo );

Anthony Williams:

--- Quote from: Kenneth Carter on November 19, 2008, 10:44:34 PM ---amd x2 processor with 4 GB of memory running on vista ultimate x64

the below code I have found is far more accurate on my system. it uses the GetNativeSystemInfo found in the kernel32.dll  and returns 2 for the dwNumberOfProcessors everytime. to be honest based on the code below I have never ran GetSystemInfo on my computer because GetNativeSystemInfo has been successfull every time I have ran this code.

--- End quote ---

Aha. GetSystemInfo is documented to return incorrect information under WOW64, which you get with a 32-bit app on a 64-bit OS.

I bet that's the problem with the deadlock check stack tracing too --- WOW64 is messing up the stack tracer. I'll see what I can do.

Thanks.

Kenneth Carter:
Anthony,

I just installed .4 beta and this situation has not been resolved yet. I would suggest the GetNativeSystemInfo function found in the kernel32.dll. when I use this in place of hardware_concurrency I am getting accurate count of processor cores.

Kenneth

Navigation

[0] Message Index

[#] Next page

Go to full version