[Trilinos-Users] Printing Objects Causes Hangs

Ammar T. Al-Sayegh alsayegh at purdue.edu
Sun Sep 4 23:46:19 MDT 2005


Mike,

Thank you for following up on my question. The "cout << x"
statement is intended to be within the block, because this
example is a simple illustration what I am trying to do in
my program. Since each process will be doing a different
task, but will share some vectors and other variables, I
need to check the values of the vectors on individual
processes during execution for debugging purposes without
having to synchronize the code so that all the processes
will execute the cout line at the same time.

I'm not sure if heading to the right approach for
parallelizing my code if my debugging scheme will not
work properly. The serial coding went through seamlessly
with all the Epetra serial objects. But now that I'm
trying to parallelize my program, my MPI-background logic
doesn't seem to help much in here. For example, I now
know how to distribute objects, but still can't distribute
the computation workload properly as any attempt to use
"If(Comm.MyPID()){}" to control what gets executed in
each processor will cause my program to hang at some
Epetra functions.


-ammar


----- Original Message ----- 
From: "Michael A Heroux" <maherou at sandia.gov>
To: "'Ammar T. Al-Sayegh'" <alsayegh at purdue.edu>
Cc: <trilinos-users at software.sandia.gov>
Sent: Sunday, September 04, 2005 11:51 PM
Subject: RE: [Trilinos-Users] Printing Objects Causes Hangs


> Ammar,
> 
> The use of "cout <<" with Epetra distributed objects requires all processors
> to participate in the operation, even if some have no elements of the
> object.  If you move the "cout << x;" statement outside the if block, then
> this code should work.  In fact, you can remove the if statement altogether
> since the Random() method will work just fine without it.
> 
> Mike
> 
>> -----Original Message-----
>> From: trilinos-users-bounces at software.sandia.gov 
>> [mailto:trilinos-users-bounces at software.sandia.gov] On Behalf 
>> Of Ammar T. Al-Sayegh
>> Sent: Saturday, September 03, 2005 9:35 PM
>> To: trilinos-users at software.sandia.gov
>> Subject: [Trilinos-Users] Printing Objects Causes Hangs
>> 
>> Hi All,
>> 
>> When I try to print objects to standard output from a single 
>> processor, the program hangs. Consider the following code 
>> with two processors, for example:
>> 
>>     // create the map. all global elements are in P0
>>     int nge = 0;
>>     if(Comm.MyPID() == 0)
>>         nge = 4;
>>     Epetra_Map Map(-1, nge, 0, Comm);
>> 
>>     // create the vector, populate it, and print it from P0
>>     Epetra_Vector x(Map);
>>     if(Comm.MyPID() == 0)
>>     {
>>         x.Random();
>>         cout << x;
>>     }
>> 
>> The program hangs after printing x to standard output as P1 
>> terminates successfully while P0 doesn't terminate. Anyone 
>> experienced the same problem? How can it be resolved?
>> 
>> Thanks.
>> 
>> 
>> -ammar
>> 
>> _______________________________________________
>> Trilinos-Users mailing list
>> Trilinos-Users at software.sandia.gov
>> http://software.sandia.gov/mailman/listinfo/trilinos-users
>> 
> 
>



More information about the Trilinos-Users mailing list