I made an R package with Rcpp where whole simulations are run in c++ and results are analyzed in R. Now I need to profile my functions so I can optimize them, but R profilers can't distinguish what happens inside the C++ functions, and I don't know how to run C++ profilers when the functions can only be ran from inside R.
So far, I have found some suggestions to use gperftools (questions and tutorials) but the guides are incomplete (maybe they assume a level of knowledge that I lack?), have missing links, and I keep running into walls. Hence this question. Here's where I'm at:
The current wall is gcc tells me "Undefined Symbol: ProfilerStart", so I think there's something wrong with the linking?
I'm not really very impressed with gperftools. Also, it appears to be an instrumenting profiler, sampling-based profilers are easier to use and are likely to run faster. Intels VTune is an excellent sampling-based profiler, available for free if you're an educational user. Even if you're not, your organisation may already have licenses.
Turning to your gperftools issue, yes, that's a linker issue. As you have decided not to share any of the relevant information (link command? compile command? Actual error messages?) we can't help you further.
It was a linking error after all, caused by my lack of experience as this is the first time I use Makevars.
In step #4, I added "-lprofiler" to PKG_CXXFLAGS
, that is used in compiling, when I should have added it to PKG_LIBS
. I made the change and now the profiler works just fine. This is my Makevars now:
PKG_CXXFLAGS += -Wall -pedantic -g -ggdb #-fno-inline-small-functions
PKG_LIBS += -lprofiler
CXX_STD = CXX11
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With