Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions benches/benches/builder/grid_size.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::hint::black_box;

use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use honeycomb::prelude::{CMap2, CMapBuilder};
use honeycomb::prelude::{CMap2, grid_generation::GridBuilder};

use honeycomb_benches::utils::FloatType;

Expand All @@ -13,17 +13,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
group.throughput(Throughput::Elements(size.pow(2))); // throughoutput = number of cells
group.bench_with_input(BenchmarkId::new("unit-squares", ""), &size, |b, size| {
b.iter(|| {
let mut map: CMap2<FloatType> = CMapBuilder::<2, _>::unit_grid(*size as usize)
.build()
.unwrap();
let mut map: CMap2<FloatType> =
GridBuilder::<2, FloatType>::unit_grid(*size as usize);
black_box(&mut map);
})
});
group.bench_with_input(BenchmarkId::new("unit-triangles", ""), &size, |b, size| {
b.iter(|| {
let mut map: CMap2<FloatType> = CMapBuilder::<2, _>::unit_triangles(*size as usize)
.build()
.unwrap();
let mut map: CMap2<FloatType> =
GridBuilder::<2, FloatType>::unit_triangles(*size as usize);
black_box(&mut map);
})
});
Expand Down
9 changes: 3 additions & 6 deletions benches/benches/builder/time.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::hint::black_box;

use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use honeycomb::prelude::{CMap2, CMapBuilder};
use honeycomb::prelude::{CMap2, grid_generation::GridBuilder};

use honeycomb_benches::utils::FloatType;

