c++ - MPI_Bcast hanging -
I followed the example and added some code for the test, but when I added the new code, some strange results emerged. The results are shown below: it is hanging here and was not able to move forward. [0]: Before BCC, the buff is 777 [1]: Before the BCC, the bluff is 32767 [0]: After the BCC, the buff is 777
from two point of view Weird:
-
When the code (code =
-
Whey
buffer [1]
is not before bcast.
Here is the code:
#include & lt; Mpi.h & gt; # Include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; # Include & lt; Unistd.h & gt; Int main (int argc, char ** argv) {int rank; Int buf; Const int root = 0; MPI_Init (& amp; argc, & argv); MPI_Comm_rank (MPI_COMM_WORLD, and Rank); If (rank == root) {buf = 777; } Printf ("[% d]: Before BCC, buf% d \ n", rank, buff); // added for new (i int = 0; i & lt; 2; i ++) {if (rank == i) {if (i == 1) MPI_Bcast (& amp; buf, 1, MPI_INT, rank) , MPI_COMM_WORLD); }} / / * Every time the call is taken from the root, the data is taken from the root and ends in everyone's buf * / MPI_Bcast (& amp; buf, 1, MPI_INT, root, MPI_COMM_WORLD) is; Printf ("[% d]: after BCC, buf% d \ n", rank, buff); MPI_Finalize (); Return 0; }
What I really want to do is to realize the function: each processor runs a portion of the processing, then after receiving the results, it transmits it, the other processor is its combination By combining the updated results
This is the main part of the code (the original code is from LibSewM)
struct decision_function {double * alpha; Double row; }; Int gate_no = 2; Int p = 0; Int nr_class = 8; For (; I & lt; i = 0 int nr_class; i ++) {for (int j = i + 1; j & lt; nr_class; j ++) {if (((world_rank == i-2 * Gate_no * (I / (2 * gate_no)) & amp; amp; (i% (2 * gate_no & lt; gate_no)) || ((world_rank == 2 * gate_no * (I / (2 * Gate_no) +1) I-1) & amp; amp; (I% (2 * gate_no) & gt; = gate_no))) {// Here are some procedures for generating F [P] ... MPI_Bcast (F [p] .pha, count [i] + count [j], mpeg_double, world_crank, mpeakomm_wireLD); } ++ p; }}
But this code does not work, and I get some errors. Critical Error in PMPI_Bcast: Other MPI Error, Error Stack: PMPI_Bcast (1478) ......................: MPI_Bcast (buf = 0xcc7b40, counts = 2340, MPI_DOUBLE , Root = 1, MPI_COMM_WORLD) failed in MPIR_Bcast_impl (1321). ................: MPIR_Bcast_intra (1119) ................: MPIR_Bcast_scatter_ring_allgather (962): MPIR_Bcast_binomial (154) ... ...........: message size group
this block
if (rank == i) {if (i == 1) MPI_Bcast (& amp; buf; 1, MPI_INT, rank, MPI_COMM_WORLD); }
means that only calls process 1 to MPI_Bcast
. Since it is a mass operation, so all processes in the Communicator should call it (at the same time). Waiting for all other people in process 1 of this case, if I understand correctly, they will continue until they go to the next call on MPI_Bcast
and they wait for process 1 Are there. and wait. and wait.
I am not sure why you are actually trying to do this, in fact, no creative advice can be given about correcting it.
Comments
Post a Comment