Skip to content

Commit

Permalink
refactor!(core): rework attribute semantics (#226)
Browse files Browse the repository at this point in the history
* add error enum

* update `UnknownAttributeStorage` trait

* move copy req to `AttributeUpdate`

* update `AttributeStorage` trait and its impl

* update AttrStorageManager methods

* update attribute module test

* update embed methods

* fix ;ore tests

* fix dim2 tests

* fix 2-sews

* fix 1-sews

* remove explicit Result in favor of StmResult

* fix core tests & errors

* fix tests & errors of kernels

* fix render & doctests

* fix benches

* update trait doc

* update doc

* fix clippy lints
  • Loading branch information
imrn99 authored Nov 24, 2024
1 parent 8b3209f commit a924645
Show file tree
Hide file tree
Showing 30 changed files with 1,947 additions and 1,633 deletions.
19 changes: 11 additions & 8 deletions benches/benches/core/cmap2/basic_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ fn get_sparse_map(n_square: usize) -> CMap2<FloatType> {
map.remove_free_dart(5);
// because of the way we built the map in the square_cmap2 function & the ID computation
// policy, we can safely remove a vertex we know is defined
assert_eq!(map.remove_vertex(1).unwrap(), Vertex2::from((0.0, 0.0)));
assert_eq!(
map.force_remove_vertex(1).unwrap(),
Vertex2::from((0.0, 0.0))
);
map
}

Expand Down Expand Up @@ -109,23 +112,23 @@ library_benchmark_group!(
#[bench::medium(&mut get_map(64))]
#[bench::large(&mut get_map(256))]
fn read_vertex(map: &mut CMap2<FloatType>) -> Option<Vertex2<FloatType>> {
black_box(map.vertex(1))
black_box(map.force_read_vertex(1))
}

#[library_benchmark]
#[bench::small(&mut get_sparse_map(16))]
#[bench::medium(&mut get_sparse_map(64))]
#[bench::large(&mut get_sparse_map(256))]
fn read_missing_vertex(map: &mut CMap2<FloatType>) -> Option<Vertex2<FloatType>> {
black_box(map.vertex(1))
black_box(map.force_read_vertex(1))
}

#[library_benchmark]
#[bench::small(&mut get_sparse_map(16))]
#[bench::medium(&mut get_sparse_map(64))]
#[bench::large(&mut get_sparse_map(256))]
fn insert_vertex(map: &mut CMap2<FloatType>) {
map.insert_vertex(1, (0.0, 0.0));
map.force_write_vertex(1, (0.0, 0.0));
black_box(map);
}

Expand All @@ -134,31 +137,31 @@ fn insert_vertex(map: &mut CMap2<FloatType>) {
#[bench::medium(&mut get_map(64))]
#[bench::large(&mut get_map(256))]
fn replace_vertex(map: &mut CMap2<FloatType>) -> Option<Vertex2<FloatType>> {
black_box(map.replace_vertex(1, (0.0, 0.0)))
black_box(map.force_write_vertex(1, (0.0, 0.0)))
}

#[library_benchmark]
#[bench::small(&mut get_sparse_map(16))]
#[bench::medium(&mut get_sparse_map(64))]
#[bench::large(&mut get_sparse_map(256))]
fn set_vertex(map: &mut CMap2<FloatType>) -> Option<Vertex2<FloatType>> {
black_box(map.replace_vertex(1, (0.0, 0.0)))
black_box(map.force_write_vertex(1, (0.0, 0.0)))
}

#[library_benchmark]
#[bench::small(&mut get_map(16))]
#[bench::medium(&mut get_map(64))]
#[bench::large(&mut get_map(256))]
fn remove_vertex(map: &mut CMap2<FloatType>) -> Option<Vertex2<FloatType>> {
black_box(map.remove_vertex(1))
black_box(map.force_remove_vertex(1))
}

#[library_benchmark]
#[bench::small(&mut get_sparse_map(16))]
#[bench::medium(&mut get_sparse_map(64))]
#[bench::large(&mut get_sparse_map(256))]
fn remove_missing_vertex(map: &mut CMap2<FloatType>) -> Option<Vertex2<FloatType>> {
black_box(map.remove_vertex(1))
black_box(map.force_remove_vertex(1))
}

library_benchmark_group!(
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/core/cmap2/link_and_sew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ fn get_sew_map(n_square: usize) -> CMap2<FloatType> {
.n_darts(n_square.pow(2) * 4)
.build()
.unwrap();
map.insert_vertex(4, (0.0, 0.0));
map.insert_vertex(6, (1.0, 0.0));
map.force_write_vertex(4, (0.0, 0.0));
map.force_write_vertex(6, (1.0, 0.0));
map
}

Expand Down
Loading

0 comments on commit a924645

Please sign in to comment.