Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
turn of experiments, adjust benchmarks for now
Browse files Browse the repository at this point in the history
  • Loading branch information
shamatar committed Jan 5, 2024
1 parent a8a46ea commit b60488d
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 162 deletions.
316 changes: 158 additions & 158 deletions benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,104 +192,104 @@ fn criterion_benchmark_poseidon2_inner_statevec(c: &mut Criterion) {
// });
// }

fn criterion_benchmark_add_naive(c: &mut Criterion) {
let degree: usize = 1 << 24;
// fn criterion_benchmark_add_naive(c: &mut Criterion) {
// let degree: usize = 1 << 24;

let aa: Vec<u64> = (0..(degree * 2)).map(|x| x as u64 + 1).collect();
let bb: Vec<u64> = (0..(degree * 2)).map(|x| x as u64 + 2).collect();
let mut cc: Vec<u64> = Vec::with_capacity(degree * 2);
// let aa: Vec<u64> = (0..(degree * 2)).map(|x| x as u64 + 1).collect();
// let bb: Vec<u64> = (0..(degree * 2)).map(|x| x as u64 + 2).collect();
// let mut cc: Vec<u64> = Vec::with_capacity(degree * 2);

c.bench_function("Naive", |b| {
b.iter(|| unsafe {
boojum::experiments::naive(black_box(&aa), black_box(&bb), black_box(&mut cc))
})
});
}
// c.bench_function("Naive", |b| {
// b.iter(|| unsafe {
// boojum::experiments::naive(black_box(&aa), black_box(&bb), black_box(&mut cc))
// })
// });
// }

fn criterion_benchmark_add_vectors_naive(c: &mut Criterion) {
let degree: usize = 1 << 24;
// fn criterion_benchmark_add_vectors_naive(c: &mut Criterion) {
// let degree: usize = 1 << 24;

let mut aa: Vec<GoldilocksField> = (0..(degree * 2))
.map(|x| x as u64 + 1)
.map(GoldilocksField::from_u64_with_reduction)
.collect();
let bb: Vec<GoldilocksField> = (0..(degree * 2))
.map(|x| x as u64 + 2)
.map(GoldilocksField::from_u64_with_reduction)
.collect();
// let mut aa: Vec<GoldilocksField> = (0..(degree * 2))
// .map(|x| x as u64 + 1)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect();
// let bb: Vec<GoldilocksField> = (0..(degree * 2))
// .map(|x| x as u64 + 2)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect();

c.bench_function("Naive Vec add", |b| {
b.iter(|| boojum::experiments::vec_add_native(black_box(&mut aa), black_box(&bb)))
});
}
// c.bench_function("Naive Vec add", |b| {
// b.iter(|| boojum::experiments::vec_add_native(black_box(&mut aa), black_box(&bb)))
// });
// }

fn criterion_benchmark_add_vectors_vectorized(c: &mut Criterion) {
let degree: usize = 1 << 24;
// fn criterion_benchmark_add_vectors_vectorized(c: &mut Criterion) {
// let degree: usize = 1 << 24;

let aa: Vec<GoldilocksField> = (0..(degree * 2))
.map(|x| x as u64 + 1)
.map(GoldilocksField::from_u64_with_reduction)
.collect();
let bb: Vec<GoldilocksField> = (0..(degree * 2))
.map(|x| x as u64 + 2)
.map(GoldilocksField::from_u64_with_reduction)
.collect();
// let aa: Vec<GoldilocksField> = (0..(degree * 2))
// .map(|x| x as u64 + 1)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect();
// let bb: Vec<GoldilocksField> = (0..(degree * 2))
// .map(|x| x as u64 + 2)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect();

let mut aa = boojum::utils::cast_check_alignment(aa);
let bb = boojum::utils::cast_check_alignment(bb);
// let mut aa = boojum::utils::cast_check_alignment(aa);
// let bb = boojum::utils::cast_check_alignment(bb);

c.bench_function("Unrolled Vec add", |b| {
b.iter(|| boojum::experiments::vec_add_vectorized(black_box(&mut aa), black_box(&bb)))
});
}
// c.bench_function("Unrolled Vec add", |b| {
// b.iter(|| boojum::experiments::vec_add_vectorized(black_box(&mut aa), black_box(&bb)))
// });
// }

fn criterion_benchmark_add_vectors_simd(c: &mut Criterion) {
let degree: usize = 1 << 24;
// fn criterion_benchmark_add_vectors_simd(c: &mut Criterion) {
// let degree: usize = 1 << 24;

use boojum::experiments::GLV;
let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// use boojum::experiments::GLV;
// let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);

(0..(degree * 2))
.map(|x| x as u64 + 1)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut aa);
(0..(degree * 2))
.map(|x| x as u64 + 2)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut bb);
// (0..(degree * 2))
// .map(|x| x as u64 + 1)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut aa);
// (0..(degree * 2))
// .map(|x| x as u64 + 2)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut bb);

