Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is _IO_wfile on a gprof output of a fortran code?

I have some fortran code compiled with intel fortran compiler ifort. When I do a profile test with gprof, I get that most of the time is used in IO operations, I think finding the end of the files, but I can no find any more documentation on this:

index % time    self  children    called     name
                                                 <spontaneous>
[1]     20.6    0.07    0.00                 _IO_wfile_seekoff [1]
-----------------------------------------------
                                                 <spontaneous>
[2]     20.6    0.07    0.00                 sforcepf_ [2]
-----------------------------------------------
                                                 <spontaneous>
[3]     20.6    0.02    0.05                 _IO_wfile_underflow [3]
                0.01    0.04  258716/258717      strncmp [4]
-----------------------------------------------
                0.00    0.00       1/258717      _IO_wdefault_doallocate [15]
                0.01    0.04  258716/258717      _IO_wfile_underflow [3]
[4]     14.7    0.01    0.04  258717         strncmp [4]
                0.04    0.00 3104592/3109256     strerror_r [5]
-----------------------------------------------
                0.00    0.00    4664/3109256     __strcmp_sse42 [14]
                0.04    0.00 3104592/3109256     strncmp [4]
[5]     11.8    0.04    0.00 3109256         strerror_r [5]
-----------------------------------------------

So, the question would be, is this IO specific to Linux, or to ifort, or to fortran? I am trying to optimize this code, and have found no useful info about this terms in google.

like image 723
Gabriel Avatar asked Dec 06 '22 15:12

Gabriel


1 Answers

You write Fortran statements. The Intel Fortran compiler translates those statements into assembler including calls to system functions. For example, strncmp is an ISO C standard function to compare parts of strings. So it looks like you are writing Fortran statements to compare strings, and the Intel Fortran compiler is calling an existing function to implement the comparisons. Some of those system functions will themselves be implemented (in part) by calls to even more fundamental functions provided on your platform.

gprof is showing you the calls to the functions that it finds referred to in the products of your compilation. Most of what you see is specific to Linux I/O -- on a Windows machine the I/O would use similar functions with different names. It's possible that some of what you see is specific to the Intel compilers, that all Intel compilers use the same (Intel-created) function for some operation and that that function uses platform-specific lower-level functions.

Unless you are prepared to rewrite these low-level functions, and take the risk that you will screw them up for other programs using the same functions, then just about the only optimisation you can make is to call them less often. For example, if you have reason to think that reading past the end of a file is an expensive I/O operation, and if your program strategy is to read a file until you read past the end and then deal with the error that arises, then you may want to implement a superior program strategy. That will be easier than re-writing the low-level I/O routines which deal with the consequences of your strategy.

like image 136
High Performance Mark Avatar answered Dec 26 '22 00:12

High Performance Mark