Skip to content
Prev 11313 / 12125 Next

[R-pkg-devel] GPU programming in R packages

? Sun, 16 Feb 2025 13:00:55 +0000
Wolfgang Rolke via R-package-devel <r-package-devel at r-project.org>
?????:
How large are the matrices? Are CPU-side calculations (possibly done in
special-purpose parallel code written in C/C++/Fortran/Rust) out of
question? What are your performance goals?
How about OpenCL [1]?

Pros:

* The 'OpenCL' package is already on CRAN, making it possible to write
  and run "kernels" straight from R.
* Unlike CUDA, OpenCL is an open standard, relatively portable between
  video card vendors. It is even possible to use a CPU-only
  "installable client driver" that would (probably very slowly) run the
  kernels on the processor when no compatible video card is present.

Cons:

* Additional user setup is required. The OpenCL package will fail to
  load if the OpenCL runtime is not installed; installing it from
  source will also require the OpenCL SDK with headers.
* Your code will also fail to run if OpenCL cannot find a working
  "platform", so any examples and tests will need to check for
  length(oclPlatforms) > 0 [2].