Fortran代码的gprof输出中的_IO_wfile是什么? [英] What is _IO_wfile on a gprof output of a fortran code?

查看:215
本文介绍了Fortran代码的gprof输出中的_IO_wfile是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些Fortran代码是用intel fortran编译器ifort编译的。当我使用gprof进行配置文件测试时,我发现大部分时间都用于IO操作,我认为找到文件的结尾,但是我找不到更多关于此的文档:

  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]
---------------------- -------------------------


$ b $所以,问题是,这是IO特定于Linux,或者ifort,还是fortran?我试图优化这段代码,并且没有在google中找到关于这个术语的有用信息。 你写Fortran语句。英特尔Fortran编译器将这些语句转换为汇编程序,包括对系统函数的调用。例如, strncmp 是ISO C标准函数,用于比较部分字符串。因此,看起来您正在编写Fortran语句来比较字符串,并且英特尔Fortran编译器正在调用现有函数来实施比较。其中一些系统功能本身将通过调用您的平台上提供的更基本的功能来部分实现。



gprof 会向您显示调用它在编译产品中引用的函数的调用。你看到的大部分是特定于Linux I / O的 - 在Windows机器上,I / O将使用具有不同名称的类似函数。您可能会看到一些特定于英特尔编译器的特性,即所有英特尔编译器对某些操作使用相同的(由英特尔创建的)函数,并且该函数使用特定于平台的低级函数。



除非您准备重写这些低级函数,并冒着将其用于其他使用相同函数的程序的风险,那么您可以做出的唯一优化就是不经常打电话给他们。例如,如果您有理由认为读取文件的尾部是昂贵的I / O操作,并且如果您的程序策略是读取文件,直到读完文件并处理出现的错误,那么你可能想要实施一个优秀的计划战略。这比重写低层I / O例程来处理您的策略后果要容易。


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.

解决方案

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.

这篇关于Fortran代码的gprof输出中的_IO_wfile是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