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

Strategy for merging file output from multiple coarray images?

OP1
New Contributor III
518 Views

I am looking for a strategy to implement the merging of file output when a coarray program is executed.

Assume I have a code being executed on multiple images. Ideally, the overall behavior of the code and some intermediate results would be documented in a small number of log files (possibly just one). At regular intervals (but not too frequently), the slave images would add content to these *.log files.

I am a bit at a loss to find an elegant solution to this problem, and if somebody here could share their experience with this I would be very grateful!

0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
518 Views

Try having each image update into a coarray a write sequence number. IOW after each write to log file it increments the write count. The master image would collect the write counts at any convenient sync. When (if) count differs from last time then continue reading from the specific log file. Your log file has to be attributed and open to permit shared access.

On Windows, you might also want to consider using a named pipe.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365799(v=vs.85).aspx

Jim Dempsey

0 Kudos
OP1
New Contributor III
518 Views

Thanks Jim,

One of the options I am considering is having a dedicated image solely in control of the log file(s). This 'error/message-handling' image would be in a spin loop, only interrupted by other images passing messages to it (messages would be passed through coarrays), so that they can be written out by this special image.

This is a real waste of resources though, when a small number of images are used.

0 Kudos
Steven_L_Intel1
Employee
518 Views

If you know you are on a single system (and not a cluster), then Jim's named pipe solution is probably best - but rather than waiting for a message you should sleep for a short time and check for messages as otherwise you'll completely stall the image. It's possible that some of the enhancements being considered for F2015 such as events would help, but I'm not sure.

Today, writing separate log files and combining them is an approach that scales.

0 Kudos
Reply