g: Transfer and R object to and from the GPU.

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

View source: R/00general.R

Description

The function g transfers the object to the GPU. The function h transfers it back to the host.

Usage

1
2
g(x, type = NULL, dup = TRUE)
h(x)

Arguments

x

The object to be transfered.

type

The type to convert the object to. There are three different ways to specify this. One may use the "double", "single", "integer" or "logical" notation. Alternatively the short form "d", "s", "i" or "s" notation may be used. Finally the internal integer representation of 0L, 1L, 2L or 3L may be used.

dup

This may be set to 'FALSE' to avoid duplicating x in the event that it is on the GPU allready and the original type is the same as the type argument.

Details

These functions may be more convenient than functions such as 'as.gmatrix' or 'as.gvector'. In addition to having a very short name, one does not need to consider whether the object is a vector or matrix.

Value

The 'h' function transfers device data back to the host and returns a matrix or vector, while the 'g' function returns an object of class gmatrix or gvector storing the data on the GPU.

Author(s)

Nathan Morris

See Also

as.gmatrix and as.numeric

Examples

1
2
3
4
h_x=1:10
g_x=g(h_x) #Transfer to the device
g_ans=crossprod(g_x) #Do a a calculation
h_ans=h(g_ans) #Transfer back to the host

gmatrix documentation built on May 29, 2017, 2:20 p.m.