Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29262 Discussions

Speeding up printing during program execution

usanthosh
Beginner
647 Views
I have a FORTRAN (IVF-9.0) compiled program which does computations and is heavy on memory and processor. Intermittently the program writes large sets of results to one or more text files on the disk. As expected during the writing phase the program slows down tremendously. Will the speed of the overall program be faster if the printing is done using a separate thread while the computations proceed on the main thread? Or can some other method be suggested to speed up the overall progress of the program. Thank you.

- Santhosh
0 Kudos
5 Replies
jimdempseyatthecove
Honored Contributor III
647 Views

You may be able to recover some computation time by copying your results data in internal format then writing to files using seperate thread. A better route would be (if possible) to double buffer. Which will avoid the copy of results data.

As to if it is worth the programming effort, you have to determine how much time is spent writing out the data files. If this is only a small percent of the time then it is probably not worth the effort.

My son went to Purdue University and one of his friends was named Santosh. Would you happen to be this Santosh?

Jim Dempsey
0 Kudos
usanthosh
Beginner
647 Views

Thank you Jim for the suggestions. In this case it is probably not worth the effort since it will be quite an effort for me. I haveto first learn to write the code for a separate thread.

No, I went to school at UMass.

- Santhosh
0 Kudos
onkelhotte
New Contributor II
647 Views

You may be able to recover some computation time by copying your results data in internal format then writing to files using seperate thread. A better route would be (if possible) to double buffer. Which will avoid the copy of results data.

As to if it is worth the programming effort, you have to determine how much time is spent writing out the data files. If this is only a small percent of the time then it is probably not worth the effort.

My son went to Purdue University and one of his friends was named Santosh. Would you happen to be this Santosh?

Jim Dempsey

Hi Jim,

what do you mean to double buffer the data?

Markus
0 Kudos
TimP
Honored Contributor III
647 Views
Quoting - onkelhotte

what do you mean to double buffer the data?

Markus
Have you set /assume:buffered_io ?
0 Kudos
jimdempseyatthecove
Honored Contributor III
647 Views

You can use either one thread and asychronous I/O with two buffers in a single threaded loop

open file asychronous
read buffer 1 (no wait)
read buffer 2 (no wait)
loop:
wait for I/O to buffer 1
process buffer 1
read buffer 1 (no wait)
wait for I/O buffer 2
process buffer 2
read buffer 2 (no wait)
goto loop

Add end of file tests.

Alternate way is to use multiple threads (2). Use synchronous I/O and semephores. (WaitForSingleEvent).

Jim Demspey

0 Kudos
Reply