【问题标题】:GProf: What are __cosl_internal and __sinl_internal functions?GProf:__cosl_internal 和 __sinl_internal 函数是什么?
【发布时间】:2018-11-24 13:39:51
【问题描述】:

我一直在使用 gprof 分析我的程序,并注意到顶部附近出现以下内容:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 17.50      6.69     6.69                             _mcount_private
 12.14     11.33     4.64                             __cosl_internal
 11.02     15.54     4.21                             __sinl_internal

我大量使用 cmath 库中的 cosine 和 sine 函数,因为 cos 和 sin 在这些函数调用的名称中,所以可能就是这些函数。但是,在探查器的下方,我也有

 %   cumulative   self              self     total           
time   seconds   seconds    calls   s/call   s/call  name    
2.93     23.25     1.12                             cos
2.51     24.21     0.96                             sin

这令人困惑,所以我不完全确定 __cosl/sinl_internal 的实际含义。尝试用 Google 搜索该问题时没有得到有意义的结果。

这里是使用的构建命令:

i686-w64-mingw32-g++.exe -Wshadow -Winit-self -Wredundant-decls 
-Wcast-align -Wfloat-equal -Wunreachable-code -Wmissing-include-dirs 
-pedantic-errors -pedantic -Wall -std=c++14 -fexceptions -O2 -std=c++14 
-pg -DSFML_STATIC -std=c++14

【问题讨论】:

    标签: c++ profiling gprof


    【解决方案1】:

    这两个函数是cossin的实现细节。

    如果查看https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-crt/math/cos.def.h#L51,三角函数首先会检查值是NaN 还是无穷大,然后再计算实际值。这就是您获得两次点击的原因:

    • 一个用于计算本身
    • 用于检查有效数字的包装代码。

    您可以将内部函数视为 cos/sin 调用。根据生成的调试信息和优化级别,它们可能不会显示从 sin/cos 调用的事实。

    【讨论】:

      猜你喜欢
      • 2010-11-16
      • 1970-01-01
      • 2013-07-10
      • 2016-02-12
      • 1970-01-01
      • 2016-12-26
      • 2012-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多