Discussion:
[Rcpp-devel] finding plugins
M A
2018-12-01 03:49:04 UTC
Permalink
Is there a standard way to list what plugins are available in Rcpp? And,
given a plugin, how do I find out what exactly is in that plugin? I did
find in the inline package inline::getPlugin() for the second of these
questions, but it does not work on Rcpp plugins (e.g. the openmp plugin)
and I can't find an equivalent in Rcpp. These seem like they should be easy
questions with obvious solutions, but I can't find anything. Sorry if I did
miss something obvious.

Mark
Dirk Eddelbuettel
2018-12-01 15:18:40 UTC
Permalink
On 30 November 2018 at 21:49, M A wrote:
| Is there a standard way to list what plugins are available in Rcpp? And,
| given a plugin, how do I find out what exactly is in that plugin? I did
| find in the inline package inline::getPlugin() for the second of these
| questions, but it does not work on Rcpp plugins (e.g. the openmp plugin)
| and I can't find an equivalent in Rcpp. These seem like they should be easy
| questions with obvious solutions, but I can't find anything. Sorry if I did
| miss something obvious.

Have you found this obvious answer yet:

Rcpp FAQ Question 3.6
"How do I write a plugin for inline and/or Rcpp Attributes"

My pdf reader shows me 36 hits for 'plugin' in that Rcpp FAQ document.

As for 'what exists': there is no central registry as packages can bring
their own; the mechanism is such that when a package loads it can register
upon load. You could use the same hooks to a) scan all your installed (but
not yet loaded) packages and b) list currently registered plugins. I don't
think anybody has written such a helper yet.

As for 'what is in it': "Use the source, Luke."

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
M A
2018-12-01 17:30:44 UTC
Permalink
Yes, thanks, I did at least manage to read through the FAQ, but,
unfortunately, none of the mentions of 'plugins' was helpful for my
questions. I can search through the source to find the plugins that come
with Rcpp, but I'm not familiar enough with the necessary mechanisms to
know what hooks to look for or use to be able to list currently registered
plugins.

An issue is that I can't get at least some plugins to work with
cppFunction. For instance:
library(Rcpp)
library(RcppArmadillo)
library(inline)
cppFunction('//Anything', depends="RcppArmadillo", plugin="RcppArmadillo",
verbose=TRUE)

just gives error:
Error in .findPlugin(pluginName) :
Inline plugin 'RcppArmadillo' could not be found within the Rcpp package.
You should be sure to call registerPlugin before using a plugin.

Thanks,
Mark
Post by Dirk Eddelbuettel
| Is there a standard way to list what plugins are available in Rcpp? And,
| given a plugin, how do I find out what exactly is in that plugin? I did
| find in the inline package inline::getPlugin() for the second of these
| questions, but it does not work on Rcpp plugins (e.g. the openmp plugin)
| and I can't find an equivalent in Rcpp. These seem like they should be easy
| questions with obvious solutions, but I can't find anything. Sorry if I did
| miss something obvious.
Rcpp FAQ Question 3.6
"How do I write a plugin for inline and/or Rcpp Attributes"
My pdf reader shows me 36 hits for 'plugin' in that Rcpp FAQ document.
As for 'what exists': there is no central registry as packages can bring
their own; the mechanism is such that when a package loads it can register
upon load. You could use the same hooks to a) scan all your installed (but
not yet loaded) packages and b) list currently registered plugins. I don't
think anybody has written such a helper yet.
As for 'what is in it': "Use the source, Luke."
Dirk
--
Balamuta, James Joseph
2018-12-01 17:59:21 UTC
Permalink
Mark,

Consider:

cppFunction('//Anything', depends="RcppArmadillo", plugin="RcppArmadillo", verbose=TRUE)

Armadillo is not a plugin but a library. Plugins are for changing the C++ compilation standard, enabling OpenMP, or changing the long jump behavior. Examples of built-in plugins can be found here:

https://github.com/RcppCore/Rcpp/blob/b7dc5f16488d5b6f46bf3aadbce3ef06ca72ff3f/R/Attributes.R#L469-L534

Perhaps try with:

cppFunction('//Anything', depends="RcppArmadillo", verbose=TRUE)

Full list:


* cpp98
* cpp11
* cpp0x
* older gcc C++11
* cpp14
* cpp1y
* C++14/C++17 standard under dev
* cpp17
* cpp1z
* C++17 standard under dev
* openmp
* Enable OpenMP
* unwindProtect
* long jump behavior

Sincerely,

JJB

From: Rcpp-devel <rcpp-devel-***@lists.r-forge.r-project.org> on behalf of M A <***@gmail.com>
Date: Saturday, December 1, 2018 at 11:31 AM
To: "***@debian.org" <***@debian.org>
Cc: "rcpp-***@lists.r-forge.r-project.org" <rcpp-***@lists.r-forge.r-project.org>
Subject: Re: [Rcpp-devel] finding plugins

Yes, thanks, I did at least manage to read through the FAQ, but, unfortunately, none of the mentions of 'plugins' was helpful for my questions. I can search through the source to find the plugins that come with Rcpp, but I'm not familiar enough with the necessary mechanisms to know what hooks to look for or use to be able to list currently registered plugins.

An issue is that I can't get at least some plugins to work with cppFunction. For instance:
library(Rcpp)
library(RcppArmadillo)
library(inline)
cppFunction('//Anything', depends="RcppArmadillo", plugin="RcppArmadillo", verbose=TRUE)

just gives error:
Error in .findPlugin(pluginName) :
Inline plugin 'RcppArmadillo' could not be found within the Rcpp package. You should be sure to call registerPlugin before using a plugin.

Thanks,
Mark

