[mlpack-git] [mlpack/mlpack] parallel sgd (#603)

ranjan notifications at github.com
Thu Apr 7 06:46:10 EDT 2016


> +  #pragma omp parallel  shared(sumIterate,halt) private(it) 
> +  {
> +    it=0; 
> +    while(it!=maxIterations && halt != true)
> +    {
> +      it++;
> +      int th_num=omp_get_thread_num(); //thread number is stored in which the thread is running. 
> +      arma::mat gradient(iterate.n_rows, iterate.n_cols);  //To make gradient private to each thread it is declared here.
> +      int selectedFunction;
> +    
> +      selectedFunction=std::rand()%numFunctions;
> +      function.Gradient(tIterate[th_num],selectedFunction, gradient);
> +      tIterate[th_num] -= stepSize * gradient;
> +      
> +  
> +      #pragma omp barrier    //wait untill all the threads reach here

This barrier is not  needed!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/603/files/1bb4efe93db25ae1d1f36c765b4b16b46cdc0c7c..39c317571e2014f017d648ae72f586c8b0148069#r58852171
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160407/2d8ec29a/attachment.html>


More information about the mlpack-git mailing list