rocprofiler icon indicating copy to clipboard operation
rocprofiler copied to clipboard

Standard output not being flushed during program execution when using Open MPI and rocprof

Open yoann-heitz opened this issue 3 years ago • 1 comments

When running a MPI program with Open MPI and rocprof, all that has been written in the standard output is only flushed at the end of the program execution at once even if "\n" has been written in the standard output . When using MPICH and rocprof or Open MPI without rocprof, the standard output is automatically flushed during program execution when "\n" has been written in the standard output. When using the fflush function, the standard output is correctly flushed during program execution with Open MPI and rocprof.

This can be problematic for long programs that rely on printing "\n" in the standard output rather than using fflush(stdout) to display the progress of the program (machine learning for example).

A test case is provided attached to this issue. It can be build with : mpicc openmpi_rocprof_issue.c -L/opt/rocm/hip/lib/ -l amdhip64 -I /opt/rocm/include -D __HIP_PLATFORM_AMD__

I ran it with only one rank to avoid post-processing issues : mpirun -n 1 rocprof --hip-trace -d my_trace ./a.out

Line 13 can be commented/uncommented to check the behavior when using fflush(stdout)

openmpi_rocprof_issue.zip

yoann-heitz avatar Feb 21 '22 12:02 yoann-heitz

You can try to specify line buffering for stdout explicitly setvbuf(stdout, NULL, _IOLBF, 4096);

kikimych avatar Mar 24 '22 10:03 kikimych

@yoann-heitz Do you still need assistance with this ticket? If not, please close the ticket. Thanks!

ppanchad-amd avatar Aug 27 '24 18:08 ppanchad-amd

@yoann-heitz Closing ticket. Please feel free to re-open a ticket if you still see the issue with the latest ROCm. Thanks!

ppanchad-amd avatar Sep 24 '24 17:09 ppanchad-amd