let mut aa = boojum::utils::cast_check_alignment(aa);
let bb = boojum::utils::cast_check_alignment(bb);
// let mut aa = boojum::utils::cast_check_alignment(aa);
// let bb = boojum::utils::cast_check_alignment(bb);

c.bench_function("SIMD Vec add", |b| {
b.iter(|| boojum::experiments::vec_add_simd(black_box(&mut aa), black_box(&bb)))
});
}
// c.bench_function("SIMD Vec add", |b| {
// b.iter(|| boojum::experiments::vec_add_simd(black_box(&mut aa), black_box(&bb)))
// });
// }

fn criterion_benchmark_add_vectors_portable_simd(c: &mut Criterion) {
let degree: usize = 1 << 24;
// fn criterion_benchmark_add_vectors_portable_simd(c: &mut Criterion) {
// let degree: usize = 1 << 24;

use boojum::experiments::GLV;
let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// use boojum::experiments::GLV;
// let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);

(0..(degree * 2))
.map(|x| x as u64 + 1)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut aa);
(0..(degree * 2))
.map(|x| x as u64 + 2)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut bb);
// (0..(degree * 2))
// .map(|x| x as u64 + 1)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut aa);
// (0..(degree * 2))
// .map(|x| x as u64 + 2)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut bb);

let mut aa = boojum::utils::cast_check_alignment(aa);
let bb = boojum::utils::cast_check_alignment(bb);
// let mut aa = boojum::utils::cast_check_alignment(aa);
// let bb = boojum::utils::cast_check_alignment(bb);

c.bench_function("Portable SIMD Vec add", |b| {
b.iter(|| boojum::experiments::vec_add_portable_simd(black_box(&mut aa), black_box(&bb)))
});
}
// c.bench_function("Portable SIMD Vec add", |b| {
// b.iter(|| boojum::experiments::vec_add_portable_simd(black_box(&mut aa), black_box(&bb)))
// });
// }

use boojum::utils::clone_respecting_allignment;

Expand Down Expand Up @@ -350,99 +350,99 @@ fn criterion_benchmark_mul_vectors_naive(c: &mut Criterion) {
});
}

fn criterion_benchmark_mul_vectors_vectorized(c: &mut Criterion) {
let degree: usize = 1 << 24;

let aa: Vec<GoldilocksField> = (0..(degree * 2))
.map(|x| x as u64 + 1)
.map(GoldilocksField::from_u64_with_reduction)
.collect();
let bb: Vec<GoldilocksField> = (0..(degree * 2))
.map(|x| x as u64 + 2)
.map(GoldilocksField::from_u64_with_reduction)
.collect();

let mut aa = boojum::utils::cast_check_alignment(aa);
let bb = boojum::utils::cast_check_alignment(bb);
// fn criterion_benchmark_mul_vectors_vectorized(c: &mut Criterion) {
// let degree: usize = 1 << 24;

c.bench_function("Unrolled Vec mul", |b| {
b.iter(|| boojum::experiments::vec_mul_vectorized(black_box(&mut aa), black_box(&bb)))
});
}
// let aa: Vec<GoldilocksField> = (0..(degree * 2))
// .map(|x| x as u64 + 1)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect();
// let bb: Vec<GoldilocksField> = (0..(degree * 2))
// .map(|x| x as u64 + 2)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect();

fn criterion_benchmark_mul_vectors_simd(c: &mut Criterion) {
let degree: usize = 1 << 24;
// let mut aa = boojum::utils::cast_check_alignment(aa);
// let bb = boojum::utils::cast_check_alignment(bb);

use boojum::experiments::GLV;
let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// c.bench_function("Unrolled Vec mul", |b| {
// b.iter(|| boojum::experiments::vec_mul_vectorized(black_box(&mut aa), black_box(&bb)))
// });
// }

(0..(degree * 2))
.map(|x| x as u64 + 1)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut aa);
(0..(degree * 2))
.map(|x| x as u64 + 2)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut bb);
// fn criterion_benchmark_mul_vectors_simd(c: &mut Criterion) {
// let degree: usize = 1 << 24;

let mut aa = boojum::utils::cast_check_alignment(aa);
let bb = boojum::utils::cast_check_alignment(bb);
// use boojum::experiments::GLV;
// let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);

