Note that there are some explanatory texts on larger screens.

plurals
  1. POMPI_Scatter Segfaulting
    primarykey
    data
    text
    <p>I'm working on a parallel sort program to learn MPI, and I've been having problems with MPI_Scatter. Every time I attempt to run, I get the following:</p> <pre><code>reading input Scattering input _pmii_daemon(SIGCHLD): [NID 00012] PE 0 exit signal Segmentation fault [NID 00012] 2011-03-28 10:12:56 Apid 23655: initiated application termination </code></pre> <p>A basic look at other questions didn't really answer why I'm having troubles - The arrays are contiguous, so I shouldn't have problems with non-contiguous memory access, and I'm passing the correct pointers in the correct order. Does anyone have any ideas?</p> <p>Source code is below - It's specified for a specific number because I don't want to deal with variable input and rank size just yet.</p> <pre><code>#include &lt;mpi.h&gt; #include &lt;iostream&gt; using std::endl; using std::cout; #include &lt;fstream&gt; using std::ifstream; using std::ofstream; #include &lt;algorithm&gt; using std::sort; #define SIZEOF_INPUT 10000000 #define NUMTHREADS 100 #define SIZEOF_SUBARRAY SIZEOF_INPUT/NUMTHREADS int main(int argc, char** argv){ MPI_Init(&amp;argc, &amp;argv); int input[SIZEOF_INPUT]; int tempbuf[SIZEOF_SUBARRAY]; int myRank; MPI_Comm_rank(MPI_COMM_WORLD, &amp;myRank); /* Read input from file */ if(myRank == 0){ cout &lt;&lt; "reading input" &lt;&lt; endl; ifstream in(argv[1]); for(int i = 0; i &lt; SIZEOF_INPUT; ++i) in &gt;&gt; input[i]; cout &lt;&lt; "Scattering input" &lt;&lt; endl; } // Scatter, Sort, and Gather again MPI_Scatter(input,SIZEOF_INPUT,MPI_INT,tempbuf,SIZEOF_SUBARRAY,MPI_INT,0,MPI_COMM_WORLD); cout &lt;&lt; "Rank " &lt;&lt; myRank &lt;&lt; "Sorting" &lt;&lt; endl; sort(tempbuf,tempbuf+SIZEOF_SUBARRAY); MPI_Gather(tempbuf,SIZEOF_SUBARRAY,MPI_INT,input,SIZEOF_INPUT,MPI_INT,0,MPI_COMM_WORLD); if(myRank == 0){ cout &lt;&lt; "Sorting final output" &lt;&lt; endl; // I'm doing a multi-queue merge here using tricky pointer games //list of iterators representing things in the queue int* iterators[NUMTHREADS]; //The ends of those iterators int* ends[NUMTHREADS]; //Set up iterators and ends for(int i = 0; i &lt; NUMTHREADS; ++i){ iterators[i] = input + (i*SIZEOF_SUBARRAY); ends[i] = iterators[i] + SIZEOF_SUBARRAY; } ofstream out(argv[2]); int ULTRA_MAX = SIZEOF_INPUT + 1; int* ULTRA_MAX_POINTER = &amp;ULTRA_MAX; while(true){ int** curr_min = &amp;ULTRA_MAX_POINTER; for(int i = 0 ; i &lt; NUMTHREADS; ++i) if(iterators[i] &lt; ends[i] &amp;&amp; *iterators[i] &lt; **curr_min) curr_min = &amp;iterators[i]; if(curr_min == &amp;ULTRA_MAX_POINTER) break; out &lt;&lt; **curr_min &lt;&lt; endl; ++(*curr_min); } } MPI_Finalize(); } </code></pre> <p>Any help would be much appreciated. Regards, Zach</p>
    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.
 

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