Search code examples
rparallel-processingdata-analysis

Port R into Cuda


I have a function fun1 written in R that takes a long time to run. I need to run said function a large number of times.

I have done some reading about running R programs on graphics cards and have only come up with a few packages that can run very specific functions (most matrix manipulation).

My question is: Is there a way to run fun1 or any user written function, on a graphics card (parallelized for speed). Such as a CUDA interpreter for R that could be installed, or maybe a way to compile R functions for cuda so that all I would have to do would be to write a little bit of Cuda/C to excecute my function originally written in R?

Anything and everything is helpful


Solution

  • AFAIK, there is no converter for any generic function to CUDA or OPENCL for that matter. I would love to be proven wrong as it would be a tremendous asset.

    The structure of functions for GPU is very different from normal CPU programming. So there is no CUDA interpreter for R. If you want something in R run on a GPU you need to:

    1. Write your desired function in CUDA
    2. Compile it with NVCC
    3. Link it to some additional C++ code (likely using Rcpp).

    You can look at how this has been accomplished with most of the available R GPU packages.

    My unreleased package using CUDA can be seen here. If you are interested in using OpenCL, my currently released, and more actively developed, package gpuR may be of interest to you. I am currently working on an interface to allow users to use custom OpenCL.