I'm implementing a program that normalizes a big dataset(single file), it's math-intensive calculation and therefore is CPU-bounded.
Having lookup some of the optimal threads questions, most leads to this:
Runtime.getRuntime().availableProcessors()
But with HT technology, a single core can handle two threads concurrently.
Some of the previous answers also state that the optimal threads = number of cores, I'm not sure if it's correct for CPU-bounded tasks.
Knowing each OS might perform parallel programming differently, should I be solely using availableProcessors() without having to consider elements like:
- Thread(s) per core
- core(s) per socket
- CPU socket(s)
For example, should I be using availableProcessors() * Thread(s) per core to get the optimal threads? Does it create thread competition?
I'm looking for the recommended practice achieve this, without having to modify and rebuild the program when the program moves to the other machine.(the program is only tested on a local machine)
Thanks in advance.