Note that there are some explanatory texts on larger screens.

plurals
  1. POThe same random numbers for each process in c++ code with MPI
    primarykey
    data
    text
    <p>I have C++ MPI code that works, in that it compiles and does indeed launch on the specified number of processors (<em>n</em>). The problem is that it simply does the same calculation <em>n</em> times, rather than doing one calculation <em>n</em> times faster.</p> <p>I have hacked quite a few examples I have found on various sites, and it appears I am missing the proper use of MPI_Send and MPI_Receive, but I can't find an instance these commands that takes a function as input (and am confused as to why these MPI commands would be useful for anything other than functions).</p> <p>My code is below. Essentially it calls a C++ function I wrote to get Fisher's Exact Test p-value. The random-number bit is just something I put in to test the speed.</p> <p>What I want is for this program to do is farm out <em>Fisher.TwoTailed</em> with each set of random variables (i.e., <em>A</em>, <em>B</em>, <em>C</em>, and <em>D</em>) to a different processor, rather than doing the exact same calculation on multiple processors. Thanks in advance for any insight--cheers!</p> <p>Here is the code: </p> <pre><code>int main (int argc, char* argv[]) { int id; int p; // // Initialize MPI. // MPI::Init ( argc, argv ); // // Get the number of processors. // p = MPI::COMM_WORLD.Get_size ( ); // // Get the rank of this processor. // id = MPI::COMM_WORLD.Get_rank ( ); FishersExactTest Fishers; int i = 0; while (i &lt; 10) { int A = 0 + rand() % (100 - 0); int B = 0 + rand() % (100 - 0); int C = 0 + rand() % (100 - 0); int D = 0 + rand() % (100 - 0); cout &lt;&lt; Fishers.TwoTailed(A, B, C, D) &lt;&lt; endl; i += 1; } MPI::Finalize ( ); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload