runifGpu {clrng} | R Documentation |
runifGpu
Description
Generate uniform random numbers parallely on a GPU.
Usage
runifGpu(
n,
streams,
Nglobal = getOption("clrng.Nglobal"),
type = getOption("clrng.type"),
verbose = FALSE
)
Arguments
n |
a number or a numeric vector specifying the size of output vector or matrix. |
streams |
a vclMatrix of streams. |
Nglobal |
a (non-empty) integer vector specifying size of work items for use, with default value from global option 'clrng.Nglobal'. |
type |
a character string specifying "double" or "float" of random numbers, with default value from global option 'clrng.type'. |
verbose |
a logical value, if TRUE, print extra information, default is FALSE. |
Details
type
specifies the precision type of random numbers. If GPU supports "double", 'clrng.Nglobal' is "double", otherwise, ‘clrng.Nglobal’ is "single".
Value
a 'vclVector' or 'vclMatrix' of uniform random numbers.
Examples
library('clrng')
if (detectGPUs() >= 1) {
setContext(grep("gpu", listContexts()$device_type)[1])
currentDevice()
getOption('clrng.Nglobal')
streams <- createStreamsGpu()
as.vector(runifGpu(5, streams))
# Change global options
options(clrng.type="float")
# produce a matrix of random numbers
as.matrix(runifGpu(c(2,2), streams))} else {
message("No GPU context available")
}
[Package clrng version 0.0.5 Index]