Skip to content

Commit

Permalink
C-EXAMPLE, C-QUESTION-MARK and spelling [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
ABouttefeux committed Apr 6, 2022
1 parent 0db92e6 commit 51e7acf
Show file tree
Hide file tree
Showing 35 changed files with 1,574 additions and 790 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
version: 2
updates:

# main crate
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
target-branch: develop

# procedural macro
- package-ecosystem: cargo
directory: "/procedural_macro/"
schedule:
interval: daily
open-pull-requests-limit: 10
target-branch: develop
label:
- "dependencies"
- "macro"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Cargo.lock
**/*.rs.bk
data/
.vscode/settings.json
logo.png
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ First release

- thread::ThreadError::Panic now contain a vector of error
- fixe issue with the threading module's function giving inconsistent error type
- iterator opac type returned now also implement ExactSizeIterator and FusedIterator
- add licences MIT or APACHE-2.0
- iterator opaque type returned now also implement ExactSizeIterator and FusedIterator
- add licenses MIT or APACHE-2.0
- add documentation
- correct doctest Su3Adjoint::as_mut_vector
- migrate to rust 2021
- use readme in librairies root documentation
- rename lots of gettet to match C-GETTER convention
- rename some structure for C-WORD-ORDER
- use readme in libraries root documentation
- rename lots of getter to match C-GETTER convention
- rename some structure for C-WORD-ORDER
- Rename `LatticeCylcique` to `LatticeCyclic`
- Rename `SimulationStateSynchrone` to `SimulationStateSynchronous`
- Rename structures and functions to correct spelling mistakes
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use lq::prelude::*;
let beta = 1_f64;
let mut simulation =
LatticeStateDefault::<4>::new_deterministe(size, beta, number_of_pts, &mut rng)?;
LatticeStateDefault::<4>::new_determinist(size, beta, number_of_pts, &mut rng)?;
let spread_parameter = 0.1_f64;
let mut mc = MetropolisHastingsDeltaDiagnostic::new(spread_parameter, rng)?;
Expand All @@ -74,7 +74,7 @@ use lq::prelude::*;
simulation.normalize_link_matrices();
}
let average = simulation.average_trace_plaquette().unwrap().real() / 3_f64;
let average = simulation.average_trace_plaquette().ok_or(ImplementationError::Unreachable)?.real() / 3_f64;
# Ok(())
# }
```
Expand Down Expand Up @@ -153,7 +153,7 @@ let size = 1_000_f64;
let number_of_pts = 4;
let beta = 2_f64;
let mut simulation =
LatticeStateDefault::<4>::new_deterministe(size, beta, number_of_pts, &mut rng)?;
LatticeStateDefault::<4>::new_determinist(size, beta, number_of_pts, &mut rng)?;

let spread_parameter = 1E-5_f64;
let mut mc = MetropolisHastingsDeltaDiagnostic::new(spread_parameter, rng)
Expand Down Expand Up @@ -188,7 +188,7 @@ let size = 1_000_f64;
let number_of_pts = 4;
let beta = 2_f64;
let mut simulation =
LatticeStateDefault::<3>::new_deterministe(size, beta, number_of_pts, &mut rng)?;
LatticeStateDefault::<3>::new_determinist(size, beta, number_of_pts, &mut rng)?;

let number_of_rand = 20;
let spread_parameter = 1E-5_f64;
Expand Down Expand Up @@ -219,7 +219,7 @@ let size = 1_000_f64;
let number_of_pts = 4;
let beta = 2_f64;
let mut simulation =
LatticeStateDefault::<3>::new_deterministe(size, beta, number_of_pts, &mut rng)?;
LatticeStateDefault::<3>::new_determinist(size, beta, number_of_pts, &mut rng)?;

let delta_t = 1E-3_f64;
let number_of_step = 10;
Expand Down
24 changes: 12 additions & 12 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use lattice_qcd_rs::{
};
use rayon::prelude::*;

fn bench_simulation_creation_deterministe(
fn bench_simulation_creation_determinist(
size: usize,
rng: &mut rand::rngs::ThreadRng,
d: &impl rand_distr::Distribution<Real>,
) {
let _simulation = LatticeStateEFSyncDefault::<LatticeStateDefault<4>, 4>::new_deterministe(
let _simulation = LatticeStateEFSyncDefault::<LatticeStateDefault<4>, 4>::new_determinist(
1_f64, 1_f64, size, rng, d,
)
.unwrap();
Expand Down Expand Up @@ -103,18 +103,18 @@ fn criterion_benchmark(c: &mut Criterion) {
let mut rng = rand::thread_rng();
let d = rand::distributions::Uniform::from(-f64::consts::PI..f64::consts::PI);

let mut groupe_creation_deterministe = c.benchmark_group("Sim creation deterministe");
groupe_creation_deterministe.sample_size(10);
let mut groupe_creation_determinist = c.benchmark_group("Sim creation determinist");
groupe_creation_determinist.sample_size(10);
let array_size: [usize; 6] = [2, 4, 8, 10, 20, 30];
for el in array_size.iter() {
groupe_creation_deterministe.throughput(Throughput::Elements((el.pow(4)) as u64));
groupe_creation_deterministe.bench_with_input(
groupe_creation_determinist.throughput(Throughput::Elements((el.pow(4)) as u64));
groupe_creation_determinist.bench_with_input(
BenchmarkId::new("size", el.pow(4)),
el,
|b, i| b.iter(|| bench_simulation_creation_deterministe(*i, &mut rng, &d)),
|b, i| b.iter(|| bench_simulation_creation_determinist(*i, &mut rng, &d)),
);
}
groupe_creation_deterministe.finish();
groupe_creation_determinist.finish();

let mut groupe_creation_threaded = c.benchmark_group("Sim creation (20) threaded");
let gp_size: usize = 20;
Expand Down Expand Up @@ -170,7 +170,7 @@ fn criterion_benchmark(c: &mut Criterion) {

groupe_mc.bench_function("simulate 20 D3 Metropolis Hastings Sweep", |b| {
b.iter_batched(
|| LatticeStateDefault::<3>::new_deterministe(1000_f64, 2_f64, 20, &mut rng).unwrap(),
|| LatticeStateDefault::<3>::new_determinist(1000_f64, 2_f64, 20, &mut rng).unwrap(),
|state_in| state_in.monte_carlo_step(&mut mc),
BatchSize::LargeInput,
)
Expand All @@ -181,7 +181,7 @@ fn criterion_benchmark(c: &mut Criterion) {

groupe_mc.bench_function("simulate 20 D3 hybrid monteCarlo 100", |b| {
b.iter_batched(
|| LatticeStateDefault::<3>::new_deterministe(1000_f64, 2_f64, 20, &mut rng).unwrap(),
|| LatticeStateDefault::<3>::new_determinist(1000_f64, 2_f64, 20, &mut rng).unwrap(),
|state_in| state_in.monte_carlo_step(&mut mch),
BatchSize::LargeInput,
)
Expand All @@ -196,9 +196,9 @@ fn criterion_benchmark(c: &mut Criterion) {
groupe_gauss_proj.bench_with_input(BenchmarkId::new("size", n), n, |b, i| {
b.iter(|| {
let state =
LatticeStateDefault::<4>::new_deterministe(1_f64, 1_f64, *i, &mut rng).unwrap();
LatticeStateDefault::<4>::new_determinist(1_f64, 1_f64, *i, &mut rng).unwrap();
let d = rand_distr::Normal::new(0.0, 0.5_f64).unwrap();
let e_field = EField::new_deterministe(state.lattice(), &mut rng, &d);
let e_field = EField::new_determinist(state.lattice(), &mut rng, &d);
e_field.project_to_gauss(state.link_matrix(), state.lattice());
})
});
Expand Down
4 changes: 2 additions & 2 deletions procedural_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ publish = true
proc-macro = true

[dependencies]
quote = "1.0.16"
syn = "1.0.89"
quote = "1.0.17"
syn = "1.0.90"
proc-macro2 = "1.0.36"

[dev-dependencies]
Expand Down
12 changes: 6 additions & 6 deletions procedural_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ mod test;
use proc_macro::TokenStream;
use quote::quote;

/// Maximum dimention to impl [`Direction`] for.
/// Maximum dimension to impl [`Direction`] for.
const MAX_DIM: usize = 127;

/// Implement [`DirectionList`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/lattice/trait.DirectionList.html)
/// for [`Direction`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/lattice/struct.Direction.html) of `1` to `127` the value of `MAX_DIM`.
///
/// Using const generics might render this unecessary. Waiting for stabilisation of feature(generic_const_exprs).
/// Using const generics might render this unnecessary. Waiting for stabilization of feature(generic_const_exprs).
#[proc_macro]
pub fn implement_direction_list(_item: TokenStream) -> TokenStream {
let mut implem = Vec::with_capacity(MAX_DIM);
Expand All @@ -66,7 +66,7 @@ pub fn implement_direction_list(_item: TokenStream) -> TokenStream {
let u_dir_ident = syn::Ident::new(&format!("U{}_DIR", i), proc_macro2::Span::call_site());
let u_dir_pos_ident =
syn::Ident::new(&format!("U{}_DIR_POS", i), proc_macro2::Span::call_site());
// we store the vallues in array so we can access them as fast as possible.
// we store the values in array so we can access them as fast as possible.
let s = quote! {
const #u_dir_ident: [Direction<#i>; #i * 2] = [ #(#array_direction),* ];
const #u_dir_pos_ident: [Direction<#i>; #i] = [ #(#array_direction_positives),* ];
Expand All @@ -90,7 +90,7 @@ pub fn implement_direction_list(_item: TokenStream) -> TokenStream {
final_stream.into()
}

/// The max dimention to imply the [`From`] and [`std::convert::TryFrom`] and for
/// The max dimension to imply the [`From`] and [`std::convert::TryFrom`] and for
/// [`Direction`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/lattice/struct.Direction.html).
///
/// It takes just way to long for 127.
Expand All @@ -108,14 +108,14 @@ pub fn implement_direction_from(_item: TokenStream) -> TokenStream {
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[non_exhaustive]
pub enum DirectionConversionError {
/// The index is out of bound, i.e. the directtion axis does not exist in the lower space dimention.
/// The index is out of bound, i.e. the direction axis does not exist in the lower space dimension.
IndexOutOfBound,
}

impl std::fmt::Display for DirectionConversionError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::IndexOutOfBound => write!(f, "the index is out of bound, the direction axis does not exist in the lower space dimention"),
Self::IndexOutOfBound => write!(f, "the index is out of bound, the direction axis does not exist in the lower space dimension"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/dim.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Depreciated, module for dimension reexport.
//!
//! The library use now const generic and not this sytem anymore. It can be safely ignored.
//! It a sytem used before const generic was introduced.
//! The library use now const generic and not this system anymore. It can be safely ignored.
//! It a was system used before const generic was introduced.
macro_rules! reexport_name_dim{
($($i:ident) ,+) => {
Expand Down
Loading

0 comments on commit 51e7acf

Please sign in to comment.