Expand All @@ -16,16 +16,13 @@ pub fn criterion_benchmark(c: &mut Criterion) {

group.bench_with_input(BenchmarkId::new("unit-squares", ""), &(), |b, _| {
b.iter(|| {
let mut map: CMap2<FloatType> =
CMapBuilder::<2, _>::unit_grid(n_square).build().unwrap();
let mut map: CMap2<FloatType> = GridBuilder::<2, _>::unit_grid(n_square);
black_box(&mut map);
})
});
group.bench_with_input(BenchmarkId::new("unit-triangles", ""), &(), |b, _| {
b.iter(|| {
let mut map: CMap2<FloatType> = CMapBuilder::<2, _>::unit_triangles(n_square)
.build()
.unwrap();
let mut map: CMap2<FloatType> = GridBuilder::<2, _>::unit_triangles(n_square);
black_box(&mut map);
})
});
Expand Down
20 changes: 7 additions & 13 deletions benches/benches/core/cmap2/basic_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::hint::black_box;

use honeycomb::{
core::cmap::DartReservationError,
prelude::{CMap2, CMapBuilder, DartIdType, Vertex2},
prelude::{CMap2, CMapBuilder, DartIdType, Vertex2, grid_generation::GridBuilder},
};
use iai_callgrind::{
Callgrind, FlamegraphConfig, LibraryBenchmarkConfig, library_benchmark,
Expand All @@ -25,15 +25,11 @@ use honeycomb_benches::utils::FloatType;
// --- common

fn get_map(n_square: usize) -> CMap2<FloatType> {
CMapBuilder::<2, FloatType>::unit_grid(n_square)
.build()
.unwrap()
GridBuilder::<2, FloatType>::unit_grid(n_square)
}

fn get_sparse_map(n_square: usize) -> CMap2<FloatType> {
let mut map = CMapBuilder::<2, FloatType>::unit_grid(n_square)
.build()
.unwrap();
let map = GridBuilder::<2, FloatType>::unit_grid(n_square);
map.set_betas(5, [0; 3]); // free dart 5
map.release_dart(5).unwrap();
// because of the way we built the map in the square_cmap2 function & the ID computation
Expand All @@ -47,9 +43,7 @@ fn get_sparse_map(n_square: usize) -> CMap2<FloatType> {

fn get_empty_map(n_squares: usize) -> (CMap2<FloatType>, usize) {
(
CMapBuilder::<2, FloatType>::from_n_darts(0)
.build()
.unwrap(),
CMapBuilder::<2>::from_n_darts(0).build().unwrap(),
n_squares.pow(2) * 4,
)
}
Expand Down Expand Up @@ -79,9 +73,9 @@ fn insert_dart_full(map: &mut CMap2<FloatType>) -> DartReservationError {
}

#[library_benchmark]
#[bench::small(&mut CMapBuilder::<2, FloatType>::from_n_darts(16_usize.pow(2) * 4).build().unwrap())]
#[bench::medium(&mut CMapBuilder::<2, FloatType>::from_n_darts(64_usize.pow(2) * 4).build().unwrap())]
#[bench::large(&mut CMapBuilder::<2, FloatType>::from_n_darts(256_usize.pow(2) * 4).build().unwrap())]
#[bench::small(&mut CMapBuilder::<2>::from_n_darts(16_usize.pow(2) * 4).build().unwrap())]
#[bench::medium(&mut CMapBuilder::<2>::from_n_darts(64_usize.pow(2) * 4).build().unwrap())]
#[bench::large(&mut CMapBuilder::<2>::from_n_darts(256_usize.pow(2) * 4).build().unwrap())]
fn remove_dart(map: &mut CMap2<FloatType>) {
map.release_dart(5).unwrap();
black_box(map);
Expand Down
19 changes: 8 additions & 11 deletions benches/benches/core/cmap2/constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

use std::hint::black_box;

use honeycomb::core::cmap::{CMap2, CMapBuilder};
use honeycomb::{
core::cmap::{CMap2, CMapBuilder},
prelude::grid_generation::GridBuilder,
};
use iai_callgrind::{
Callgrind, FlamegraphConfig, LibraryBenchmarkConfig, library_benchmark,
library_benchmark_group, main,
Expand All @@ -24,9 +27,7 @@ use honeycomb_benches::utils::FloatType;
// --- common

fn get_map(n_square: usize) -> CMap2<FloatType> {
CMapBuilder::<2, FloatType>::unit_grid(n_square)
.build()
.unwrap()
GridBuilder::<2, FloatType>::unit_grid(n_square)
}

// --- constructor group
Expand All @@ -35,7 +36,7 @@ fn get_map(n_square: usize) -> CMap2<FloatType> {
#[benches::with_setup(args = [16, 32, 64, 128, 256, 512])]
fn new(n_squares: usize) -> CMap2<FloatType> {
black_box(
CMapBuilder::<2, FloatType>::from_n_darts(n_squares.pow(2) * 4)
CMapBuilder::<2>::from_n_darts(n_squares.pow(2) * 4)
.build()
.unwrap(),
)
Expand All @@ -44,17 +45,13 @@ fn new(n_squares: usize) -> CMap2<FloatType> {
#[library_benchmark]
#[benches::with_setup(args = [16, 32, 64, 128, 256, 512])]
fn grid(n_squares: usize) -> CMap2<FloatType> {
black_box(CMapBuilder::<2, _>::unit_grid(n_squares).build().unwrap())
black_box(GridBuilder::<2, _>::unit_grid(n_squares))
}

#[library_benchmark]
#[benches::with_setup(args = [16, 32, 64, 128, 256, 512])]
fn tet_grid(n_squares: usize) -> CMap2<FloatType> {
black_box(
CMapBuilder::<2, _>::unit_triangles(n_squares)
.build()
.unwrap(),
)
black_box(GridBuilder::<2, _>::unit_triangles(n_squares))
}

library_benchmark_group!(
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/core/cmap2/fetch_icells.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::hint::black_box;

use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use honeycomb::core::cmap::{CMap2, CMapBuilder};
use honeycomb::{core::cmap::CMap2, prelude::grid_generation::GridBuilder};

use honeycomb_benches::utils::FloatType;

pub fn criterion_benchmark(c: &mut Criterion) {
let n_square = 512;
let map: CMap2<FloatType> = CMapBuilder::<2, _>::unit_grid(n_square).build().unwrap();
let map: CMap2<FloatType> = GridBuilder::<2, _>::unit_grid(n_square);

let mut group = c.benchmark_group("fetch-icells");

Expand Down
13 changes: 7 additions & 6 deletions benches/benches/core/cmap2/link_and_sew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

use std::hint::black_box;

use honeycomb::core::cmap::{CMap2, CMapBuilder};
use honeycomb::{
core::cmap::{CMap2, CMapBuilder},
prelude::grid_generation::GridBuilder,
};
use iai_callgrind::{
Callgrind, FlamegraphConfig, LibraryBenchmarkConfig, library_benchmark,
library_benchmark_group, main,
Expand All @@ -23,19 +26,17 @@ use honeycomb_benches::utils::FloatType;
// --- common

fn get_map(n_square: usize) -> CMap2<FloatType> {
CMapBuilder::<2, FloatType>::unit_grid(n_square)
.build()
.unwrap()
GridBuilder::<2, FloatType>::unit_grid(n_square)
}

fn get_link_map(n_square: usize) -> CMap2<FloatType> {
CMapBuilder::<2, FloatType>::from_n_darts(n_square.pow(2) * 4)
CMapBuilder::<2>::from_n_darts(n_square.pow(2) * 4)
.build()
.unwrap()
}

fn get_sew_map(n_square: usize) -> CMap2<FloatType> {
let map = CMapBuilder::<2, FloatType>::from_n_darts(n_square.pow(2) * 4)
let map = CMapBuilder::<2>::from_n_darts(n_square.pow(2) * 4)
.build()
.unwrap();
map.force_write_vertex(4, (0.0, 0.0));
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/triangulate/quads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use honeycomb_benches::utils::FloatType;
const PATH: &str = "../examples/quads.vtk";

fn fan_bench() -> Result<(), TriangulateError> {
let mut map: CMap2<FloatType> = CMapBuilder::<2, _>::from_vtk_file(PATH).build().unwrap();
let mut map: CMap2<FloatType> = CMapBuilder::<2>::from_vtk_file(PATH).build().unwrap();

// prealloc darts
let faces: Vec<_> = map.iter_faces().collect();
Expand Down Expand Up @@ -48,7 +48,7 @@ fn fan_bench() -> Result<(), TriangulateError> {
}

fn earclip_bench() -> Result<(), TriangulateError> {
let mut map: CMap2<FloatType> = CMapBuilder::<2, _>::from_vtk_file(PATH).build().unwrap();
let mut map: CMap2<FloatType> = CMapBuilder::<2>::from_vtk_file(PATH).build().unwrap();

// prealloc darts
let faces: Vec<_> = map.iter_faces().collect();
Expand Down
8 changes: 2 additions & 6 deletions benches/src/cut_edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ pub fn bench_cut_edges<T: CoordsFloat>(args: CutEdgesArgs) -> CMap2<T> {
let input_hash = hash_file(input_map).expect("E: could not compute input hash"); // file id for posterity

let mut map: CMap2<T> = if input_map.ends_with(".cmap") {
CMapBuilder::<2, _>::from_cmap_file(input_map)
.build()
.unwrap()
CMapBuilder::<2>::from_cmap_file(input_map).build().unwrap()
} else if input_map.ends_with(".vtk") {
CMapBuilder::<2, _>::from_vtk_file(input_map)
.build()
.unwrap()
CMapBuilder::<2>::from_vtk_file(input_map).build().unwrap()
} else {
panic!(
"E: Unknown file format; only .cmap or .vtk files are supported for map initialization"
Expand Down
8 changes: 3 additions & 5 deletions benches/src/grid_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::time::{Duration, Instant};

use honeycomb::{
core::stm::atomically_with_err,
prelude::{CMap2, CMapBuilder, CoordsFloat, DartIdType, GridDescriptor, OrbitPolicy},
prelude::{CMap2, CoordsFloat, DartIdType, OrbitPolicy, grid_generation::GridBuilder},
};
use rand::{
SeedableRng,
Expand All @@ -19,12 +19,10 @@ use rayon::prelude::*;
use crate::cli::{Generate2dGridArgs, Split};

pub fn bench_generate_2d_grid<T: CoordsFloat>(args: Generate2dGridArgs) -> CMap2<T> {
let descriptor = GridDescriptor::<2, T>::default()
let mut map = GridBuilder::<2, T>::default()
.n_cells([args.nx.get(), args.ny.get()])
.len_per_cell([T::from(args.lx).unwrap(), T::from(args.ly).unwrap()])
.split_cells(args.split.is_some_and(|s| s == Split::Uniform));

let mut map = CMapBuilder::from_grid_descriptor(descriptor)
.split_cells(args.split.is_some_and(|s| s == Split::Uniform))
.build()
.unwrap();

Expand Down
8 changes: 2 additions & 6 deletions benches/src/shift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ pub fn bench_shift<T: CoordsFloat>(args: ShiftArgs) -> CMap2<T> {
let input_map = args.input.to_str().unwrap();
let input_hash = hash_file(input_map).unwrap();
let map: CMap2<T> = if input_map.ends_with(".cmap") {
CMapBuilder::<2, T>::from_cmap_file(input_map)
.build()
.unwrap()
CMapBuilder::<2>::from_cmap_file(input_map).build().unwrap()
} else if input_map.ends_with(".vtk") {
CMapBuilder::<2, T>::from_vtk_file(input_map)
.build()
.unwrap()
CMapBuilder::<2>::from_vtk_file(input_map).build().unwrap()
} else {
panic!(
"E: Unknown file format; only .cmap or .vtk files are supported for map initialization"
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/io/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
let args: Vec<String> = env::args().collect();

if let Some(path) = args.get(1) {
let map: CMap2<f32> = match CMapBuilder::<2, f32>::from_vtk_file(path).build() {
let map: CMap2<f32> = match CMapBuilder::<2>::from_vtk_file(path).build() {
Ok(cmap) => cmap,
Err(e) => panic!("Error while building map: {e:?}"),
};
Expand Down
5 changes: 3 additions & 2 deletions examples/examples/io/write.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::time::Instant;

use honeycomb_core::cmap::{CMap2, CMapBuilder, DartIdType};
use honeycomb_core::cmap::{CMap2, DartIdType};
use honeycomb_kernels::grid_generation::GridBuilder;
use rand::{
SeedableRng,
distr::{Bernoulli, Distribution},
Expand All @@ -15,7 +16,7 @@ fn main() {

println!("I: Start map initialization...");
let now = Instant::now();
let mut map: CMap2<f32> = CMapBuilder::<2, _>::unit_grid(N_SQUARE).build().unwrap();
let mut map: CMap2<f32> = GridBuilder::<2, f32>::unit_grid(N_SQUARE);
let elapsed = now.elapsed();
println!("I: Finished initializing in {}μs", elapsed.as_micros());

Expand Down
9 changes: 3 additions & 6 deletions examples/examples/parallel_shift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
//! - overwrite current vertex value with computed average
//!

use honeycomb_core::cmap::{
CMap2, CMapBuilder, DartIdType, NULL_DART_ID, OrbitPolicy, VertexIdType,
};
use honeycomb_core::cmap::{CMap2, DartIdType, NULL_DART_ID, OrbitPolicy, VertexIdType};
use honeycomb_core::geometry::Vertex2;
use honeycomb_core::stm::atomically;
use honeycomb_kernels::grid_generation::GridBuilder;
use rayon::prelude::*;

const N_SQUARES: usize = 256;
Expand All @@ -44,9 +43,7 @@ fn main() {
.build_global()
.unwrap();

let map: CMap2<f64> = CMapBuilder::<2, _>::unit_triangles(N_SQUARES)
.build()
.unwrap();
let map: CMap2<f64> = GridBuilder::<2, _>::unit_triangles(N_SQUARES);

// fetch all vertices that are not on the boundary of the map
let nodes: Vec<(VertexIdType, Vec<VertexIdType>)> = map
Expand Down
16 changes: 7 additions & 9 deletions examples/examples/render.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use honeycomb_core::cmap::{CMapBuilder, GridDescriptor};
use honeycomb_kernels::grid_generation::GridBuilder;
use honeycomb_render::render_2d_map;

fn main() {
// build a simple 4 by 4 grid at origin (1.5, 1.5)

let map = CMapBuilder::<2, f64>::from_grid_descriptor(
GridDescriptor::default()
.origin([1.5, 1.5])
.n_cells([4, 4])
.len_per_cell([1., 1.]),
)
.build()
.unwrap();
let map = GridBuilder::<2, f32>::default()
.origin([1.5, 1.5])
.n_cells([4, 4])
.len_per_cell([1., 1.])
.build()
.unwrap();

// create the render app, add the map to it, and run the app

Expand Down
2 changes: 1 addition & 1 deletion honeycomb-core/src/attributes/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl AttributeBind for Color {
#[test]
fn temperature_map() {
// build the map
let builder = CMapBuilder::<2, _>::from_n_darts(6).add_attribute::<Temperature>();
let builder = CMapBuilder::<2>::from_n_darts(6).add_attribute::<Temperature>();
let map: CMap2<f64> = builder.build().unwrap();

map.force_link::<2>(1, 2).unwrap();
Expand Down
Loading
Loading