[R-sig-hpc] Use GPU in R with .Call
Norm Matloff
matloff at cs.ucdavis.edu
Mon Jul 23 03:15:31 CEST 2012
I just tried it in bash and it worked fine, Simon:
bash-4.2$ export PKG_LIBS="-L/usr/local/cuda/lib -lcudart"
bash-4.2$ R CMD SHLIB rthhist.o -o rthhistgpu.so
gcc -m32 -std=gnu99 -shared -L/usr/local/lib -o rthhistgpu.so rthhist.o
-L/usr/local/cuda/lib -lcudart -L/usr/lib/R/lib -lR
bash-4.2$ R CMD SHLIB rthhist.o -o rthhistgpu.s^
Am I misunderstanding your posting?
Agree that in a nonpackage situation it's easier to keep the dynamic
link files in the same directory.
Norm (csh holdout)
On Sun, Jul 22, 2012 at 09:00:06PM -0400, Simon Urbanek wrote:
> On Jul 22, 2012, at 5:41 PM, Norm Matloff wrote:
>
> > I'm not exactly sure what you are asking, Raymond, but this may answer
> > your question.
> >
> > Say you have a file x.cu. After compiling with nvcc -c as you did, then
> > do something like this:
> >
> > setenv PKG_LIBS "-L/usr/local/cuda/lib -lcudart"
> > R CMD SHLIB x.o -o x.so
> >
> > PKG_LIBS is an environment variable used by R CMD SHLIB.
> >
>
> FWIW the above will only work in csh (this is after many years that I see someone positing advice based on csh - I thought it died out ;)) and Rtools don't have csh (unsurprisingly).
>
> It's much easier and more portable to simply pass the flags directly to SHLIB - it's not a package after all. In Raymond's case something like
>
> R CMD SHLIB VecAdd_cuda.c VecAdd_kernel.o -lcudart
>
> Add -L if needed, but on Windows it's typically easiest to have DLLs in the same directory. I don't use CUDA so if in doubt, ask nvidia specialists for the exact flags.
>
> Cheers,
> Simon
>
>
> > Of course, you need to translate the setting of the environment variable
> > from Linux C shell to Windows, and substitute your location of the CUDA
> > library.
> >
> > Norm
> >
> > _______________________________________________
> > R-sig-hpc mailing list
> > R-sig-hpc at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
> >
> >
>
More information about the R-sig-hpc
mailing list