Why is there a difference using std::thread::hardware_concurrency() and boost::thread::hardware_concurrency()? Why is there a difference using std::thread::hardware_concurrency() and boost::thread::hardware_concurrency()? multithreading multithreading

Why is there a difference using std::thread::hardware_concurrency() and boost::thread::hardware_concurrency()?


After reviewing /usr/include/c++/4.6.2/thread

it can be seen that the implementation is actually:

// Returns a value that hints at the number of hardware thread contexts.static unsigned inthardware_concurrency(){ return 0; }

So problem solved. It's just another feature that hasn't been implemented in gcc 4.6.2


The method employed by your compiler installation of boost is supported for your target, whereas your installation of boost compiler does not support this feature for your target.

TFM says:

The number of hardware threads available on the current system (e.g. number of CPUs or cores or hyperthreading units), or 0 if this information is not available.

EDIT: scratch that, reverse it.

EDIT2: This feature is present on the trunk, but absent in 4.6.2:

~/tmp/gcc-4.6.2/libstdc++-v3/src> wc -l thread.cc104 thread.cc~/tmp/gcc-4.6.2/libstdc++-v3/src> grep concurrency thread.cc | wc -l0~/tmp/gcc-4.6.2/libstdc++-v3> grep -C 2 VERIFY testsuite/30_threads/thread/members/hardware_concurrency.cc  // Current implementation punts on this.  VERIFY( std::thread::hardware_concurrency() == 0 );  return 0;