PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

output redirection & PGI compilers
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
mamaluy



Joined: 13 Sep 2004
Posts: 4

PostPosted: Mon Nov 07, 2005 10:14 am    Post subject: output redirection & PGI compilers Reply with quote

Hello guys,

so, is there a solution to the output redirection problem with PGI compilers?

I don't experience this problem with any other compilers (pathscale, intel), so I am quite surprised that there seem to be no simple fix to this problem. At least I couldn't find one in this forum or PGI docs.

I repeat: whenever one redirects the output to a file, there is a significant delay in updating its content. It seems that the output log is being updated only when it gains a certain "critical mass" (buffer size?) or when the program is finished.

I am using Fortran 90, but as far as I know the same problem exists with C++.

Thanks -

Denis.
Back to top
View user's profile
David Norton



Joined: 18 Aug 2004
Posts: 20

PostPosted: Mon Nov 07, 2005 12:09 pm    Post subject: Reply with quote

Hi Denis -

Do you have any more information on this? I don't see any issue when I redirect stdout to a file. A simple:

csh> make >& build.log

doesn't seem to have any appreciable delay on my system.

What shell are you running, what OS and version, and what command are you using? Do you notice the delay when you don't redirect the output?

-dave
Back to top
View user's profile
mamaluy



Joined: 13 Sep 2004
Posts: 4

PostPosted: Mon Nov 07, 2005 12:48 pm    Post subject: Reply with quote

Thanks for the reply, Dave.

It's not about MAKE, it is about any executable, produced by PGI compilers.
I have a fortran code that outputs some messages on the screen like

print *,'calculating big A matrix'
!... actual calculation of A, takes some time
print *,'calculating big B matrix'
!... actulal calculation of B, takes some time
etc.


So, if I compile the code with pgf90 and run it
>./executable
then it immediately produces the message "calculating big A matrix", as expected. Once matrix A is calculated, it immediately produces message "calculating big B matrix", etc.

Now, if I start
>(./executable >& output.txt) &
(redirecting the output of the same executable to the file output.txt), then the file output.txt contains (initially) nothing, even though it should already have contained "calculating big A matrix". The message will only appear later on, when (as I understand it) enough messages will be accumulated to be written to output.txt.
Of course, once the code is finished output.txt will contain all the messages (because, probably, the buffer is flushed at the end).
However, there is always a delay in writing the messages to the file (compared to the screen output). There is NO delay in the performance. Only in outputing the messages.

The system I have:

Suse Linux 9.2 64bit running on an dual-CPU Opteron 250
As I mentioned I am using PGF90.
If I am compiling the same code with other compilers, there is no delay in the output and the output.txt contains "up-to-date" info all the time.
Back to top
View user's profile
mamaluy



Joined: 13 Sep 2004
Posts: 4

PostPosted: Mon Nov 07, 2005 1:15 pm    Post subject: additional note Reply with quote

If I look into output.txt file while the program is still running I may find something like

...
calculating big A matrix
calcula

I.e. only a PART of the message ('calculating big B matrix') is shown. This is (as I understand) due to the fact that the output buffer is flushed when it reaches a certain size. Once it "accumulates" enough data (or when the program is finished) the rest of the message will be written to output.txt:
...
calculating big A matrix
calculating big B matrix
...


My question is how to control that internal stdout output buffer of the PGI compilers? Can I change its size? Can I tell the compiler to produce a code without an stdout output buffer at all, so that the messages would be written to a file immediately - as they appear on the screen?
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6134
Location: The Portland Group Inc.

PostPosted: Tue Nov 08, 2005 9:06 am    Post subject: Reply with quote

Hi Denis,

How are you printing your output? Are you using WRITE or PRINT? Do you open and close stdout?

Since it only happens with redirection, this suggests an OS or program problem. However, since it only occurs with PGI compiled code, this suggests a compiler problem. So far we been unable to recreate the issue so don't have a good handle on why it would occur. Can you send the code in question to trs@pgroup.com?

Ohio State has a good web page about how to flush fortran output (
Here). Note the section about repeatedly open and closing files.

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group