MarcelK
2008-Nov-04 12:55 UTC
[R] Help needed using 3rd party C library/functions from within R (Nvidia CUDA)
Hello, I'm trying to combine the parallel computing power available through NVIDIA CUDA (www.nvidia.com/cuda) from within R. CUDA is an extension to the C language, so I thought it would be possible to do this. If I have a C file with an empty function which includes a needed CUDA library (cutil.h) and compile this to an .so file using a NVIDIA compiler (nvcc), called 'myFunc.so' I can load this fine from within R with dyn.load("myFunc.so"). But, as soon as I want to call it's function I get:> dyn.load("myFunc.so") > .C("testFunc")Error in .C("testFunc") : C symbol name "testFunc" not in load table The myFunc.c file looks like this: #include<cutil.h> #include<stdio.h> #include<stdlib.h> #include<R.h> void testFunc() { printf("Hello!\n"); } The problem is that NVIDIA has their own C compiler (nvcc) which is needed to compile code for their devices. This compiler calls 'gcc' (or Windows C compiler) for all standard C code, so setting the 'CC = nvcc' might still work when using 'R CMD SHLIB' to compile C files to shared libraries. But as far as I know, if I use the same flags R CMD SHLIB uses (nvcc passes them to gcc) it should work.. Can anyone point me in the right direction? Thanks in advance. -- View this message in context: http://www.nabble.com/Help-needed-using-3rd-party-C-library-functions-from-within-R-%28Nvidia-CUDA%29-tp20321716p20321716.html Sent from the R help mailing list archive at Nabble.com.
Prof Brian Ripley
2008-Nov-04 13:16 UTC
[R] Help needed using 3rd party C library/functions from within R (Nvidia CUDA)
Please see the R posting guide (the footer of this and every R-help message). - This is not an R-help question but an R-devel one. - You have not told us your OS, nor any of the 'at a minimum' information requested in the posting guide. But look at nm -g myFunc.so to see what symbols are exported. Please post any follow-up help request on R-devel, with as far as possible a completely reproducible example. On Tue, 4 Nov 2008, MarcelK wrote:> > Hello, > > I'm trying to combine the parallel computing power available through NVIDIA > CUDA (www.nvidia.com/cuda) from within R. CUDA is an extension to the C > language, so I thought it would be possible to do this. > > If I have a C file with an empty function which includes a needed CUDA > library (cutil.h) and compile this to an .so file using a NVIDIA compiler > (nvcc), called 'myFunc.so' I can load this fine from within R with > dyn.load("myFunc.so"). > But, as soon as I want to call it's function I get: > >> dyn.load("myFunc.so") >> .C("testFunc") > Error in .C("testFunc") : C symbol name "testFunc" not in load table > > The myFunc.c file looks like this: > > #include<cutil.h> > #include<stdio.h> > #include<stdlib.h> > #include<R.h> > > void testFunc() { > printf("Hello!\n"); > } > > The problem is that NVIDIA has their own C compiler (nvcc) which is needed > to compile code for their devices. This compiler calls 'gcc' (or Windows C > compiler) for all standard C code, so setting the 'CC = nvcc' might still > work when using 'R CMD SHLIB' to compile C files to shared libraries. But as > far as I know, if I use the same flags R CMD SHLIB uses (nvcc passes them to > gcc) it should work.. > > Can anyone point me in the right direction? > > Thanks in advance. > -- > View this message in context: http://www.nabble.com/Help-needed-using-3rd-party-C-library-functions-from-within-R-%28Nvidia-CUDA%29-tp20321716p20321716.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595