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) {
128
128
while i < N {
129
129
let d2s = f64x2:: from_array ( [ ( r[ i] * r[ i] ) . horizontal_sum ( ) , ( r[ i + 1 ] * r[ i + 1 ] ) . horizontal_sum ( ) ] ) ;
130
130
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 ] ;
132
134
i += 2 ;
133
135
}
134
136
@@ -146,6 +148,12 @@ pub fn advance(bodies: &mut [Body; N_BODIES], dt: f64) {
146
148
}
147
149
}
148
150
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
+
149
157
pub fn run ( n : usize ) -> ( f64 , f64 ) {
150
158
let mut bodies = BODIES ;
151
159
offset_momentum ( & mut bodies) ;
@@ -158,7 +166,7 @@ pub fn run(n: usize) -> (f64, f64) {
158
166
( energy_before, energy_after)
159
167
}
160
168
161
- const OUTPUT : Vec < f64 > = vec ! [ -0.169075164 , -0.169087605 ] ;
169
+ const OUTPUT : [ f64 ; 2 ] = [ -0.169075164 , -0.169087605 ] ;
162
170
#[ cfg( test) ]
163
171
mod tests {
164
172
#[ test]
@@ -172,6 +180,8 @@ mod tests {
172
180
}
173
181
}
174
182
}
183
+
184
+
175
185
fn main ( ) {
176
186
//let n: usize = std::env::args()
177
187
//.nth(1)
You can’t perform that action at this time.
0 commit comments