I'm working on an application that does some heavy number crunching. It is intended to run on a single computer. Recently, we've started looking at multithreading to speed up the calculations. Some of the algorithms can be made to run parallel without much effort, and I use a fixed thread pool to run each of the sub tasks.
What I was wondering is: how is the number of threads (the size of the pool), typically specified for these kinds of algorithms? I suspect this is typically done by using either a configuration file, or a commandline parameter, but I haven't seen any examples like that, so I was wondering if there are better ways.
Related to this: Is it even relevant to specify the number of threads? I was thinking that setting the pool size to the number of assignable cores will likely run the fastest, but is the thread-contention for processing power in the case of over assignment even relevant for performance? Eg: will setting 20 max threads on a 4 core machine be worse than setting 4 max threads?
Edit: the application is intended for sale, so I have no idea what computers it will be run on. I'm looking for general guidelines, and best practices.