diff --git a/Cargo.lock b/Cargo.lock index ad8a2d8..571ca42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -339,7 +339,6 @@ dependencies = [ "spirv_backend", "spirv_backend_runner", "threadpool", - "typetag", "wgpu", "y4m", ] @@ -502,16 +501,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ctor" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "cty" version = "0.2.2" @@ -590,15 +579,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "erased-serde" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d013529d5574a60caeda29e179e695125448e5de52e3874f7b4c1d7360e18e" -dependencies = [ - "serde", -] - [[package]] name = "exr" version = "1.4.2" @@ -802,17 +782,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "ghost" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93490550b1782c589a350f2211fff2e34682e25fed17ef53fc4fa8fe184975e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "gif" version = "0.11.4" @@ -1021,16 +990,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "inventory" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0257e268c91daba296499206db5dd5a058875936bec3d8429b5f3e20ec9dc9a" -dependencies = [ - "ctor", - "ghost", -] - [[package]] name = "itertools" version = "0.10.3" @@ -2236,30 +2195,6 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" -[[package]] -name = "typetag" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36afde536989c95b0c35d2b6720618ed268b271a002fa1ebd97e821cf9ff28c6" -dependencies = [ - "erased-serde", - "inventory", - "once_cell", - "serde", - "typetag-impl", -] - -[[package]] -name = "typetag-impl" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c935ee7eb11a684e863c6a3332ff17caa2a46fc855719a90c6493aee213852b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "unicode-ident" version = "1.0.1" diff --git a/crates/applications/buffer_proto5/src/main.rs b/crates/applications/buffer_proto5/src/main.rs index 9077469..06638d7 100644 --- a/crates/applications/buffer_proto5/src/main.rs +++ b/crates/applications/buffer_proto5/src/main.rs @@ -13,9 +13,9 @@ use coremem::stim::{CurlStimulus, Exp1, Gated, Sinusoid1, TimeVarying as _}; use log::{error, info, warn}; use serde::{Deserialize, Serialize}; -mod cache; - -use cache::DiskCache; +// XXX: cache was disabled during Region rework. +// mod cache; +// use cache::DiskCache; type Mat = IsoConductorOr; @@ -142,7 +142,7 @@ struct Params { dump_frames: (u64, Option), } -#[derive(Clone, Default, Serialize, Deserialize)] +#[derive(Clone, Default)] struct Geometries { dim: Meters, ferro1_region: Torus, @@ -657,10 +657,14 @@ fn main() { variants.len() / post_times.len(), ); - let mut geom_cache = DiskCache::new_with_supplier( - &format!("{}/.geom_cache", ensure_out_dir(i)), - |geom: &GeomParams| derive_geometries(geom.clone()) - ); + // let mut geom_cache = DiskCache::new_with_supplier( + // &format!("{}/.geom_cache", ensure_out_dir(i)), + // |geom: &GeomParams| derive_geometries(geom.clone()) + // ); + // TODO: re-enable geometry cache. had to disable during Region serialization rework + fn geom_cache_get_or_insert_from_supplier(geom: GeomParams) -> Option { + derive_geometries(geom) + } for (peak_clock_current, clock_duration, post_time, clock_type, ferro_major, wrap1_coverage, wrap2_coverage, wrap1_density, wrap2_density) in variants { info!("{}A/{}s {}s {}m {}:{}cov {}:{}density", peak_clock_current, clock_duration, post_time, ferro_major, wrap1_coverage, wrap2_coverage, wrap1_density, wrap2_density); @@ -709,7 +713,7 @@ fn main() { wraps1: (wraps1 * 4) as f32, ..base_params.geom }; - let geoms = geom_cache.get_or_insert_from_supplier(params.clone())?; + let geoms = geom_cache_get_or_insert_from_supplier(params.clone())?; Some((params, geoms)) }) .collect(); @@ -734,7 +738,7 @@ fn main() { wraps2: (wraps2 * 4) as f32, ..base_params.geom }; - let geoms = geom_cache.get_or_insert_from_supplier(params.clone())?; + let geoms = geom_cache_get_or_insert_from_supplier(params.clone())?; Some((params, geoms)) }) .collect(); @@ -755,7 +759,7 @@ fn main() { let mut params = base_params; params.geom.wraps1 = wraps1; params.geom.wraps2 = wraps2; - match geom_cache.get_or_insert_from_supplier(params.geom.clone()) { + match geom_cache_get_or_insert_from_supplier(params.geom.clone()) { Some(geoms) => { run_sim(i, params, geoms); }, diff --git a/crates/coremem/Cargo.toml b/crates/coremem/Cargo.toml index 7f8d5af..3dce5ed 100644 --- a/crates/coremem/Cargo.toml +++ b/crates/coremem/Cargo.toml @@ -33,7 +33,6 @@ rand = "0.8" # MIT or Apache 2.0 rayon = "1.5" # MIT or Apache 2.0 serde = "1.0" # MIT or Apache 2.0 threadpool = "1.8" # MIT or Apache 2.0 -typetag = "0.2" # MIT or Apache 2.0 y4m = "0.7" # MIT wgpu = "0.12" diff --git a/crates/coremem/src/geom/region/mod.rs b/crates/coremem/src/geom/region/mod.rs index 719de46..8c91c6c 100644 --- a/crates/coremem/src/geom/region/mod.rs +++ b/crates/coremem/src/geom/region/mod.rs @@ -12,7 +12,6 @@ mod primitives; pub use primitives::*; -#[typetag::serde(tag = "type")] pub trait Region: Send + Sync + DynClone { fn contains(&self, p: Meters) -> bool; } @@ -79,14 +78,13 @@ pub fn distance_to(r: &R, p0: C, p1: C, feat_size: f32) -> #[derive(Copy, Clone, Serialize, Deserialize)] pub struct WorldRegion; -#[typetag::serde] impl Region for WorldRegion { fn contains(&self, _: Meters) -> bool { true } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct InvertedRegion(Box); impl InvertedRegion { @@ -95,14 +93,13 @@ impl InvertedRegion { } } -#[typetag::serde] impl Region for InvertedRegion { fn contains(&self, p: Meters) -> bool { !self.0.contains(p) } } -#[derive(Clone, Default, Serialize, Deserialize)] +#[derive(Clone, Default)] pub struct Union(Vec>); impl Union { @@ -121,14 +118,13 @@ impl Union { } } -#[typetag::serde] impl Region for Union { fn contains(&self, p: Meters) -> bool { self.0.iter().any(|r| r.contains(p)) } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Intersection(Vec>); @@ -148,14 +144,13 @@ impl Intersection { } } -#[typetag::serde] impl Region for Intersection { fn contains(&self, p: Meters) -> bool { self.0.iter().all(|r| r.contains(p)) } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Translate { inner: Box, shift: Meters, @@ -167,14 +162,13 @@ impl Translate { } } -#[typetag::serde] impl Region for Translate { fn contains(&self, p: Meters) -> bool { self.inner.contains(p - self.shift) } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct SwapXZ { inner: Box, } @@ -185,7 +179,6 @@ impl SwapXZ { } } -#[typetag::serde] impl Region for SwapXZ { fn contains(&self, p: Meters) -> bool { let p = Meters::new(p.z(), p.y(), p.z()); @@ -194,7 +187,7 @@ impl Region for SwapXZ { } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct SwapYZ { inner: Box, } @@ -205,7 +198,6 @@ impl SwapYZ { } } -#[typetag::serde] impl Region for SwapYZ { fn contains(&self, p: Meters) -> bool { let mapped = Meters::new(p.x(), p.z(), p.y()); @@ -219,7 +211,7 @@ impl Region for SwapYZ { /// the resulting region is mapped onto the original region y=[0, y_max]. x is just the radius /// so that (0, 0) is mapped to (0, 0), and (1, 0) is mapped to (1, 0) and (0, 1) is mapped to /// (1, 0.5*y_max) and (-5, 0) is mapped to (5, 0.5*y_max). -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Wrap { inner: Box, y_max: f32, @@ -244,14 +236,13 @@ impl Wrap { } } -#[typetag::serde] impl Region for Wrap { fn contains(&self, p: Meters) -> bool { self.inner.contains(self.map(p)) } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Dilate { inner: Box, rad: f32, @@ -264,7 +255,6 @@ impl Dilate { } } -#[typetag::serde] impl Region for Dilate { fn contains(&self, p: Meters) -> bool { let rad_iters = (self.rad / self.res).ceil() as i32; @@ -288,9 +278,8 @@ impl Region for Dilate { } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Memoize { - #[serde(skip)] lut: Arc>, inner: Box, } @@ -304,7 +293,6 @@ impl Memoize { } } -#[typetag::serde] impl Region for Memoize { fn contains(&self, p: Meters) -> bool { *self.lut.entry(OrdMeters(p)).or_insert_with(|| self.inner.contains(p)) diff --git a/crates/coremem/src/geom/region/primitives.rs b/crates/coremem/src/geom/region/primitives.rs index b1fe309..cfe4102 100644 --- a/crates/coremem/src/geom/region/primitives.rs +++ b/crates/coremem/src/geom/region/primitives.rs @@ -24,7 +24,6 @@ impl CylinderZ { } } -#[typetag::serde] impl Region for CylinderZ { fn contains(&self, p: Meters) -> bool { p.xy().distance_sq(self.center) <= self.radius * self.radius @@ -77,7 +76,6 @@ impl Torus { } } -#[typetag::serde] impl Region for Torus { fn contains(&self, p: Meters) -> bool { // a torus is the set of all points < distance `r` from the circle of radius `R`, @@ -128,7 +126,6 @@ impl Sphere { } } -#[typetag::serde] impl Region for Sphere { fn contains(&self, p: Meters) -> bool { p.distance_sq(*self.center) < self.rad * self.rad @@ -237,7 +234,6 @@ impl Cube { } } -#[typetag::serde] impl Region for Cube { fn contains(&self, p: Meters) -> bool { self.x_range().contains(&p.x()) && @@ -266,7 +262,6 @@ impl Spiral { } } -#[typetag::serde] impl Region for Spiral { fn contains(&self, p: Meters) -> bool { let revs = p.z() / self.period; diff --git a/crates/coremem/src/meas.rs b/crates/coremem/src/meas.rs index 7d581f2..bbf2e45 100644 --- a/crates/coremem/src/meas.rs +++ b/crates/coremem/src/meas.rs @@ -212,7 +212,7 @@ impl AbstractMeasurement for Meta { } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Volume { name: String, region: Box, @@ -241,7 +241,7 @@ impl AbstractMeasurement for Volume { } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Current { name: String, region: Box, @@ -471,7 +471,7 @@ impl AbstractMeasurement for MagneticLoop { } /// mean M over a region -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct MagneticFlux { name: String, region: Box, @@ -508,7 +508,7 @@ impl AbstractMeasurement for MagneticFlux { } /// mean B over a region -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Magnetization { name: String, region: Box, @@ -604,7 +604,7 @@ impl AbstractMeasurement for ElectricField { } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Energy { name: String, region: Box, @@ -648,7 +648,7 @@ impl AbstractMeasurement for Energy { } } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone)] pub struct Power { name: String, region: Box @@ -741,7 +741,6 @@ pub mod test { self.normal } } - #[typetag::serde] impl Region for MockRegion { fn contains(&self, _p: Meters) -> bool { true diff --git a/crates/coremem/src/stim.rs b/crates/coremem/src/stim.rs index decf937..888ce8c 100644 --- a/crates/coremem/src/stim.rs +++ b/crates/coremem/src/stim.rs @@ -405,7 +405,6 @@ mod test { self.normal } } - #[typetag::serde] impl Region for MockRegion { fn contains(&self, _p: Meters) -> bool { true