Random number stream on a GPU
Use parallel.gpu.RandStream
to control the global GPU random
number stream and create multiple independent streams on the GPU. When you generate random
numbers on a GPU, the numbers are drawn from the GPU random number stream. This stream is
different from the random stream of the client MATLAB® session on the CPU.
To create random numbers on the GPU, use the random number generator functions rand
, randi
, and randn
with gpuArrays
. By default, these functions draw
numbers from the global GPU random number stream. To use a different stream, follow the
syntaxes described in the RandStream
object functions rand
(RandStream)
, randi (RandStream)
, and randn
(RandStream)
. If you use a GPU random number stream, the results are returned as
a gpuArray
.
Use the following syntaxes to create a single parallel.gpu.RandStream
object. If you want to create multiple independent streams simultaneously, use the parallel.gpu.RandStream.create
function.
s = parallel.gpu.RandStream(
creates a random number stream that uses the uniform pseudorandom number generator
algorithm specified by 'gentype'
)'gentype'
.
s = parallel.gpu.RandStream(
also specifies one or more optional 'gentype'
,Name,Value
)Name,Value
pairs to control
properties of the stream.
parallel.gpu.RandStream.create | Create independent random number streams on a GPU |
parallel.gpu.RandStream.list | Random number generator algorithms on the GPU |
parallel.gpu.RandStream.getGlobalStream | Current global GPU random number stream |
parallel.gpu.RandStream.setGlobalStream | Set GPU global random number stream |
reset (RandStream) | Reset random number stream |
rand (RandStream) | Uniformly distributed random numbers |
randi (RandStream) | Uniformly distributed pseudorandom integers |
randn (RandStream) | Normally distributed pseudorandom numbers |
randperm (RandStream) | Random permutation |