Skip to content

[Rcpp-devel] routine registration

3 messages · Ramon Diaz-Uriarte, Kevin Ushey, Dirk Eddelbuettel

#
Dear All,

Does it make sense to use C routine registration
(http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines)
in a package that has C++ code and uses Rcpp? What are the pros and cons?


All of my code is C++. Writing the relevant code for routine registration
is not hard (it is actually automagic if one uses
https://github.com/kevinushey/Kmisc/blob/master/R/registerFunctions.R). But
I wonder if it really makes sense to do this. 

I've googled around and I haven't been able to find much (maybe a problem
of my google-fu). I've looked at packages in CRAN and BioConductor that
import Rcpp and almost none, of those I've looked at, use registration
(except for a few that use Kmisc's registerFunctions).


Thanks,

R.
#
Hi Ramon,

Nice to see that there are people stumbling upon Kmisc and finding it
useful ;) It was developed partially in response to new BioConductor
guidelines requiring packages with source code to register the entry
points, and since that's a pain to do manually, and it was possible to
automate...

I believe everything in the manual applies identically to C++ code -- in
essence, the question is:

    1. Do we take a string, e.g. "C_do_something", and resolve that to some
entry point dynamically, or
    2. Do we pre-resolve these entry points, cache them in the package, and
then enter that way?

and so the second version should be marginally faster, but I doubt you
would notice it unless you were calling that function from the R
interpreter millions of times (and even then other overhead would dominate).

Cheers,
Kevin


On Wed, Jun 25, 2014 at 12:11 PM, Ramon Diaz-Uriarte <rdiaz02 at gmail.com>
wrote:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140625/5e349b63/attachment.html>
#
Hi Ramon,
On 25 June 2014 at 21:11, Ramon Diaz-Uriarte wrote:
| 
| Dear All,
| 
| Does it make sense to use C routine registration
| (http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines)
| in a package that has C++ code and uses Rcpp? What are the pros and cons?

I do in two cases:
  
 - RcppRedis uses (C language) code from the (small, mine) RApiSerialize package
 - RcppXts uses (C language) code from the (larger, not mine, they let me
   commit though) xts package

Registration is nice because it avoid explicit linking, and R handles this
effectively for you.
 
| All of my code is C++. Writing the relevant code for routine registration
| is not hard (it is actually automagic if one uses
| https://github.com/kevinushey/Kmisc/blob/master/R/registerFunctions.R). But
| I wonder if it really makes sense to do this. 

I need to look at that too, and maybe cook up an example with Kevin. I
basically followed non-Rcpp, non-C++ packages just trying to get C code in.

Cheers from DSC,  Dirk
 
| I've googled around and I haven't been able to find much (maybe a problem
| of my google-fu). I've looked at packages in CRAN and BioConductor that
| import Rcpp and almost none, of those I've looked at, use registration
| (except for a few that use Kmisc's registerFunctions).
| 
| 
| Thanks,
| 
| R.
| 
| 
| -- 
| Ramon Diaz-Uriarte
| Department of Biochemistry, Lab B-25
| Facultad de Medicina 
| Universidad Aut?noma de Madrid 
| Arzobispo Morcillo, 4
| 28029 Madrid
| Spain
| 
| Phone: +34-91-497-2412
| 
| Email: rdiaz02 at gmail.com
|        ramon.diaz at iib.uam.es
| 
| http://ligarto.org/rdiaz
| 
| 
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel