pub struct CudaRng { /* private fields */ }
Expand description
Host side RNG that can fill CudaSlice with random values.
- Create:
let device = CudaDevice::new(0).unwrap();
let rng = CudaRng::new(0, device).unwrap();
- Fill device memory:
let mut a_dev = device.alloc_zeros::<f32>(10).unwrap();
rng.fill_with_uniform(&mut a_dev).unwrap();
The three distributions are:
- Uniform - CudaRng::fill_with_uniform()
- Normal - CudaRng::fill_with_normal()
- LogNormal - CudaRng::fill_with_log_normal()
Implementations§
source§impl CudaRng
impl CudaRng
sourcepub fn new(seed: u64, device: Arc<CudaDevice>) -> Result<Self, CurandError>
pub fn new(seed: u64, device: Arc<CudaDevice>) -> Result<Self, CurandError>
Constructs the RNG with the given seed
. Requires the stream from CudaDevice to submit kernels.
pub fn set_offset(&mut self, offset: u64) -> Result<(), CurandError>
sourcepub fn fill_with_uniform<T>(
&self,
t: &mut CudaSlice<T>,
) -> Result<(), CurandError>where
curandGenerator_t: UniformFill<T>,
pub fn fill_with_uniform<T>(
&self,
t: &mut CudaSlice<T>,
) -> Result<(), CurandError>where
curandGenerator_t: UniformFill<T>,
Fill the CudaSlice with data from a Uniform
distribution
sourcepub fn fill_with_normal<T>(
&self,
t: &mut CudaSlice<T>,
mean: T,
std: T,
) -> Result<(), CurandError>where
curandGenerator_t: NormalFill<T>,
pub fn fill_with_normal<T>(
&self,
t: &mut CudaSlice<T>,
mean: T,
std: T,
) -> Result<(), CurandError>where
curandGenerator_t: NormalFill<T>,
Fill the CudaSlice with data from a Normal(mean, std)
distribution.
sourcepub fn fill_with_log_normal<T>(
&self,
t: &mut CudaSlice<T>,
mean: T,
std: T,
) -> Result<(), CurandError>where
curandGenerator_t: LogNormalFill<T>,
pub fn fill_with_log_normal<T>(
&self,
t: &mut CudaSlice<T>,
mean: T,
std: T,
) -> Result<(), CurandError>where
curandGenerator_t: LogNormalFill<T>,
Fill the CudaRc
with data from a LogNormal(mean, std)
distribution.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CudaRng
impl RefUnwindSafe for CudaRng
impl !Send for CudaRng
impl !Sync for CudaRng
impl Unpin for CudaRng
impl UnwindSafe for CudaRng
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more