Hi,
I am not sure if I understand your requirement correctly. I guess, you
want only rank-0 to execute the sequential code A and B in the for
loop, but all processes to execute the parallel code. Will adding the
condition as follows work for your case ?
for (i = 0; i < MAX; ++i) {
if (rank == 0) {
// some sequential code A
}
// parallel code B
if (rank == 0) {
// some sequential code C
}
}
Maybe specifying your case with a concrete example will help us
understand better.
--
Shashwat Srivastav
LAM / MPI Developer
Indiana University
ssrivast_at_[hidden]
On Thursday, Sep 25, 2003, at 01:04 America/Chicago, Wa-Kun Lam wrote:
> Hi all,
> I have a question about the loop in parallel code.
>
> for (i=0; i<MAX; i++)
> {
> // some sequential code
> // parallel code
> // some sequential code
> }
>
> In the above code, I want the outer loop to be dominated only by rank-0
> process. For that purpose, I add a condition like
>
> if (rank==0)
> {
> for (i=0; i<MAX; i++)
> {
> // some sequential code A
> // parallel code B
> // some sequential code C
> }
> }
> However, the above code will keep other process outside the loop so the
> parallel code B will not run parallelly. Anyone have idea for that
> issue?
>
> Thanks in advance.
>
>
>
>
> _______________________________________________
> This list is archived at http://www.lam-mpi.org/MailArchives/lam/
>
>
|