Updated rust examples
parent
c9bc4eef58
commit
0db11da754
@ -1,7 +1,5 @@
|
||||
pub fn max_array(x: &mut[i32; 65536], y: &[i32; 65536]) {
|
||||
pub fn max_array(x: &mut[f64; 65536], y: &[f64; 65536]) {
|
||||
for i in (0..65536) {
|
||||
if y[i] > x[i] {
|
||||
x[i] = y[i];
|
||||
}
|
||||
x[i] = if y[i] > x[i] { y[i] } else { x[i] };
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
#[allow(unstable)]
|
||||
pub fn max_array(x: &mut[f64; 65536], y: &[f64; 65536]) {
|
||||
unsafe {
|
||||
std::intrinsics::assume(x.as_ptr() as usize % 64 == 0);
|
||||
std::intrinsics::assume(y.as_ptr() as usize % 64 == 0);
|
||||
}
|
||||
for i in (0..65536) {
|
||||
x[i] = if y[i] > x[i] { y[i] } else { x[i] };
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
pub fn sum_array(x: &[i32]) -> i32 {
|
||||
x.iter().fold(0, |sum, next| sum + *next)
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
#[allow(unstable)]
|
||||
pub fn sum_array(x: &[i32]) -> i32 {
|
||||
unsafe {
|
||||
std::intrinsics::assume(x.as_ptr() as usize % 64 == 0);
|
||||
}
|
||||
x.iter().fold(0, |sum, next| sum + *next)
|
||||
}
|
Loading…
Reference in New Issue