title: Parallel MPI Version
body: <p>I have to write a parallel MPI version of my dot product (code below):</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include &lt;sys/time.h&gt;
  
  #define SIZE 10000000
  
  volatile float a[SIZE];
  volatile float b[SIZE];
  
  int main(int argc, char **argv)
  {
    long int       i;
    double         sum;
    struct timeval time1, time2;
  
    srand(time(0));
    
    for (i = 0; i &lt; SIZE; i++)
    {
      a[i] = rand();
      b[i] = rand();
    }
      
    gettimeofday(&amp;time1, 0);
    
    sum = 0.0;
    
    for (i = 0; i &lt; SIZE; i++)
    {
      sum = sum + a[i]*b[i];
    }
  
    gettimeofday(&amp;time2, 0);
  MPI_Scatter(a, 1, MPI_INT, &amp;b, 1, MPI_INT, 0, MPI_COMM_WORLD);
  
    printf(&quot;Elapsed time (us) = %d\n&quot;, (time2.tv_sec-time1.tv_sec)*1000000 + time2.tv_usec - time1.tv_usec);
  
    return 0;
  }                
  </code></pre>
  <p><strong>My question is</strong>, what code do I need to add to the program, what MPI primitives are useful?</p>