title: MATLAB parfor is slower than for -- what is wrong?
body: <p>the code I'm dealing with has loops like the following:</p>
  
  <pre><code>bistar = zeros(numdims,numcases); 
  parfor hh=1:nt       
    bistar = bistar +  A(:,:,hh)*data(:,:,hh+1)' ;
  end   
  </code></pre>
  
  <p>for small nt (10). </p>
  
  <p>After timing it, it is actually <strong>100 times slower</strong> than using the regular loop!!! I know that parfor can do parallel sums, so I'm not sure why this isn't working.</p>
  
  <p>I run </p>
  
  <pre><code>matlabpool
  </code></pre>
  
  <p>with the out-of-the-box configurations before running my code.</p>
  
  <p>I'm relatively new to matlab, and just started to use the parallel features, so please don't assume that I'm am not doing something stupid.</p>
  
  <p>Thanks!</p>
  
  <p>PS: I'm running the code on a quad core so I would expect to see some improvements.</p>