Intruments调用树破坏的R,C ++和Fortran混合 [英] Intruments Call Tree broken mix of R, C++ and Fortran
问题描述
我试图剖析OpenMx的功能,一个包含C ++和Fortran代码的R包,用于CPU时间。我的操作系统是OS X 10.10。我已阅读。命令行工具示例返回相同的输出。
问题是,它看起来像 omxunsafedgemm _
将直接从主线程调用。但是,这是一个低级的Fortran函数。它总是由一个名为 omxDGEMM
的C ++函数调用。在本示例中, omxDGEMM
首先由 omxCallRamExpection
调用(因此几乎在调用树的底部)。 omxDGEMM
的总时间为0.因此,分析信息目前无用。
在原始版本包 omxDGEMM
定义为内联。我改变了这一点,希望它能解决这个问题。不是这样的。 omxunsafedgemm
由 omxDGEMM
调用,像
F77_CALL(omxunsafedgemm)(& transa,& transb,
&(nrow),&(ncol),&(nmid),
&数据,&(a->前导),
b->数据,&(b->前导),& beta,result->数据,& - > leading));
任何想法如何获得敏感的分析器输出?
这个问题是由gfortran的 -O2
编译器,R默认使用。 -O2
标志打开 -O1
标志启用和更多的所有优化步骤(参见 gcc manual page 98)。 -O1
标志启用的优化标志之一是 -fomit-frame-pointer
。 Instruments需要框架指针才能知道调用框架的父级(请参阅 this talk )。
因此,更改
FFLAGS = -g -O2 $(LTO)
到
FFLAGS = -g -O2 -fno-omit-frame-pointer $ )/ etc / Makeconf
中的
可解决问题。对我来说 R_HOME = / Library // Frameworks / R.framework / Versions / 3.2 / Resources
-O2
也解决了这个问题,但使OpenMx相当慢(我的情况下为200对30秒)。
I am trying to profile a function of OpenMx, an R package containing C++ and Fortran code, for CPU time. My operating system is OS X 10.10. I have read the section regarding this topic in the R manual. This section and this post lead me to try Instruments. Here is what I did
- Opened Instruments
- Chose the Time Profiler Template
- Pressed Record
- Started my R script using RStudio
I get the following output: . The command line tool sample returns the same output.
The problem is that it looks like omxunsafedgemm_
would be called directly from the Main Thread. However, this is a low level Fortran function. It is always called by a C++ function called omxDGEMM
. In this example omxDGEMM
is first called by omxCallRamExpection
(so almost at the bottom of the call tree). The total time of omxDGEMM
is 0. Thus, the profiling information is currently useless.
In the original version of the package omxDGEMM
is defined as inline. I changed this in the hope that it would resolve the issue. This was not the case. omxunsafedgemm
is called by omxDGEMM
like that
F77_CALL(omxunsafedgemm)(&transa, &transb,
&(nrow), &(ncol), &(nmid),
&alpha, a->data, &(a->leading),
b->data, &(b->leading),&beta, result->data, &(result->leading));
Any ideas how to obtain a sensible profiler output?
This problem is caused by the -O2
flag of the gfortran compiler, which R uses per default. The -O2
flag turns on all optimization steps that the -O1
flag enables and more (see gcc manual page 98). One of the optimization flags that the -O1
flags enables is -fomit-frame-pointer
. Instruments needs the frame pointers to know the parent of a call frame (see this talk).
Thus, changing
FFLAGS = -g -O2 $(LTO)
to
FFLAGS = -g -O2 -fno-omit-frame-pointer $(LTO)
in ${R_HOME}/etc/Makeconf
resolves the issue. For me R_HOME=/Library//Frameworks/R.framework/Versions/3.2/Resources
Simply omitting the -O2
also solves the issue but makes OpenMx considerably slower (200 vs 30 seconds in my case).
这篇关于Intruments调用树破坏的R,C ++和Fortran混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!