loadModule: Load a GPU module and access its Routines

Description Usage Arguments Value Author(s) References See Also Examples

Description

These functions load a module and allow us to get a reference to any of the named functions/routines or global variables it contains.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
loadModule(filename, ctx = cuGetContext(TRUE),
           isCode = is(filename, "raw") ||
                     is(filename, "AsIs") ||
                       grepl(" __cudaparm", filename),  
           ...)
getFunction(module, name) 
## S4 method for signature 'CUmodule'
x$name
## S4 method for signature 'CUmodule,character,missing'
x[[i,j, globalVar = FALSE, ...]]

Arguments

filename

the name of the file containing the GPU module. This can be in PTX, cubin or fatbin format. It is important that the code be compiled correctly for the appropriate architecture/GPU device. If not, an error is raised.

ctx

the context into which to load the module. If none has been created, this creates default contet that is used for this and subsequent computations.

isCode

a logical value that indicates whether filename is actually the PTX code itself or the name of a file containing the code. This allows us to obtain the code in R as a string and load it directly. One can use this argument or alternatively wrap the PTX text within a call to I() to indicate that it is the PTX code and not the name of a file. We also use some heuristic to determine if the text is PTX code.

...

additional parameters for methods

module,x

the module object returned by loadModule in which we will find the named function

name,i

the name of the function to find in the module. It is imperative that the kernel we want be compiled with the declaration extern "C" so that its name is not mangled.

j

missing/not supplied

globalVar

a logical that controls whether we are looking for a variable or a routine/function in the module.

Value

loadModule returns an reference to the C object and is of class CUmodule in R.

getFunction, if it succeeds, returns an object of class CUfunction and is a reference to the C data type representing this routine.

Author(s)

Duncan Temple Lang

References

http://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__MODULE.html#group__CUDA__MODULE_1g366093bd269dafd0af21f1c7d18115d3

See Also

.cuda

Examples

1
2
3
4
5
6
if(getNumDevices() > 0) {
  ctx = cuGetContext(TRUE)
  ptx = system.file("sampleKernels", "dnormOutput.ptx", package = "RCUDA")
  m = loadModule(ptx)
  kernel = m$dnorm_kernel
}

duncantl/RCUDA documentation built on May 15, 2019, 5:26 p.m.