On 29 July 2017 at 15:00, Iñaki Úcar wrote: | With our simulator, simmer, we are able to generate arrivals, entities | that execute a given set of activities. One of these activities could | be, let's say, a delay. A user can provide this delay as a fixed | parameter to the C++ core, but also as a function that returns a | value, giving them a lot of flexibility to implement the simulation | model. As a trade-off, calling an R function from C++ is slow. | | Now, what if the user needs flexibility *and* speed and so decides to | pass a cppFunction instead? This is perfectly valid and works like a | charm. In fact, this speeds up things a lot, especially if the | function was performing some heavy processing. *However*, it means | that we still have C++ calling R calling C++. | | This is why I say, what if I can detect that situation and completely | get rid of that thin R layer? What if I can extract the pointer and | call C++ directly from my C++ core? I would expect an impressive | performance improvement.
Are you aware of what we can do with Rcpp::XPtr and what e.g. the RcppDE package does to pass __user-supplied C++ functions__ down to the core of the optimization to avoid touching R code? There is also a Rcpp Gallery piece on this: http://gallery.rcpp.org/articles/passing-cpp-function-pointers/ Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel