gdup: Duplicate a GPU object

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

View source: R/00general.R

Description

This function duplicates a gmatrix or gvector object on the specified device.

Usage

1
gdup(x, dev=getDevice())

Arguments

x

object to duplicate

dev

device to duplicate the object on

Details

This function is very important because the gmatrix and gvector classes store only a pointer to an object on the GPU device. Thus, a line such as y<-x will duplicate the pointer but not the actual data on the GPU. One should use instead y<-gdup(x). The gdup function is also useful for copying the data to a different GPU device.

Value

a gmatrix or gvector object.

Author(s)

Nathan Morris

See Also

To move data to a different device instead of copying it see device

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#problematic code
x=gseq(1,10)
y=x 
x[1]=1000 
show(y)#changes to x also change y

#correct
x=gseq(1,10)
y=gdup(x) 
x[1]=1000 
show(y) #changes to x do not change y

#copy to a different device 
#y=gdup(x, dev=2L)

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