<p>In <a href="https://github.com/mlpack/mlpack/pull/603#discussion_r58859113">src/mlpack/core/optimizers/parallel_sgd/sgdp_impl.hpp</a>:</p>
<pre style='color:#555'>&gt; +  #pragma omp parallel  shared(sumIterate,halt) private(it) 
&gt; +  {
&gt; +    it=0; 
&gt; +    while(it!=maxIterations &amp;&amp; halt != true)
&gt; +    {
&gt; +      it++;
&gt; +      int th_num=omp_get_thread_num(); //thread number is stored in which the thread is running. 
&gt; +      arma::mat gradient(iterate.n_rows, iterate.n_cols);  //To make gradient private to each thread it is declared here.
&gt; +      int selectedFunction;
&gt; +    
&gt; +      selectedFunction=std::rand()%numFunctions;
&gt; +      function.Gradient(tIterate[th_num],selectedFunction, gradient);
&gt; +      tIterate[th_num] -= stepSize * gradient;
&gt; +      
&gt; +  
&gt; +      #pragma omp barrier    //wait untill all the threads reach here
</pre>
<p>Not needed! </p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/603/files/1bb4efe93db25ae1d1f36c765b4b16b46cdc0c7c..39c317571e2014f017d648ae72f586c8b0148069#r58859113">view it on GitHub</a><img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFN8TTbWzrYBlGjTCcjdUkOeqIUrxks5p1PGigaJpZM4H_54U.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/603/files/1bb4efe93db25ae1d1f36c765b4b16b46cdc0c7c..39c317571e2014f017d648ae72f586c8b0148069#r58859113"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>