What is meant by a hardware thread. Is it always double the number of processor cores available? How to determine the number of hardware threads in an Intel Core2 Duo processor? Can it be determined through Java code?
What is meant by a hardware thread.
You tell us. It's not really an established term.
Is it always double the number of processor cores available?
Ah, now it seems like you're talking about hyperthreading where partial redundancies within a CPU core are used to "fake" an additional core.
How to determine the number of hardware threads in an Intel Core2 Duo processor? Can it be determined through Java code?
You could try to find something in the system properties, but it's not going to be standard (i.e. depends on the JVM and OS).
Personally, I'd just use a sensible default (4 or 8 threads - having a few too many is perferable to not using available cores) and make it configurable.
It's definately not the case that the number of hardware threads is twice the number of cores -- AMD processors don't have any sort of hyperthreading ( yet ), and hyperthreading may be turned off in the BIOS (as is usually was for pre-nehalem processors, as it really didn't buy you very much in practice). There's also no reason why it would necessarily have to only be two hardware threads per core -- Power7 systems have 4 per core.
There's no OS- or hardware-independant way to do these checks. The only library I know that fairly portably can query this information is the hardware locality (hwloc) library . It's a C library, so should be pretty simple to call from Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With