I've read related posts here and here, and looked at Dirk Eddelbuettel's talk here and yet I'm failing to even get a .log file from gperftools
. Here is my R
file, called Rcpp_practice.R
:
library(Rcpp)
Sys.setenv("PKG_LIBS"="-lprofiler")
sourceCpp('eigen.cpp')
a <- matrix(rnorm(300^2), 300, 300)
getEigenValues(a)
Here are the contents of eigen.cpp
:
#include <RcppArmadillo.h>
#include <gperftools/profiler.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
arma::vec getEigenValues(arma::mat M) {
return arma::eig_sym(M);
}
Then, on Terminal (I'm using OSX):
CPUPROFILE="eigenprof.log" R -f "Rcpp_practice.R"
I was hoping to see eigenprof.log
sitting in my working directory but I don't. Also, I don't get the message that I've seen in other posts of the form PROFILE: interrupts/evictions/bytes = 012/34/567891
I verified that I have the latest version of gperftools
installed. ($ brew upgrade google-perftools
gives Error: gperftools 2.5 already installed
).
What am I missing?
Update
After I modified my code to match @nrussell's I get this error message:
Error in dyn.load("/private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so") :
unable to load shared object '/private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so':
dlopen(/private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so, 6): Symbol not found: _ProfilerStart
Referenced from: /private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so
Expected in: flat namespace
in /private/var/folders/6k/ffcchdq52kbb7d631b5vsqcw0000gn/T/RtmpCIdHkG/sourceCpp-x86_64-apple-darwin13.4.0-0.12.7/sourcecpp_6c3253d60384/sourceCpp_2.so
Calls: sourceCpp -> source -> withVisible -> eval -> eval -> dyn.load
Execution halted
This appears on the line with sourceCpp
if I run the script interactively.
main()
in a c++ file, ensure I have all compilation and linking flags and options sorted out -- and then carry that to a Rcpp-based build. – Dirk Eddelbuettel