# Making GPU power available in R

### Description

This package implements a general framework for utilizing R to harness the power
of NVIDIA GPU's. The `gmatrix`

and `gvector`

classes allow for easy management
of the separate device and host memory spaces. Numerous numerical operations are
implemented for these objects on the GPU. These operations include matrix
multiplication, addition, subtraction, the kronecker product, the outer product,
comparison operators, logical operators, trigonometric functions, indexing, sorting,
random number generation and many more.

### Details

Package: | gmatrix |

Type: | Package |

Version: | 0.1 |

Date: | 2013-5-10 |

License: | GPL-2 |

LazyLoad: | yes |

Depends: | methods |

To move an R object to the GPU use the `g`

function. To move the object back the the host use the `h`

function.
Standard operations such as matrix multiplication or addition may be performed on GPU objects as with any `matrix`

or `vector`

object in R.
The `gmatrix`

and `gvector`

classes contain a `type`

slot which determines if the data is stored as a `"double"`

, `"single"`

, `"integer"`

or `"logical."`

The `gmatrix`

and `gvector`

objects 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)`

.
Numerous random number generators such as `grnorm`

have been implemented in this package. This package is intended to work with the companion package `rcula`

which implements matrix factorization and inversions methods.

### Author(s)

Nathan Morris

### References

None

### See Also

`rcula-package`

, `g`

, `h`

, `gmatrix-class`

, `gvector-class`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
#Look at available GPU devices (use setDevice to change the device)
listDevices()
#Creating GPU objects
g_x=g(1:10) #transfer a sequence to the GPU
g_y=gseq(1,10) #create a sequence on the GPU
g_A=gmatrix(grnorm(100),10,10,dup=FALSE) #create a random 10x10 matrix
#look at and change the properties of these objects
type(g_x)
type(g_A)
type(g_x)="d" #'d' may be used as short form of"double"
length(g_x)
dim(g_A)
nrow(g_A)
#Perform some simple calculations
g_ans=g_x %*% log(abs(g_A)) %*% sin(-g_y)
g_rowsum= rowSums(g_A)
#Move data back to the host
h_ans=h(g_x)
h_roswum =h(g_A)
``` |