[R-pkg-devel] Creating a Makevars that includes objects from another compiler

Charles Determan cdetermanjr at gmail.com
Fri Jun 5 18:02:42 CEST 2015


A quick followup, even when I try and use the g++ I cannot seem to pass the
objects (it keeps omitting the .o file generated from nvcc).  How can I
have my Makevars file pass a defined list of object files to the final
shared library call?

Alternate  gpuRcuda.so block where the build output still doesn't use the
OBJS variable (note, I confirmed that the OBJS variable does contain all .o
files)

gpuRcuda.so: $(OBJS)
        $(CXX) $< -o $@ $(R_LIBS) $(LIBS)

Regards,
Charles

On Fri, Jun 5, 2015 at 9:42 AM, Charles Determan <cdetermanjr at gmail.com>
wrote:

> Greetings,
>
> Quick context, I have been working on developing a set of packages to make
> GPU computing as simple as possible with R.  I have a functional package
> that works very nicely with OpenCL based code (gpuR -
> https://github.com/cdeterman/gpuR) but I also am building a companion
> CUDA backend package (gpuRcuda - https://github.com/cdeterman/gpuRcuda)
> which is stripped down to a single function at the moment to work out the
> compiling issue described below.
>
> The problem is, CUDA requires me to use the NVCC compiler.  So I cannot
> just rely on the magic of Rcpp, I need to create a Makevars file.  I have
> done so and I am very close but I cannot get the shared object file to be
> created with NVCC.  The individual files compile with NVCC just fine, the
> build script just keeps switching back to g++ for the shared object file.
>
> A quick excerpt from my build script
>
> '''
> /usr/local/cuda-7.0/bin/nvcc -arch=sm_30 -Xcompiler -fPIC -Xcudafe
> --diag_suppress=boolean_controlling_expr_is_constant -I/usr/share/R/include
> -I/usr/include
> -I/home/cdeterman/R/x86_64-pc-linux-gnu-library/3.2/RViennaCL/include
> -I"/home/cdeterman/R/x86_64-pc-linux-gnu-library/3.2/RcppEigen/include"
> viennacl_sgemm.cu -c
>
> # NOW IT SWITCHES TO G++?
>
> ccache g++-4.8 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions
> -Wl,-z,relro -o gpuRcuda.so RcppExports.o viennacl_cudaMatrix_sgemm.o
> -L/usr/lib/R/lib -lR
> '''
>
> You can see my current Makevars file here (
> https://github.com/cdeterman/gpuRcuda/blob/master/src/Makevars).
>
> I have read in the 'Writing R Extensions' manual that this is possible
> with the OBJECTS macro (
> http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Creating-shared-objects)
> however I cannot figure out how to use it properly (and haven't been able
> to find an example).  I have looked at the other packages on CRAN that also
> use CUDA (such as WideLM which I tried to emulate) but I can't seem to
> figure out why R keeps defaulting the shared library creation to g++.
> Perhaps my shared object section of my Makevars is incorrect?
>
> Any insights would be sincerely appreciated,
> Charles
>
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list