Enabling buffered I/O to stdout with Intel ifort compiler

Enabling buffered I/O to stdout with Intel ifort compiler

Аватар пользователя ciaron

I've read the Intel docs about enabling buffered I/O with ifort (using -assume buffered_io or FORT_BUFFERED=true), and this works fine for output directly to files. However, we have large applications that are writing to stdout (e.g.write(*,*) or write(stdout,*)), which is redirected to a file. Neither of the buffering techniques work in this case.

Other than refactoring the code to write directly to files, is there a method to enable buffered I/O on stdout with ifort? This is enabled by default on, for example, gfortran.

We're using ifort 12.0 on SLES 11.

6 сообщений / 0 новое
Последнее сообщение
Пожалуйста, обратитесь к странице Уведомление об оптимизации для более подробной информации относительно производительности и оптимизации в программных продуктах компании Intel.
Аватар пользователя Ronald W Green (Intel)

There is no support for buffering IO for stdout. I can put in a feature request, but it will be for non-default behavior.

Our runtime buffers on line boundaries by default.

There is an obvious problem with making it default - users expect that write(*,*) statements for debug purposes come out in a timely manner. If you buffer them, you cannot rely on them for debug.

also, for our cluster customers: if stdout is buffered and the distributed app is killed, it is very common to kill remote processes and destroy their buffers, hence NO output would come out.

I will put in a feature request for a non-default way to enable buffering of stdout. I doubt we want to do this for stderr, as that information should definitely be delivered in near-real time.

ron

Аватар пользователя Ronald W Green (Intel)

Feature Request ID DPD200236607

Аватар пользователя ciaron

Thanks very much! In the meantime, I'm investigating stdbuf and/or piping through a buffering program (like tee) as a workaround.

Аватар пользователя jimdempseyatthecove

Ronald,

I found this on stackoverflow.com

fpost_t pos;
fgetpos(stdout, &pos);
return (pos >= 0);

As to if this alwasy works I cannot say.

Jim Dempsey

Blog: The Parallel Void

www.quickthreadprogramming.com
Аватар пользователя John Damm S.

We are facing the same problem and would like to know the status of the feature request.

How about adopting the gfortran/g77 behavior where redirection to a file cause the I/O to be buffered?

Best
John

Зарегистрируйтесь, чтобы оставить комментарий.