These functions and objects allow us to compile an R function into PTX code so that it can be used as a GPU kernel, i.e. run on a GPU.
compileGPUKernel
maps the R code to GPU instructions.
ModuleForNVVM
creates an LLVM Module for housing Functions and
variables. This sets the appropriate information for the Module to be
used for a Nvidia GPU, setting the data layout information for the
different basic data types.
setGPUKernel
adds an nnvm.annotations
attribute to each of the
functions. This is used by libNVVM when creating the final usable code
for the GPU.
fixPTXCodeForNVVM
is used to post-process generated code
so that it can be then used by the libNVVM mechanism.
compileGPUKernel(fun, types, module = ModuleForNVVM(name), name = NULL,
.compilerHandlers = getGPUCompilerHandlers(), .insertReturn = TRUE,
.builtInRoutines = getGPUBuiltInRoutines(), .useFloat = TRUE, ...)
fixPTXCodeForNVVM(code)
setGPUKernel(funs, module)
the R function to map to GPU instructions
type information for the parameters and return value
the LLVM module in which the Function is to be (or was)
created. For setGPUKernel
, this can be missing and so obtained from the first Function.
the name of the newly created LLVM/compiled Function
the collection of "methods"/functions that constitute the compiler. These handle the different constructs in the R code and map them to GPU
a logical value controlling whether we should
pre-process the R code to insert the explicit return
calls. This simplifies the job of the individual handler functions.
a list describing built-in routines that may be referenced.
a logical value. This controls whether we use double or float data type for numeric variables.
additional arguments passed directly to
compileFunction
a character string containing the PTX code generated by compiling code for the GPU
a list of LLVM Function objects
The newly created Function
object, i.e. the LLVM routine.
LLVM, libNVVM