Main Content

parallel.gpu.RandStream.getGlobalStream

Current global GPU random number stream

Description

example

stream = parallel.gpu.RandStream.getGlobalStream returns the current global random number stream on the GPU.

Note

The gpurng function is a more concise alternative for many uses of parallel.gpu.RandStream.setGlobalStream.

Examples

collapse all

Use parallel.gpu.RandStream.getGlobalStream to save the default stream settings.

defaultStr = parallel.gpu.RandStream.getGlobalStream
defaultStr =

Threefry4x64_20 random stream on the GPU (current global stream)
             Seed: 0
  NormalTransform: BoxMuller

If you change the global stream, you can use the stream defaultStr to restore the default settings. For example, suppose that you change the global stream to a different stream.

newStr = parallel.gpu.RandStream('CombRecursive', 'NormalTransform','Inversion');
defaultStr = parallel.gpu.RandStream.setGlobalStream(newStr)
defaultStr =

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

defaultStr is no longer the current global GPU stream. Once you finish your calculations using the new global stream settings, you can reset the stream to the default settings.

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

MRG32K3A random stream on the GPU
             Seed: 0
  NormalTransform: Inversion
defaultStr
defaultStr =

Threefry4x64_20 random stream on the GPU (current global stream)
             Seed: 0
  NormalTransform: BoxMuller

defaultStr is once again the current global stream.

Output Arguments

collapse all

Global random number stream for generating random numbers on a GPU, returned as a parallel.gpu.RandStream object.

Introduced in R2011b