fips_md/codegen/analysis/
barrier.rs

1//! Components related to barriers in the simulation graph
2
3use std::collections::HashSet;
4
5use slotmap::{DefaultKey};
6
7use crate::runtime::{InteractionID, InteractionQuantityID, ParticleID};
8
9/// Different barriers can be shared by having the same barrier ID
10pub type BarrierID = DefaultKey;
11
12/// A synchronization barrier (i.e. the data part of a barrier node in the
13/// simulation graph)
14#[derive(Clone)]
15pub struct Barrier {
16    /// Particle types affected by this barrier
17    pub affected_particles: HashSet<ParticleID>,
18    /// Kind of barrier
19    pub kind: BarrierKind
20}
21
22impl Barrier {
23    pub(crate) fn new(affected_particles: HashSet<ParticleID>, kind: BarrierKind) -> Self {
24        Self {
25            affected_particles, kind
26        }
27    }
28}
29
30/// Types of synchronization barriers
31#[derive(Clone)]
32pub enum BarrierKind {
33    /// Barrier due to particle interaction
34    InteractionBarrier(InteractionID, Option<InteractionQuantityID>),
35    /// Barrier due to a call to Rust
36    CallBarrier(String)
37}