compileGPUCode: Compile the R function without excute it in the device.

Description Usage Arguments Value Examples

View source: R/gpuApply.R

Description

Compile the R function without excute it in the device.

Usage

1
2
3
4
5
6
7
compileGPUCode(
  X,
  FUN,
  ...,
  .macroParms = NULL,
  .options = gpuSapply.getOption()
)

Arguments

X

a vector that FUN will loop over.

FUN

The function to be applied to each element of X

...

optional arguments to FUN

.macroParms

The function argument that will be treated as macro in the code. If an argument is treated as macro, its value cannot be changed by the code

.options

The package and openCL compilation options, please call gpuSapply.getOption() to get all the available options

Value

A list of compilation information

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#matrix add function
matAdd = function(ind,A,B){
C = A[,ind]+B[,ind]
return(C)
}

n = 100
m = 200
#Create the data
A = matrix(runif(n*m),n,m)
B = matrix(runif(n*m),n,m)
#Compile the R code
res = compileGPUCode(1:m,matAdd,A,B)
#print GPU code
cat(res$gpu_code)

gpuMagic documentation built on Nov. 8, 2020, 5:15 p.m.