c.bench_function("SIMD Vec mul", |b| {
b.iter(|| boojum::experiments::vec_mul_simd(black_box(&mut aa), black_box(&bb)))
});
}
// (0..(degree * 2))
// .map(|x| x as u64 + 1)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut aa);
// (0..(degree * 2))
// .map(|x| x as u64 + 2)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut bb);

fn criterion_benchmark_mul_vectors_portable_simd_long(c: &mut Criterion) {
let degree: usize = 1 << 24;
// let mut aa = boojum::utils::cast_check_alignment(aa);
// let bb = boojum::utils::cast_check_alignment(bb);

use boojum::experiments::GLV;
let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);

(0..(degree * 2))
.map(|x| x as u64 + 1)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut aa);
(0..(degree * 2))
.map(|x| x as u64 + 2)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut bb);

let mut aa = boojum::utils::cast_check_alignment(aa);
let bb = boojum::utils::cast_check_alignment(bb);
// c.bench_function("SIMD Vec mul", |b| {
// b.iter(|| boojum::experiments::vec_mul_simd(black_box(&mut aa), black_box(&bb)))
// });
// }

c.bench_function("Portable SIMD long Vec mul", |b| {
b.iter(|| {
boojum::experiments::vec_mul_portable_simd_long(black_box(&mut aa), black_box(&bb))
})
});
}
// fn criterion_benchmark_mul_vectors_portable_simd_long(c: &mut Criterion) {
// let degree: usize = 1 << 24;

// use boojum::experiments::GLV;
// let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);

// (0..(degree * 2))
// .map(|x| x as u64 + 1)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut aa);
// (0..(degree * 2))
// .map(|x| x as u64 + 2)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut bb);

// let mut aa = boojum::utils::cast_check_alignment(aa);
// let bb = boojum::utils::cast_check_alignment(bb);

// c.bench_function("Portable SIMD long Vec mul", |b| {
// b.iter(|| {
// boojum::experiments::vec_mul_portable_simd_long(black_box(&mut aa), black_box(&bb))
// })
// });
// }

fn criterion_benchmark_mul_vectors_portable_simd(c: &mut Criterion) {
let degree: usize = 1 << 24;
// fn criterion_benchmark_mul_vectors_portable_simd(c: &mut Criterion) {
// let degree: usize = 1 << 24;

use boojum::experiments::GLV;
let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// use boojum::experiments::GLV;
// let mut aa = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);
// let mut bb = boojum::utils::allocate_with_alignment_of::<GoldilocksField, GLV>(degree * 2);

(0..(degree * 2))
.map(|x| x as u64 + 1)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut aa);
(0..(degree * 2))
.map(|x| x as u64 + 2)
.map(GoldilocksField::from_u64_with_reduction)
.collect_into(&mut bb);
// (0..(degree * 2))
// .map(|x| x as u64 + 1)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut aa);
// (0..(degree * 2))
// .map(|x| x as u64 + 2)
// .map(GoldilocksField::from_u64_with_reduction)
// .collect_into(&mut bb);

let mut aa = boojum::utils::cast_check_alignment(aa);
let bb = boojum::utils::cast_check_alignment(bb);
// let mut aa = boojum::utils::cast_check_alignment(aa);
// let bb = boojum::utils::cast_check_alignment(bb);

c.bench_function("Portable SIMD Vec mul", |b| {
b.iter(|| boojum::experiments::vec_mul_portable_simd(black_box(&mut aa), black_box(&bb)))
});
}
// c.bench_function("Portable SIMD Vec mul", |b| {
// b.iter(|| boojum::experiments::vec_mul_portable_simd(black_box(&mut aa), black_box(&bb)))
// });
// }

fn criterion_benchmark_mul_vectors_mixedgl(c: &mut Criterion) {
let degree: usize = 1 << 24;
Expand Down
3 changes: 2 additions & 1 deletion src/dag/resolver_box.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::log;
use std::{intrinsics::size_of, marker::PhantomData};
use std::marker::PhantomData;
use std::mem::size_of;

use crate::{
cs::{traits::cs::DstBuffer, Place},
Expand Down
4 changes: 2 additions & 2 deletions src/experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::ops::Shl;
use std::ops::Shr;
use std::ops::Sub;

// use std::simd::num::*;
// use std::simd::cmp::*;
use std::simd::num::*;
use std::simd::cmp::*;
use packed_simd::FromCast;

use crate::field::{goldilocks::GoldilocksField, Field};
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub use sha2;
pub use sha3;

// #[cfg(target_arch = "aarch64")]
pub mod experiments;
// pub mod experiments;

pub mod log_utils;

Expand Down

0 comments on commit b60488d

Please sign in to comment.