Main Content

parallel.gpu.RandStream.setGlobalStream

Set GPU global random number stream

Description

prevStream = parallel.gpu.RandStream.setGlobalStream(stream) replaces the global random number stream with the stream specified by stream.

example

Examples

collapse all

You can change the global random number stream on the GPU and store the old settings for the global stream. First, define the random number stream that you want to set as the new global stream.

newStr = parallel.gpu.RandStream('Philox','Seed',1, ...
    'NormalTransform','Inversion')
newStr =

Philox4x32_10 random stream on the GPU
             Seed: 1
  NormalTransform: Inversion

Next, set this new stream to be the global stream.

oldStr = parallel.gpu.RandStream.setGlobalStream(newStr)
oldStr =

Threefry4x64_20 random stream on the GPU
             Seed: 0
  NormalTransform: BoxMuller

oldStr holds the settings for the previous global random number stream on the GPU. The new global stream is newStr.

newStr
newStr =

Philox4x32_10 random stream on the GPU (current global stream)
             Seed: 1
  NormalTransform: Inversion
On a GPU, the functions rand, randi, and randn draw random numbers from the new global stream using the 'Philox' generator algorithm.

Input Arguments

collapse all

New global random number stream on the GPU, specified as a parallel.gpu.RandStream object. stream replaces the previous global stream.

Output Arguments

collapse all

Previous global random number stream on the GPU, specified as a parallel.gpu.RandStream object.

Version History

Introduced in R2011b