[Rcpp-devel] NVCC compatibility

Iñaki Úcar i.ucar86 at gmail.com
Tue Jan 9 17:17:27 CET 2018


2018-01-09 16:25 GMT+01:00 Charles Determan <cdetermanjr at gmail.com>:
> Greetings,
>
> I have been exploring GPU implementations for R.  Primarily I have been
> using OpenCL given it is so portable and everyone can use it without being
> tied to NVIDIA.  That said, NVIDIA hardware is difficult to beat and
> creating packages that leverage are arguably valuable (e.g. gputools,
> gmatrix).  In my efforts to explore how to best develop these types of
> packages I must use NVCC but I also would like to continue leveraging Rcpp.
> Normally, any compilation with NVCC would results in the following warnings
> and error when including Rcpp.h.
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h(121): warning:
> statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h(74): warning:
> statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/vector_from_string.h(42):
> warning: statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h(54): warning:
> statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h(74): warning:
> statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/r_cast.h(121): warning:
> statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/Environment.h(97): warning:
> statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/vector_from_string.h(42):
> warning: statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h(324):
> warning: statement is unreachable
>
> /usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/proxy.h(99): error:
> the object has type qualifiers that are not compatible with the member
> function "Rcpp::internal::string_name_proxy<RTYPE>::get"
>             object type is: const Rcpp::internal::string_name_proxy<RTYPE>
>
>
> I stumbled upon another github user's package that tries to address this by
> a small modification in Rcpp.  You can see it here
> (https://github.com/jtilly/RcppThrust) were the user notes that removing the
> 'const' in line 98 of Rcpp/vector/proxy.h allows the compilation to succeed
> (although the warnings continue).

Instead of discarding that 'const', I would try first to check whether
adding it to the getter solves the problem without breaking anything.
I.e.:

char* get() const {

instead of [1]. At least it sounds more reasonable to me.

[1] https://github.com/RcppCore/Rcpp/blob/0.12.9/inst/include/Rcpp/vector/proxy.h#L128

Iñaki


More information about the Rcpp-devel mailing list