title: C++ super fast thread-safe rand function
body: <pre><code>void NetClass::Modulate(vector &lt;synapse&gt; &amp; synapses )
  {
      int size = synapses.size();
      int split = 200 * 0.5;
  
      for(int w=0; w &lt; size; w++)
          if(synapses[w].active)
              synapses[w].rmod = ((rand_r(seedp) % 200 - split ) / 1000.0);
  }
  </code></pre>
  
  <p>The function <code>rand_r(seedp)</code> is seriously bottle-necking my program. Specifically, its slowing me by 3X when run serialy, and 4.4X when run on 16 cores. <code>rand()</code> is not an option because its even worse. Is there anything I can do to streamline this? If it will make a difference, I think I can sustain a loss in terms of statistical randomness. Would pre-generating (before execution) a list of random numbers and then loading to the thread stacks be an option? </p>