RLLVMCompile (version 0.2-0)

compileGPUKernel: Compile an R function as a GPU kernel

Description

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.

Usage

compileGPUKernel(fun, types, module = ModuleForNVVM(name), name = NULL,
                 .compilerHandlers = getGPUCompilerHandlers(), .insertReturn = TRUE,
                  .builtInRoutines = getGPUBuiltInRoutines(), .useFloat = TRUE, ...)
fixPTXCodeForNVVM(code)
setGPUKernel(funs, module)

Arguments

fun

the R function to map to GPU instructions

types

type information for the parameters and return value

module

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.

name

the name of the newly created LLVM/compiled Function

.compilerHandlers

the collection of "methods"/functions that constitute the compiler. These handle the different constructs in the R code and map them to GPU

.insertReturn

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.

.builtInRoutines

a list describing built-in routines that may be referenced.

.useFloat

a logical value. This controls whether we use double or float data type for numeric variables.

additional arguments passed directly to compileFunction

code

a character string containing the PTX code generated by compiling code for the GPU

funs

a list of LLVM Function objects

Value

The newly created Function object, i.e. the LLVM routine.

References

LLVM, libNVVM

See Also

compileFunction