File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
crates/core_simd/examples Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,9 @@ pub fn advance(bodies: &mut [Body; N_BODIES], dt: f64) {
128128 while i < N {
129129 let d2s = f64x2:: from_array ( [ ( r[ i] * r[ i] ) . horizontal_sum ( ) , ( r[ i + 1 ] * r[ i + 1 ] ) . horizontal_sum ( ) ] ) ;
130130 let dmags = f64x2:: splat ( dt) / ( d2s * d2s. sqrt ( ) ) ;
131- dmags. write_to_slice_unaligned ( & mut mag[ i..] ) ;
131+ // dmags.write_to_slice_unaligned(&mut mag[i..]);
132+ mag[ i] = dmags[ 0 ] ;
133+ mag[ i+1 ] = dmags[ 1 ] ;
132134 i += 2 ;
133135 }
134136
@@ -146,6 +148,12 @@ pub fn advance(bodies: &mut [Body; N_BODIES], dt: f64) {
146148 }
147149}
148150
151+ // #[inline]
152+ // pub unsafe fn write_to_slice_unaligned(slice: &mut SimdF64::<LANES>) {
153+ // let target_ptr = slice.get_unchecked_mut(0) as *mut f64x2;
154+ // *(target_ptr as *mut f64x2) = SimdF64;
155+ // }
156+
149157pub fn run ( n : usize ) -> ( f64 , f64 ) {
150158 let mut bodies = BODIES ;
151159 offset_momentum ( & mut bodies) ;
@@ -158,7 +166,7 @@ pub fn run(n: usize) -> (f64, f64) {
158166 ( energy_before, energy_after)
159167}
160168
161- const OUTPUT : Vec < f64 > = vec ! [ -0.169075164 , -0.169087605 ] ;
169+ const OUTPUT : [ f64 ; 2 ] = [ -0.169075164 , -0.169087605 ] ;
162170#[ cfg( test) ]
163171mod tests {
164172 #[ test]
@@ -172,6 +180,8 @@ mod tests {
172180 }
173181 }
174182}
183+
184+
175185fn main ( ) {
176186 //let n: usize = std::env::args()
177187 //.nth(1)
You can’t perform that action at this time.
0 commit comments