On Sat, Dec 1, 2018 at 9:18 AM Dirk Eddelbuettel <***@debian.org<mailto:***@debian.org>> wrote:

On 30 November 2018 at 21:49, M A wrote:
| Is there a standard way to list what plugins are available in Rcpp? And,
| given a plugin, how do I find out what exactly is in that plugin? I did
| find in the inline package inline::getPlugin() for the second of these
| questions, but it does not work on Rcpp plugins (e.g. the openmp plugin)
| and I can't find an equivalent in Rcpp. These seem like they should be easy
| questions with obvious solutions, but I can't find anything. Sorry if I did
| miss something obvious.

Have you found this obvious answer yet:

Rcpp FAQ Question 3.6
"How do I write a plugin for inline and/or Rcpp Attributes"

My pdf reader shows me 36 hits for 'plugin' in that Rcpp FAQ document.

As for 'what exists': there is no central registry as packages can bring
their own; the mechanism is such that when a package loads it can register
upon load. You could use the same hooks to a) scan all your installed (but
not yet loaded) packages and b) list currently registered plugins. I don't
think anybody has written such a helper yet.

As for 'what is in it': "Use the source, Luke."

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org<mailto:***@debian.org>
Dirk Eddelbuettel
2018-12-01 18:14:05 UTC
Permalink
Mark,

You still haven't explained what your actual problem is. Or maybe I missed it.


James,

On 1 December 2018 at 17:59, Balamuta, James Joseph wrote:
| Armadillo is not a plugin but a library. Plugins are for changing the C++ compilation standard, enabling OpenMP, or changing the long jump behavior. Examples of built-in plugins can be found here:
|
| https://github.com/RcppCore/Rcpp/blob/b7dc5f16488d5b6f46bf3aadbce3ef06ca72ff3f/R/Attributes.R#L469-L534
|
| Perhaps try with:
|
| cppFunction('//Anything', depends="RcppArmadillo", verbose=TRUE)
|
| Full list:
|
|
| * cpp98
| * cpp11
| * cpp0x
| * older gcc C++11
| * cpp14
| * cpp1y
| * C++14/C++17 standard under dev
| * cpp17
| * cpp1z
| * C++17 standard under dev
| * openmp
| * Enable OpenMP
| * unwindProtect
| * long jump behavior

Plus, as I said, all the ones brought by packages using Rcpp as eg this
reasonably powerful one for RcppGSL which sets compile and link options:

https://github.com/eddelbuettel/rcppgsl/blob/master/R/inline.R#L47-L59

Maybe this could even be answered with a proper GitHub search query for eg
Rcpp.plugin.maker.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
M A
2018-12-01 21:05:51 UTC
Permalink
Sorry, I, in fact, wasn't clear about my problem. Essentially I'm going to
benchmark some matrix operations using R, RcppEigen, and RcppArmadillo so
when I do my real problem I'm using fast code. Part of this involves seeing
the effect of multithreading (with either openmp or through a multithreaded
BLAS, while making sure I'm only doing one of those at a time) and other
possible compiler flags. Right now, I'm just trying to learn how to do
these things with Rcpp.

The matrix operation code is not long, so I thought the easiest thing for
now would be to use cppFunction. Documentation in RcppEigen, for instance,
uses cxxfunction which specifies the plugin "RcppEigen", and this is also
what is mostly used in the Rcpp FAQ with an "RcppArmadillo" plugin. The
help page for cppFunction also says that the plugins argument is a
character vector of *inline* plugins. James' message has made me realize
that, actually, there's a difference between a plugin in the cxxfunction
and a plugin in cppFunction. At least for RcppEigen and RcppArmadillo the
correct translation is from cxxfunction(..., plugin="RcppX") to
cppFunction(..., depends="RcppX"). To get the compiler flags I want, I
think I have to write my own Rcpp plugin, which would then be a plugin for
cppFunction (and presumably in c++ source file in the attribute //
[[Rcpp::plugins(myflags)]].


Mark
Post by Dirk Eddelbuettel
Mark,
You still haven't explained what your actual problem is. Or maybe I missed it.
James,
| Armadillo is not a plugin but a library. Plugins are for changing the
C++ compilation standard, enabling OpenMP, or changing the long jump
|
|
https://github.com/RcppCore/Rcpp/blob/b7dc5f16488d5b6f46bf3aadbce3ef06ca72ff3f/R/Attributes.R#L469-L534
|
|
| cppFunction('//Anything', depends="RcppArmadillo", verbose=TRUE)
|
|
|
| * cpp98
| * cpp11
| * cpp0x
| * older gcc C++11
| * cpp14
| * cpp1y
| * C++14/C++17 standard under dev
| * cpp17
| * cpp1z
| * C++17 standard under dev
| * openmp
| * Enable OpenMP
| * unwindProtect
| * long jump behavior
Plus, as I said, all the ones brought by packages using Rcpp as eg this
https://github.com/eddelbuettel/rcppgsl/blob/master/R/inline.R#L47-L59
Maybe this could even be answered with a proper GitHub search query for eg
Rcpp.plugin.maker.
Dirk
--
Dirk Eddelbuettel
2018-12-01 21:26:19 UTC
Permalink
Yep:

- usage with inline (the package) != usage with Rcpp Attributes.

- usage with cppFunction != usage with sourceCpp

- usage with sourceCpp != usage with packages

I wish this was simpler, but this simply is the cognitive cost of having
developed this over multiple years. Sometimes things change, folks often see
one of the older approaches and stick with those.

The cleanest (but maybe most laborious) way would be to create mini-packages
with your benchmark code. One each for Armadillo, Eigen, ...

The run those with/without optimised blas, multithreaded blas, ...

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Continue reading on narkive:
Loading...