title: What is the best way to determine the number of threads to fire off in a machine with n cores? (C++)
body: <p>I have a <code>vector&lt;int&gt;</code> with 10,000,000 (10 million) elements, and that my workstation has four cores.  There is a function, called <code>ThrFunc</code>, that operates on an integer.  Assume that the runtime for <code>ThrFunc</code> for each integer in the <code>vector&lt;int&gt;</code> is roughly the same.</p>
  
  <p>How should I determine the optimal number of threads to fire off?  Is the answer as simple as the number of elements divided by the number of cores?  Or is there a more subtle computation?</p>
  
  <p><strong>Editing to provide extra information</strong></p>
  
  <ul>
  <li>No need for blocking; each function invocation needs only read-only
  access</li>
  </ul>