title: How can I initialize MPI in a function?
body: <p>I want to use multi-processes in a function and how can I make it.</p>
  
  <p>As you know, MPI_Init needs two parameter: "int argc, char **argv". Does it mean that I must add these two parameters in the function definition?</p>
  
  <p>My requirement is that I want to parallelize a step in function in stead of the step in main program. </p>
  
  <p>For example, </p>
  
  <pre><code>func(mat &amp;A, vec &amp;x) {
    some computation on A;
    auto B = sub_mat(A, 0, 10);
    B*x; // I want to parallelize this computation
  }
  main(){
    mat A;
    vec x;
    func(A, x);
  }
  </code></pre>
  
  <p>I just want to use MPI in B*x, but I don't know how to init MPI? By the way, if I can init MPI int func, does A exist in every processes at this time?</p>
  
  <p>Help me &amp; thanks!</p>