From a615ab171b30a9041e1c7d1e0c807dd9ed7b77f8 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 14:27:20 +0200 Subject: [PATCH 01/13] Use modern division from Rust --- src/cartesian/mod.rs | 2 +- src/work_share.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cartesian/mod.rs b/src/cartesian/mod.rs index 9b50f33f..e6a85294 100644 --- a/src/cartesian/mod.rs +++ b/src/cartesian/mod.rs @@ -78,7 +78,7 @@ impl Grid { _ => { for (s, p) in self.size.into_iter().zip(&mut pos) { *p = i % s; - i = i / s; + i /= s; } } } diff --git a/src/work_share.rs b/src/work_share.rs index 6bf67d3d..e0d4b2cd 100644 --- a/src/work_share.rs +++ b/src/work_share.rs @@ -12,10 +12,10 @@ pub fn work_share(total_work: usize, max_threads: usize) -> (usize, usize) { let max_threads = usize::min(total_work, max_threads); // ceil(total_work / max_threads) - let work_per_thread = (total_work + max_threads - 1) / max_threads; + let work_per_thread = total_work.div_ceil(max_threads); // ceil(total_work / work_per_thread) - let thread_count = (total_work + work_per_thread - 1) / work_per_thread; + let thread_count = total_work.div_ceil(work_per_thread); (work_per_thread, thread_count) } From d08a6e36d370d1fd0ac8e0ea63aea41a5d56b926 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 14:28:02 +0200 Subject: [PATCH 02/13] Remove unneeded lifetime parameters --- src/algorithms/graph_growth.rs | 2 +- src/topology/mod.rs | 2 +- src/topology/sprs.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/graph_growth.rs b/src/algorithms/graph_growth.rs index 483c11ce..f3bc5a48 100644 --- a/src/algorithms/graph_growth.rs +++ b/src/algorithms/graph_growth.rs @@ -118,7 +118,7 @@ pub struct GraphGrowth { pub part_count: usize, } -impl<'a, W> crate::Partition<(CsMatView<'a, f64>, W)> for GraphGrowth +impl crate::Partition<(CsMatView<'_, f64>, W)> for GraphGrowth where W: AsRef<[f64]>, { diff --git a/src/topology/mod.rs b/src/topology/mod.rs index 53167942..6246e249 100644 --- a/src/topology/mod.rs +++ b/src/topology/mod.rs @@ -94,7 +94,7 @@ pub trait Topology { } } -impl<'a, T, E> Topology for &'a T +impl Topology for &T where E: Copy, T: Topology, diff --git a/src/topology/sprs.rs b/src/topology/sprs.rs index 402e994f..4852ae8d 100644 --- a/src/topology/sprs.rs +++ b/src/topology/sprs.rs @@ -10,7 +10,7 @@ use std::iter::Sum; use std::iter::Zip; use std::ops::Mul; -impl<'a, E> Topology for sprs::CsMatView<'a, E> +impl Topology for sprs::CsMatView<'_, E> where E: Copy + Sync, { From bfeb26dd3ee08b1041b62659794cf8d003fd57a2 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 14:28:33 +0200 Subject: [PATCH 03/13] Make hilbert helper table static --- src/algorithms/hilbert_curve.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/hilbert_curve.rs b/src/algorithms/hilbert_curve.rs index b6b749bf..f33d9dcb 100644 --- a/src/algorithms/hilbert_curve.rs +++ b/src/algorithms/hilbert_curve.rs @@ -331,7 +331,7 @@ fn encode_2d(x: u64, y: u64, order: usize) -> u64 { order, ); - const LUT: [u16; 16_384] = { + static LUT: [u16; 16_384] = { let mut lut = [0; 16_384]; let mut i: usize = 0; while i < 16_384 { From acafdc6f7033e70da0458b3e3baf5fb47433e72b Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 14:40:24 +0200 Subject: [PATCH 04/13] Remove initial partition parameter for k-means --- src/algorithms/k_means.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/algorithms/k_means.rs b/src/algorithms/k_means.rs index ba8b044b..de791569 100644 --- a/src/algorithms/k_means.rs +++ b/src/algorithms/k_means.rs @@ -48,7 +48,6 @@ fn imbalance(weights: &[f64]) -> f64 { /// - `max_balance_iter`: the maximum number of iterations of the load balancing loop. It will limit how much each cluster /// influence can grow between each cluster movement. /// - `erode`: sets whether or not cluster influence is modified according to errosion's rules between each cluster movement -/// - `hilbert`: sets wheter or not an Hilbert curve is used to create the initial partition. If false, a Z curve is used instead. /// - `mbr_early_break`: sets whether or not bounding box optimization is enabled. #[derive(Debug, Clone, Copy)] pub struct BalancedKmeansSettings { @@ -58,7 +57,6 @@ pub struct BalancedKmeansSettings { pub max_iter: usize, pub max_balance_iter: usize, pub erode: bool, - pub hilbert: bool, pub mbr_early_break: bool, } @@ -71,7 +69,6 @@ impl Default for BalancedKmeansSettings { max_iter: 50, max_balance_iter: 1, // for now, `max_balance_iter > 1` yields poor convergence time erode: false, // for now, `erode` yields` enabled yields wrong results - hilbert: true, mbr_early_break: false, // for now, `mbr_early_break` enabled yields wrong results } } @@ -578,7 +575,6 @@ pub struct KMeans { pub max_iter: usize, pub max_balance_iter: usize, pub erode: bool, - pub hilbert: bool, pub mbr_early_break: bool, } @@ -590,7 +586,6 @@ impl Default for KMeans { max_iter: 500, max_balance_iter: 20, // for now, `max_balance_iter > 1` yields poor convergence time erode: false, // for now, `erode` yields` enabled yields wrong results - hilbert: true, mbr_early_break: false, // for now, `mbr_early_break` enabled yields wrong results } } @@ -621,7 +616,6 @@ where max_iter: self.max_iter, max_balance_iter: self.max_balance_iter, erode: self.erode, - hilbert: self.hilbert, mbr_early_break: self.mbr_early_break, }; balanced_k_means_with_initial_partition(points, weights, settings, part_ids); From f3dcd9d7e523f1c11c1b8911320d2713cc27799a Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 14:46:10 +0200 Subject: [PATCH 05/13] fix issue with ittapi configuration option in tools --- tools/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/lib.rs b/tools/src/lib.rs index c8dd087c..f922d274 100644 --- a/tools/src/lib.rs +++ b/tools/src/lib.rs @@ -35,7 +35,7 @@ mod scotch; #[cfg(any(feature = "metis", feature = "scotch"))] mod zoom_in; -#[cfg_attr(not(feature = "ittapi"), path = "ittapi_stub.rs")] +#[cfg_attr(not(feature = "intel-perf"), path = "ittapi_stub.rs")] pub mod ittapi; pub struct Problem { From 3da0685c45cbc073a1624068d1daa79690d81122 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 15:51:28 +0200 Subject: [PATCH 06/13] Use bundled sqlite3 as we need static library It is not always available, like on Almalinux --- tools/num-part/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/num-part/Cargo.toml b/tools/num-part/Cargo.toml index 1ba1a663..78b0813d 100644 --- a/tools/num-part/Cargo.toml +++ b/tools/num-part/Cargo.toml @@ -27,7 +27,7 @@ itertools = { version = "0.12", default-features = false } coupe = { version = "0.1", path = "../.." } # SQLite interface to save experiments -rusqlite = { version = "0.30", default-features = false } +rusqlite = { version = "0.30", default-features = false, features = ["bundled"] } # Command-line interface getopts = { version = "0.2", default-features = false } From 7c6fd160d99aa22e1ce3af9850b1dda44ffd1247 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 15:52:29 +0200 Subject: [PATCH 07/13] Fix some warnings --- tools/mesh-io/ffi/src/lib.rs | 5 ++--- tools/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/mesh-io/ffi/src/lib.rs b/tools/mesh-io/ffi/src/lib.rs index f7fb5711..c0281f90 100644 --- a/tools/mesh-io/ffi/src/lib.rs +++ b/tools/mesh-io/ffi/src/lib.rs @@ -5,7 +5,6 @@ use std::ffi::c_int; use std::fs; use std::io; use std::os::unix::io::FromRawFd as _; -use std::os::unix::io::IntoRawFd as _; use std::ptr; const ERROR_OTHER: c_int = -1; @@ -50,8 +49,8 @@ pub unsafe extern "C" fn mio_partition_write(fd: c_int, size: u64, partition: *c return ERROR_OTHER; } match w.into_inner() { - Ok(f) => { - f.into_raw_fd(); + Ok(_) => { + //f.into_raw_fd(); 0 } Err(_) => ERROR_OTHER, diff --git a/tools/src/lib.rs b/tools/src/lib.rs index f922d274..46153350 100644 --- a/tools/src/lib.rs +++ b/tools/src/lib.rs @@ -92,7 +92,7 @@ pub type Metadata = Option>; pub type Runner<'a> = Box Result + Send + Sync + 'a>; -fn runner_error(message: &'static str) -> Runner { +fn runner_error(message: &'static str) -> Runner<'static> { Box::new(move |_partition| Err(anyhow::anyhow!("{}", message))) } From b09891b8b21f8754548b96fd272d0d5539b68901 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 15:53:45 +0200 Subject: [PATCH 08/13] Fix format --- src/cartesian/mod.rs | 5 ++++- src/topology/mod.rs | 6 ++++-- src/topology/sprs.rs | 6 ++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cartesian/mod.rs b/src/cartesian/mod.rs index e6a85294..da84ec24 100644 --- a/src/cartesian/mod.rs +++ b/src/cartesian/mod.rs @@ -265,7 +265,10 @@ impl Topology for Grid where E: One, { - type Neighbors<'a> = GridNeighbors where Self: 'a; + type Neighbors<'a> + = GridNeighbors + where + Self: 'a; fn len(&self) -> usize { self.len() diff --git a/src/topology/mod.rs b/src/topology/mod.rs index 6246e249..a0ed7ccb 100644 --- a/src/topology/mod.rs +++ b/src/topology/mod.rs @@ -99,8 +99,10 @@ where E: Copy, T: Topology, { - type Neighbors<'n> = T::Neighbors<'n> - where Self: 'n; + type Neighbors<'n> + = T::Neighbors<'n> + where + Self: 'n; fn len(&self) -> usize { T::len(self) diff --git a/src/topology/sprs.rs b/src/topology/sprs.rs index 4852ae8d..16e54776 100644 --- a/src/topology/sprs.rs +++ b/src/topology/sprs.rs @@ -14,8 +14,10 @@ impl Topology for sprs::CsMatView<'_, E> where E: Copy + Sync, { - type Neighbors<'n> = Zip>, Cloned>> - where Self: 'n; + type Neighbors<'n> + = Zip>, Cloned>> + where + Self: 'n; fn len(&self) -> usize { debug_assert_eq!(self.rows(), self.cols()); From 8e7076c5bdebf1ebf6f3185182f5fb066b846cde Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 15:54:08 +0200 Subject: [PATCH 09/13] Update Cargo.lock --- Cargo.lock | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61b68c2a..ef1ca195 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler" @@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", "once_cell", @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anes" @@ -467,9 +467,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -594,6 +594,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" dependencies = [ + "cc", "pkg-config", "vcpkg", ] @@ -1440,9 +1441,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vtkio" @@ -1734,18 +1735,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", From cfb90335a9732d035a27f79207c8705e21d21827 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 16:09:14 +0200 Subject: [PATCH 10/13] Fix clippy warnings on FP constants --- src/algorithms/k_means.rs | 9 ++++----- src/algorithms/kernighan_lin.rs | 2 +- src/algorithms/multi_jagged.rs | 2 +- src/algorithms/z_curve.rs | 2 +- src/geometry.rs | 6 +++--- src/nextafter.rs | 12 ++++++------ 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/algorithms/k_means.rs b/src/algorithms/k_means.rs index de791569..8e56a504 100644 --- a/src/algorithms/k_means.rs +++ b/src/algorithms/k_means.rs @@ -45,8 +45,7 @@ fn imbalance(weights: &[f64]) -> f64 { /// - `imbalance_tol`: the relative imbalance tolerance of the generated partitions, in `%` of the target weight of each partition. /// - `delta_threshold`: the distance threshold for the cluster movements under which the algorithm stops. /// - `max_iter`: the maximum number of times each cluster will move before stopping the algorithm -/// - `max_balance_iter`: the maximum number of iterations of the load balancing loop. It will limit how much each cluster -/// influence can grow between each cluster movement. +/// - `max_balance_iter`: the maximum number of iterations of the load balancing loop. It will limit how much each cluster influence can grow between each cluster movement. /// - `erode`: sets whether or not cluster influence is modified according to errosion's rules between each cluster movement /// - `mbr_early_break`: sets whether or not bounding box optimization is enabled. #[derive(Debug, Clone, Copy)] @@ -126,7 +125,7 @@ fn balanced_k_means_with_initial_partition( // Generate initial lower and upper bounds. These two variables represent bounds on // the effective distance between an point and the cluster it is assigned to. let mut lbs: Vec<_> = points.par_iter().map(|_| 0.).collect(); - let mut ubs: Vec<_> = points.par_iter().map(|_| std::f64::MAX).collect(); // we use f64::MAX to represent infinity + let mut ubs: Vec<_> = points.par_iter().map(|_| f64::MAX).collect(); // we use f64::MAX to represent infinity balanced_k_means_iter( Inputs { points, weights }, @@ -477,8 +476,8 @@ fn best_values( f64, // new ub Option, // new cluster assignment for the current point (None if the same assignment is kept) ) { - let mut best_value = std::f64::MAX; - let mut snd_best_value = std::f64::MAX; + let mut best_value = f64::MAX; + let mut snd_best_value = f64::MAX; let mut assignment = None; for (((center, id), distance_to_mbr), influence) in centers diff --git a/src/algorithms/kernighan_lin.rs b/src/algorithms/kernighan_lin.rs index 20bfad48..a6d48a7e 100644 --- a/src/algorithms/kernighan_lin.rs +++ b/src/algorithms/kernighan_lin.rs @@ -78,7 +78,7 @@ fn kernighan_lin_2_impl( let mut locks = vec![false; initial_partition.len()]; // pass loop - for _ in 0..(initial_partition.len() / 2).min(max_flips_per_pass.unwrap_or(std::usize::MAX)) + for _ in 0..(initial_partition.len() / 2).min(max_flips_per_pass.unwrap_or(usize::MAX)) { // construct gains for (idx, gain) in gains.iter_mut().enumerate() { diff --git a/src/algorithms/multi_jagged.rs b/src/algorithms/multi_jagged.rs index 1fc4de1e..a2cb9198 100644 --- a/src/algorithms/multi_jagged.rs +++ b/src/algorithms/multi_jagged.rs @@ -239,7 +239,7 @@ pub(crate) fn compute_split_positions( let mut scan = permutation .par_iter() .enumerate() - .fold_with((std::usize::MAX, 0.), |(low, acc), (idx, val)| { + .fold_with((usize::MAX, 0.), |(low, acc), (idx, val)| { (usize::min(idx, low), acc + weights[*val]) }) .collect::>() diff --git a/src/algorithms/z_curve.rs b/src/algorithms/z_curve.rs index ea070b53..593851d8 100644 --- a/src/algorithms/z_curve.rs +++ b/src/algorithms/z_curve.rs @@ -36,7 +36,7 @@ use std::sync::atomic::{self, AtomicPtr}; // in 2D, an order greater than 64 will overflow u128. // maybe it would be more appropriate to use a BigInt type HashType = u128; -const HASH_TYPE_MAX: HashType = std::u128::MAX; +const HASH_TYPE_MAX: HashType = u128::MAX; fn z_curve_partition( partition: &mut [usize], diff --git a/src/geometry.rs b/src/geometry.rs index 01e08b63..2f583242 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -42,8 +42,8 @@ impl BoundingBox { let (p_min, p_max) = points .fold_with( ( - PointND::::from_element(std::f64::MAX), - PointND::::from_element(std::f64::MIN), + PointND::::from_element(f64::MAX), + PointND::::from_element(f64::MIN), ), |(mut mins, mut maxs), vals| { for ((min, max), val) in mins.iter_mut().zip(maxs.iter_mut()).zip(&vals) { @@ -118,7 +118,7 @@ impl BoundingBox { } pub fn contains(&self, point: &PointND) -> bool { - let eps = 10. * std::f64::EPSILON; + let eps = 10. * f64::EPSILON; self.p_min .iter() .zip(self.p_max.iter()) diff --git a/src/nextafter.rs b/src/nextafter.rs index 6ed36318..5f38ba47 100644 --- a/src/nextafter.rs +++ b/src/nextafter.rs @@ -30,25 +30,25 @@ pub fn nextafter(from: f64, to: f64) -> f64 { mod tests { use super::*; - const POS_INF: f64 = std::f64::INFINITY; - const NEG_INF: f64 = std::f64::NEG_INFINITY; + const POS_INF: f64 = f64::INFINITY; + const NEG_INF: f64 = f64::NEG_INFINITY; const POS_ZERO: f64 = 0.0; const NEG_ZERO: f64 = -0.0; // Note: Not the same as f64::MIN_POSITIVE, because that is only the min *normal* number. const SMALLEST_POS: f64 = 5e-324; const SMALLEST_NEG: f64 = -5e-324; - const LARGEST_POS: f64 = std::f64::MAX; - const LARGEST_NEG: f64 = std::f64::MIN; + const LARGEST_POS: f64 = f64::MAX; + const LARGEST_NEG: f64 = f64::MIN; const POS_ONE: f64 = 1.0; const NEG_ONE: f64 = -1.0; - const NEXT_LARGER_THAN_ONE: f64 = 1.0 + std::f64::EPSILON; + const NEXT_LARGER_THAN_ONE: f64 = 1.0 + f64::EPSILON; const NEXT_SMALLER_THAN_ONE: f64 = 0.999_999_999_999_999_9; const SEQUENCE_BIG_NUM: (f64, f64) = (16_237_485_966.000_004, 16_237_485_966.000_006); - const NAN: f64 = std::f64::NAN; + const NAN: f64 = f64::NAN; fn is_pos_zero(x: f64) -> bool { x.to_bits() == POS_ZERO.to_bits() From 4e157d6e0a7d54b10236ff2eec8c1fd4107ed045 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 16:09:34 +0200 Subject: [PATCH 11/13] Simplify Iterator traits requirements --- ffi/src/data.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ffi/src/data.rs b/ffi/src/data.rs index 289165c8..5e1a165e 100644 --- a/ffi/src/data.rs +++ b/ffi/src/data.rs @@ -38,7 +38,7 @@ impl Constant { Ok(v) } - pub unsafe fn iter<'a, T>(&'a self) -> impl Iterator + ExactSizeIterator + 'a + pub unsafe fn iter<'a, T>(&'a self) -> impl ExactSizeIterator + 'a where T: 'a + Copy, { @@ -73,7 +73,7 @@ impl Array { slice::from_raw_parts(self.array as *const T, self.len) } - pub unsafe fn iter<'a, T>(&'a self) -> impl Iterator + ExactSizeIterator + 'a + pub unsafe fn iter<'a, T>(&'a self) -> impl ExactSizeIterator + 'a where T: 'a + Copy, { @@ -117,7 +117,7 @@ impl Fn { Ok(v) } - pub unsafe fn iter<'a, T>(&'a self) -> impl Iterator + ExactSizeIterator + 'a + pub unsafe fn iter<'a, T>(&'a self) -> impl ExactSizeIterator + 'a where T: 'a + Copy, { From 37994ba6cad07b84017f386581f6ae5d5e9ba436 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 16:10:34 +0200 Subject: [PATCH 12/13] Simpler code --- benches/rcb_cartesian.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benches/rcb_cartesian.rs b/benches/rcb_cartesian.rs index 00d345f6..85bd28dd 100644 --- a/benches/rcb_cartesian.rs +++ b/benches/rcb_cartesian.rs @@ -37,7 +37,7 @@ pub fn bench(c: &mut Criterion) { }) .build() .unwrap(); - group.bench_function(&thread_count.to_string(), |b| { + group.bench_function(thread_count.to_string(), |b| { pool.install(|| { b.iter(|| grid.rcb(black_box(&mut partition), black_box(&weights), 12)) }); From 0d739cee33901f068de2a2cf234a391d78dab5b7 Mon Sep 17 00:00:00 2001 From: Cedric Chevalier Date: Fri, 6 Jun 2025 16:12:22 +0200 Subject: [PATCH 13/13] Use repeat_n --- ffi/src/data.rs | 2 +- src/algorithms/kernighan_lin.rs | 3 +-- tools/mesh-io/src/vtk.rs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ffi/src/data.rs b/ffi/src/data.rs index 5e1a165e..b7b3b0fb 100644 --- a/ffi/src/data.rs +++ b/ffi/src/data.rs @@ -117,7 +117,7 @@ impl Fn { Ok(v) } - pub unsafe fn iter<'a, T>(&'a self) -> impl ExactSizeIterator + 'a + pub unsafe fn iter<'a, T>(&'a self) -> impl ExactSizeIterator + 'a where T: 'a + Copy, { diff --git a/src/algorithms/kernighan_lin.rs b/src/algorithms/kernighan_lin.rs index a6d48a7e..3bdae44c 100644 --- a/src/algorithms/kernighan_lin.rs +++ b/src/algorithms/kernighan_lin.rs @@ -78,8 +78,7 @@ fn kernighan_lin_2_impl( let mut locks = vec![false; initial_partition.len()]; // pass loop - for _ in 0..(initial_partition.len() / 2).min(max_flips_per_pass.unwrap_or(usize::MAX)) - { + for _ in 0..(initial_partition.len() / 2).min(max_flips_per_pass.unwrap_or(usize::MAX)) { // construct gains for (idx, gain) in gains.iter_mut().enumerate() { for (j, w) in adjacency.neighbors(idx) { diff --git a/tools/mesh-io/src/vtk.rs b/tools/mesh-io/src/vtk.rs index d68928f8..82d05e82 100644 --- a/tools/mesh-io/src/vtk.rs +++ b/tools/mesh-io/src/vtk.rs @@ -98,7 +98,7 @@ fn add_piece(mesh: &mut Mesh, piece: UnstructuredGridPiece) { mesh.coordinates.extend(piece.points.iter().unwrap()); // TODO extract attributes mesh.node_refs - .extend(iter::repeat(1).take(piece.num_points())); + .extend(std::iter::repeat_n(1, piece.num_points())); match piece.cells.cell_verts { VertexNumbers::Legacy { num_cells,