Ah. The original code snipit you sent was: MPI::COMM_WORLD.Barrier(); if if(rank == master) t1 = clock(); "code A"; MPI::COMM_WORLD.Barrier(); if if(rank == master) t2 = clock(); "code B";
Remember that the time that individual processes exit barrier is not guaranteed to be uniform (indeed, it most likely *won't* be the same). MPI only guarantees that a process will not exit until after all processes have entered. So taking t2 after the barrier might be a bit misleading, and may cause unexpected skew. Code B *probably* has no effect on time spent between t1 and t2. But extraneous effects might cause it to do so -- e.g., are you running in an oversubscribed scenario? And so on. On Oct 21, 2010, at 9:24 AM, Storm Zhang wrote: > > Thanks a lot for your reply. By commenting code B, I mean if I remove the > code B part, then the time spent on code A seems to run faster. I do have a > lot of communications in code B too. It involves 500 procs. I had thought > code B should have no effect on the time spent on code A if I use MPI_Barrier. > > Linbao > On Thu, Oct 21, 2010 at 5:17 AM, Jeff Squyres <jsquy...@cisco.com> wrote: > On Oct 20, 2010, at 5:51 PM, Storm Zhang wrote: > > > I need to measure t2-t1 to see the time spent on the code A between these > > two MPI_Barriers. I notice that if I comment code B, the time seems much > > less the original time (almost half). How does it happen? What is a > > possible reason for it? I have no idea. > > I'm not sure what you're asking here -- do you mean that if you put some > comments in code B, it takes much less time than if you don't put comments? > If so, then the comments have nothing to do with the execution run-time -- > something else is going on that is causing the delay. Some questions: > > - how long does it take to execute code B -- microseconds, or seconds, or ...? > - how many processes are involved? > - what are you doing in code B; is it communication intensive and/or do you > synchronize with other processes? > - are you doing your timings on otherwise-empty machines? > > -- > Jeff Squyres > jsquy...@cisco.com > For corporate legal information go to: > http://www.cisco.com/web/about/doing_business/legal/cri/ > > > _______________________________________________ > users mailing list > us...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/users > > _______________________________________________ > users mailing list > us...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/users -- Jeff Squyres jsquy...@cisco.com For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/