On Wednesday, August 23 at 06:22 PM, quoth Aidaros Dev:
>Doing C finish
>Doing D finish
>myid 1 end
>Doing A finish
>Doing B finish
>myid 0 end
>
>Why the myid 0 doenst start untill myid 1 finish and vice versa?
When you spawn a new process or thread, normally it gets a little time
to execute right when you first start it; for example, when you
fork(), the new process gets to run for a few hundred milliseconds
before thereâs a context switch to another process. If your program
runs to completion in that time⦠then the one program can complete
before the parent program (the parent program) has gotten to run
again.
> Why the MPI_Barriar has been skipped? one processor should wait
> until other call it.
It may not have been skipped. The output of printf is buffered, and
so in many situations the output is only actually printed to the
terminal when the entire buffer is flushed. For example, your programs
could be running exactly in parallel, and merely putting their output
into the output buffer (thatâs what printf() does) rather than
forcing the output to screen or file immediately (especially if what
youâre printing is small). However, when the programs exit the entire
buffer must be flushed. After the MPI Barrier, one (apparently) exits
before the other, and so his entire output (since it got stored in the
buffer) is displayed at once, and then the next one to exit has its
output displayed all at once.
You can force the buffers to flush immediately by doing an
fflush(NULL);
--
Kyle B. Wheeler Scalable Computing Systems (1423)
Student Intern Sandia National Laboratories
kbwheel_at_[hidden] 505-844-7179
MS: 1319 CSRI/237
- application/pgp-signature attachment: stored
|