Skip to content

yuanli22/RCUDA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RCUDA

This is an R GPU computing package via NVIDIA CUDA framework. It consists of wrappers of cuBLAS cuRAND libraries and self-defined CUDA functions. By defining gpu objective in R environment, we want to provide a high performance GPU solution to linear algebra and random number generators. Our package enables users to keep as much work on the GPU side as possible and avoid unnecessary data transfer between CPU and GPU.

Prerequisities

Installing package

To install RCUDA, user needs to speficy the path for both R and CUDA includes and library.

  1. R_HOME specifies the R root path, for example 'R_HOME = /usr/bin/R'

  2. R_INC specifies the R include path, for example 'R_INC := /usr/share/R/include'

  3. R_LIB specifies the R library path, for example 'R_LIB := /usr/lib/'

  4. CUDA_HOME specifies the CUDA root path, for example 'CUDA_HOME := /usr/local/cuda-7.5'

  5. CUDA_INC specifies the CUDA include path, for example 'CUDA_INC := $(CUDA_HOME)/include'

  6. CUDA_LIB specifies the CUDA library path, for example 'CUDA_LIB := $(CUDA_HOME)/lib64' (depends on your system structure 32-bit or 64-bit)

Running the tests

  • Build the package in linux by command 'R CMD build RCUDA' to get the file RCUDA_1.0.tar.gz

  • In R, compile your package by command 'install.packages("yourpath/RCUDA_1.0.tar.gz", repos = NULL)'

  • In R, load the library by command 'library(RCUDA)'

  • In R, run the test file (located at the 'tests' folder) by command 'source("yourpath/srcs/test.R")'

Sample code

Suppose we already installed and loaded the library in R, here is a sample code to perform GPU object creating and matrix-vector multiplication.

creategpu(1:4, 2, 2) -> A     ##create a 2 by 2 matrix in GPU and assign it to object A 
                              ##function creategpu second and third input is the row and column numbers of matrix

creategpu(1:2) -> b       ##create a vector in GPU and assign it to object b
                          ##without dimension specification, creategpu defautly assumes 
                          ##vector with length equals to number of input elements 

mvgpu(A, b) -> c      ##compute the result A*b and store the result in GPU object c. 
                      ##Here mvgpu is the matrix-vector multiplication function in RCUDA
                        
gathergpu(c) -> result       ##transfer the outcome from c (GPU object) to result (CPU object) 
                             ##which can be applied to native R function later

Available functions

BLAS implementation progress

Level 1

CUBLAS functions:

  • amax
  • amin
  • asum
  • axpy
  • copy
  • dot
  • nrm2
  • rot
  • rotg
  • rotm
  • rotmg
  • scal
  • swap

Level 2

Key:

  • ge: general
  • gb: general banded
  • sy: symmetric
  • sb: symmetric banded
  • sp: symmetric packed
  • tr: triangular
  • tb: triangular banded
  • tp: triangular packed
  • he: hermitian
  • hb: hermitian banded
  • hp: hermitian packed

CUBLAS functions:

  • gbmv
  • gemv
  • ger
  • sbmv
  • spmv
  • spr
  • spr2
  • symv
  • syr
  • syr2
  • tbmv
  • tbsv
  • tpmv
  • tpsv
  • trmv
  • trsv
  • hemv
  • hbmv
  • hpmv
  • her
  • her2
  • hpr
  • hpr2

Level 3

CUBLAS functions:

  • gemm
  • gemmBatched
  • symm
  • syrk
  • syr2k
  • syrkx
  • trmm
  • trsm
  • trsmBatched
  • hemm
  • herk
  • her2k
  • herkx

BLAS-like extensions

  • geam
  • dgmm
  • getrfBatched
  • getriBatched
  • geqrfBatched
  • gelsBatched
  • tpttr
  • trttp

Random number generators

  • Gaussian
  • Log-Gaussian
  • Poisson
  • Uniform
  • Gamma
  • Beta

High level statistical functions

  • sample Mean
  • sample Variance
  • Covariance
  • Gaussian density function
  • Gamma density function
  • Beta density function

Authors

  • Yuan Li - Initial work
  • Hua Zhou - Package design

License

This project is licensed under the MIT License - see the LICENSE.md file for details