Hi David,
Thank you for your reply.
Infact, my code looks like this:
-----------------------------------------------
CONDITION = 0; /* '0' for all the processes */
for(n=1; n<=Nt; n++)
{
for(i=1; i=Nx; i++)
for(j=1; j=Ny; j++)
for(k=1; k=Nz; k++)
if(condition met)
{
CONDITION = 1; /* if condition is true for any of the processes */
MPI_Allreduc(&CONDITION,&CONDITION,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
}
if(CONDITION == 1) break;
}
-------------------------------------
I want to break the outermost 'for' loop (i.e. for(n=1; n<=Nt; n++) ). I tried
your way, but it's not working. I want that if condtion is true for any of the
processes then it should be communicated to all the processes and hence
all the
processes must break come out of the outermost 'for' loop. This is what I want
to achieve. Please help me how to implement this thing.
Looking forward to hearing from you.
Thanks,
--
Ravi R. Kumar
859-333-8174
Quoting David Singleton <David.Singleton_at_[hidden]>:
>
> Collectives like MPI_Allreduce must be called by ALL processes within
> the communicator used. You are calling it from within a conditional.
> Will that conditional be true for all processes eventually? If not,
> those processes that do call MPI_Allreduce() it will hang.
>
> Maybe you want something like:
>
> for(i=1; i=Nx; x++)
> {
> if(condition met) CONDITION = 1;
> MPI_Allreduce(&CONDITION,&CONDITION,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
> if(CONDITION == 1) break;
> }
>
>
> Ravi R. Kumar wrote:
>> Hello Everyone,
>>
>> I am having problem in implementing loop break condition in my C++/MPI code.
>> Here is the code I want to implement:
>>
>> CONDITION = 0;
>> for(n=1; n<=Nt; n++)
>> {
>>
>> for(i=1; i=Nx; x++)
>> if(condition met)
>> {
>> CONDITION = 1;
>> MPI_Allreduc(&CONDITION,&CONDITION,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
>> }
>>
>> if(CONDITION == 1) break;
>>
>> }
>>
>> When I execute my code with this implementation, it hangs and
>> terminates with
>> error. The error I got is:
>>
>> srun: interrupt (one more within 1 sec to abort)
>> srun: task0: running
>> srun: interrupt (one more within 1 sec to abort)
>> srun: task[0-5]: running
>> srun: error: node1: task0: Exited with exit code 130
>> srun: sending Ctrl-C to job
>>
>> Could anyone please point out mistake in my implementation? I would
>> appericate
>> any help.
>>
>> Thanks a lot,
>> Ravi Kumar
>> Looking forward to hearing from you.
>>
>> Thanks,
>>
>
>
> --
> --------------------------------------------------------------------------
> Dr David Singleton ANU Supercomputer Facility
> HPC Systems Manager and APAC National Facility
> David.Singleton_at_[hidden] Leonard Huxley Bldg (No. 56)
> Phone: +61 2 6125 4389 Australian National University
> Fax: +61 2 6125 8199 Canberra, ACT, 0200, Australia
> --------------------------------------------------------------------------
> _______________________________________________
> This list is archived at http://www.lam-mpi.org/MailArchives/lam/
>
|