h2d: Cuda class methods: h2dVector, h2dMatrix

Description Usage Arguments Details Value Examples

Description

Load a numeric vector or matrix to device.

Usage

1
2
3
cu <- new(Cuda) 
cu$h2dVector(x) 
ch$h2dMatrix(x)

Arguments

x

Vector or Matrix (of type numeric) to load onto the device. Memory is automatically allocated prior to loading.

Details

Note that when the object returned by this function is garbage collected, the device memory will be automatically freed. However, garbage collection occurs "sometime in the future" after the object is destroyed, so if you are allocating many data items on the device, you may wish to expliticly call the Cuda class method dFree to free it.

Value

An XPtr to the device pointer. More precisely, an XPtr to a cuData object that encapsulates the device pointer along with the data's original dimensions so it can be properly formatted when subsequently retrieved.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
cu <- new(Cuda)

# create data vector and load on device
x <- rnorm(20)
x_dev <- cu$h2dVector(x)

# copy our data back from device
copy <- cu$d2hVector(x_dev)
all.equal(x, copy)

## End(Not run)

erikor/cudalite documentation built on May 31, 2019, 8:07 a.m.