I am working on a parallel sort program to learn MPI, and every time I am having problems with MPI_Scatter I try to run, I get the following:
Input reading input inputting input _pidadad (sigclld): [nid 00012] PE exit signal signal segmentation error [NID 00012] 2011- 03-28 10:21:56 APID 23655: Application termination started On the other questions, a basic form really did not answer why I am getting bothered - close to arrays, so I do not want to have problems with non-compatible memory access, and I passed the correct indicators in the right order. I am here. Anyone have any ideas?
The source code is below - it is specified for a specific number because I do not want to deal with variable input and rank size yet.
#include & lt; Mpi.h & gt; # Include & lt; Iostream & gt; Using the Std :: endl; Using std :: cout; # Include & lt; Fstream & gt; Std :: using ifstream; Using std :: ofstream; # Include & lt; Algorithm & gt; Using the Std :: sort; #define SIZEOF_INPUT 10000000 # defined NUMTHREADS 100 #define SIZEOF_SUBARRAY SIZEOF_INPUT / NUMTHREADS int main (int argc, char ** argv) {MPI_Init (and argc, and argv); Int input [SIZEOF_INPUT]; Int tact [SIZEOF_SUBARRAY]; Int myRank; MPI_Comm_rank (MPI_COMM_WORLD, & myRank); / * Read input from file * / if (myRank == 0) {cout & lt; & Lt; "Input reading" & lt; & Lt; Endl; Ifstream in (argv [1]); For (Int i = 0; I> Any help would be greatly appreciated Regards, Zach
< P> huh! This took me a while to see it This move is in MPI_Scatter , sending the sender amount every process, not collected in the total Along with; This is the amount to get from each, that is, it matters like MPI_Scatterv ; The count is for each process, but in this case, it is considered to be the same. Such
MPI_Scatter (input, SIZEOF_SUBARRAY, MPI_INT, tempbuf, SIZEOF_SUBARRAY, MPI_INT, 0, MPI_COMM_WORLD); Cout & lt; & Lt; "Rank" & lt; & Lt; My rank & lt; & Lt; "Sorting" & lt; & Lt; Endl; MPI_Gather (tempbuf, SIZEOF_SUBARRAY, MPI_INT, input, SIZEOF_SUBARRAY, MPI_INT, 0, MPI_COMM_WORLD); Works for me.
Also, beware of allocating large arrays on the stack; I know that this is just an example problem, but for me it was the cause of accidents. Dynamically do this
int * input = new int [SIZEOF_INPUT]; Int * tempbuf = new int [SIZEOF_SUBARRAY]; // .... Delete [] Input; Remove [] tempbuf; Resolved that issue.
Comments
Post a Comment