@@ -9,7 +9,7 @@ macro_rules! ignore_snd (
99
1010macro_rules! impl_rand_auto_simd (
1111 ( $( $t: ty, $( $i: ident) ,* ; ) * ) => ( $(
12- impl rand:: distributions :: Distribution <AutoSimd <$t>> for rand:: distributions :: Standard {
12+ impl rand:: distr :: Distribution <AutoSimd <$t>> for rand:: distr :: StandardUniform {
1313 #[ inline( always) ]
1414 fn sample<R : rand:: Rng + ?Sized >( & self , rng: & mut R ) -> AutoSimd <$t> {
1515 AutoSimd :: <$t>:: new( $(
@@ -49,9 +49,6 @@ impl_rand_auto_simd!(
4949 [ i8 ; 16 ] , _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
5050 [ i8 ; 32 ] , _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31;
5151 // [i8; 64], _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63;
52- [ isize ; 2 ] , _0, _1;
53- [ isize ; 4 ] , _0, _1, _2, _3;
54- [ isize ; 8 ] , _0, _1, _2, _3, _4, _5, _6, _7;
5552 [ u128 ; 1 ] , _0;
5653 [ u128 ; 2 ] , _0, _1;
5754 [ u128 ; 4 ] , _0, _1, _2, _3;
@@ -73,9 +70,6 @@ impl_rand_auto_simd!(
7370 [ u8 ; 16 ] , _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
7471 [ u8 ; 32 ] , _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31;
7572 // [u8; 64], _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63;
76- [ usize ; 2 ] , _0, _1;
77- [ usize ; 4 ] , _0, _1, _2, _3;
78- [ usize ; 8 ] , _0, _1, _2, _3, _4, _5, _6, _7;
7973 [ bool ; 1 ] , _0;
8074 [ bool ; 2 ] , _0, _1;
8175 [ bool ; 4 ] , _0, _1, _2, _3;
@@ -85,10 +79,32 @@ impl_rand_auto_simd!(
8579 // [bool; 64], _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63;
8680) ;
8781
82+ macro_rules! impl_rand_auto_simd_xsize (
83+ ( $( $t: ty, $sampler: ident, $( $i: ident) ,* ; ) * ) => ( $(
84+ impl rand:: distr:: Distribution <AutoSimd <$t>> for rand:: distr:: StandardUniform {
85+ #[ inline( always) ]
86+ fn sample<R : rand:: Rng + ?Sized >( & self , rng: & mut R ) -> AutoSimd <$t> {
87+ AutoSimd :: <$t>:: new( $(
88+ ignore_snd!( [ $sampler( rng) ] , [ $i] )
89+ ) ,* )
90+ }
91+ }
92+ ) * )
93+ ) ;
94+
95+ impl_rand_auto_simd_xsize ! (
96+ [ isize ; 2 ] , sample_isize, _0, _1;
97+ [ isize ; 4 ] , sample_isize, _0, _1, _2, _3;
98+ [ isize ; 8 ] , sample_isize, _0, _1, _2, _3, _4, _5, _6, _7;
99+ [ usize ; 2 ] , sample_usize, _0, _1;
100+ [ usize ; 4 ] , sample_usize, _0, _1, _2, _3;
101+ [ usize ; 8 ] , sample_usize, _0, _1, _2, _3, _4, _5, _6, _7;
102+ ) ;
103+
88104#[ cfg( feature = "wide" ) ]
89105macro_rules! impl_rand_wide_simd (
90106 ( $( $t: ident, $wrapped: ty, $arr: ty; ) * ) => ( $(
91- impl rand:: distributions :: Distribution <$t> for rand:: distributions :: Standard {
107+ impl rand:: distr :: Distribution <$t> for rand:: distr :: StandardUniform {
92108 #[ inline( always) ]
93109 fn sample<R : rand:: Rng + ?Sized >( & self , rng: & mut R ) -> $t {
94110 $t( <$wrapped as From <$arr>>:: from( self . sample( rng) ) )
@@ -107,7 +123,7 @@ impl_rand_wide_simd!(
107123#[ cfg( feature = "portable_simd" ) ]
108124macro_rules! impl_rand_portable_simd (
109125 ( $( $wrapped: ty, $( $i: ident) ,* ; ) * ) => ( $(
110- impl rand:: distributions :: Distribution <$wrapped> for rand:: distributions :: Standard {
126+ impl rand:: distr :: Distribution <$wrapped> for rand:: distr :: StandardUniform {
111127 #[ inline( always) ]
112128 fn sample<R : rand:: Rng + ?Sized >( & self , rng: & mut R ) -> $wrapped {
113129 <$wrapped>:: new( $(
@@ -145,9 +161,6 @@ impl_rand_portable_simd!(
145161 i8x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
146162 i8x32, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31;
147163 i8x64, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63;
148- isizex2, _0, _1;
149- isizex4, _0, _1, _2, _3;
150- isizex8, _0, _1, _2, _3, _4, _5, _6, _7;
151164 u16x2, _0, _1;
152165 u16x4, _0, _1, _2, _3;
153166 u16x8, _0, _1, _2, _3, _4, _5, _6, _7;
@@ -166,9 +179,6 @@ impl_rand_portable_simd!(
166179 u8x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
167180 u8x32, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31;
168181 u8x64, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63;
169- usizex2, _0, _1;
170- usizex4, _0, _1, _2, _3;
171- usizex8, _0, _1, _2, _3, _4, _5, _6, _7;
172182 mask16x2, _0, _1;
173183 mask16x4, _0, _1, _2, _3;
174184 mask16x8, _0, _1, _2, _3, _4, _5, _6, _7;
@@ -191,3 +201,41 @@ impl_rand_portable_simd!(
191201 masksizex4, _0, _1, _2, _3;
192202 masksizex8, _0, _1, _2, _3, _4, _5, _6, _7;
193203) ;
204+
205+ #[ cfg( feature = "portable_simd" ) ]
206+ macro_rules! impl_rand_portable_simd_xsize (
207+ ( $( $wrapped: ty, $sampler: ident, $( $i: ident) ,* ; ) * ) => ( $(
208+ impl rand:: distr:: Distribution <$wrapped> for rand:: distr:: StandardUniform {
209+ #[ inline( always) ]
210+ fn sample<R : rand:: Rng + ?Sized >( & self , rng: & mut R ) -> $wrapped {
211+ <$wrapped>:: new( $(
212+ ignore_snd!( [ $sampler( rng) ] , [ $i] )
213+ ) ,* )
214+ }
215+ }
216+ ) * )
217+ ) ;
218+
219+ #[ cfg( feature = "portable_simd" ) ]
220+ impl_rand_portable_simd_xsize ! (
221+ isizex2, sample_isize, _0, _1;
222+ isizex4, sample_isize, _0, _1, _2, _3;
223+ isizex8, sample_isize, _0, _1, _2, _3, _4, _5, _6, _7;
224+ usizex2, sample_usize, _0, _1;
225+ usizex4, sample_usize, _0, _1, _2, _3;
226+ usizex8, sample_usize, _0, _1, _2, _3, _4, _5, _6, _7;
227+ ) ;
228+
229+ #[ inline( always) ]
230+ fn sample_isize < R : rand:: Rng + ?Sized > ( rng : & mut R ) -> isize {
231+ let mut bytes = [ 0u8 ; _] ;
232+ rng. fill_bytes ( & mut bytes) ;
233+ isize:: from_le_bytes ( bytes)
234+ }
235+
236+ #[ inline( always) ]
237+ fn sample_usize < R : rand:: Rng + ?Sized > ( rng : & mut R ) -> usize {
238+ let mut bytes = [ 0u8 ; _] ;
239+ rng. fill_bytes ( & mut bytes) ;
240+ usize:: from_le_bytes ( bytes)
241+ }
0 commit comments