Struct SystemGroup

Source
pub struct SystemGroup(/* private fields */);
Expand description

A built-in group, e.g. MPI_GROUP_EMPTY

§Standard section(s)

6.2.1

Implementations§

Source§

impl SystemGroup

Source

pub fn empty() -> SystemGroup

An empty group

Examples found in repository?
examples/group.rs (line 31)
7fn main() {
8    let universe = mpi::initialize().unwrap();
9    let world = universe.world();
10
11    let g = world.group();
12    // Group accessors and Communicator accessors agree
13    assert_eq!(world.size(), g.size());
14    assert_eq!(world.rank(), g.rank().unwrap());
15
16    // g == g
17    assert_eq!(GroupRelation::Identical, g.compare(&g));
18
19    let h = world.group();
20    // h == g
21    assert_eq!(GroupRelation::Identical, g.compare(&h));
22
23    let i = g.union(&h);
24    // g union h == g union g == g
25    assert_eq!(GroupRelation::Identical, g.compare(&i));
26
27    let empty = g.difference(&h);
28    // g difference h == g difference g = empty Group
29    assert_eq!(
30        GroupRelation::Identical,
31        SystemGroup::empty().compare(&empty)
32    );
33    assert_eq!(0, empty.size());
34
35    // g intersection empty == empty Group
36    assert_eq!(0, g.intersection(&empty).size());
37
38    let first_half: Vec<Rank> = (0..g.size() / 2).collect();
39
40    // f and s are first and second half of g
41    let f = g.include(&first_half[..]);
42    let s = g.exclude(&first_half[..]);
43    // f != s
44    assert_eq!(GroupRelation::Unequal, f.compare(&s));
45
46    // g intersection f == f
47    let f_ = g.intersection(&f);
48    assert_eq!(GroupRelation::Identical, f.compare(&f_));
49    // g intersection s == s
50    let s_ = g.intersection(&s);
51    assert_eq!(GroupRelation::Identical, s.compare(&s_));
52
53    // g difference s == f
54    let f__ = g.difference(&s);
55    assert_eq!(GroupRelation::Identical, f.compare(&f__));
56    // g difference f == s
57    let s__ = g.difference(&f);
58    assert_eq!(GroupRelation::Identical, s.compare(&s__));
59
60    // f union s == g
61    let fs = f.union(&s);
62    assert_eq!(GroupRelation::Identical, g.compare(&fs));
63
64    // f intersection s == empty Group
65    let fs = f.intersection(&s);
66    assert_eq!(GroupRelation::Identical, empty.compare(&fs));
67
68    // rank is either in f or in s
69    assert!(
70        (f.rank().is_some() && s.rank().is_none()) ^ (f.rank().is_none() && s.rank().is_some())
71    );
72
73    // inverting rank mappings
74    let rev: Vec<Rank> = (0..g.size()).rev().collect();
75    let r = g.include(&rev[..]);
76    assert_eq!(
77        Some(rev[g.rank().unwrap() as usize]),
78        r.translate_rank(g.rank().unwrap(), &g)
79    );
80}
More examples
Hide additional examples
examples/split.rs (line 22)
6fn main() {
7    let universe = mpi::initialize().unwrap();
8    let world = universe.world();
9
10    let odd = (0..world.size()).filter(|x| x % 2 != 0).collect::<Vec<_>>();
11    let odd_group = world.group().include(&odd[..]);
12    let even_group = world.group().difference(&odd_group);
13    assert!(
14        (world.rank() % 2 == 0 && even_group.rank().is_some() && odd_group.rank().is_none())
15            || (even_group.rank().is_none() && odd_group.rank().is_some())
16    );
17    let my_group = if odd_group.rank().is_some() {
18        &odd_group
19    } else {
20        &even_group
21    };
22    let empty_group = SystemGroup::empty();
23
24    let oddness_comm = world.split_by_subgroup_collective(my_group);
25    assert!(oddness_comm.is_some());
26    let oddness_comm = oddness_comm.unwrap();
27    assert_eq!(
28        GroupRelation::Identical,
29        oddness_comm.group().compare(my_group)
30    );
31
32    let odd_comm = if odd_group.rank().is_some() {
33        world.split_by_subgroup_collective(&odd_group)
34    } else {
35        world.split_by_subgroup_collective(&empty_group)
36    };
37    if odd_group.rank().is_some() {
38        assert!(odd_comm.is_some());
39        let odd_comm = odd_comm.unwrap();
40        assert_eq!(
41            GroupRelation::Identical,
42            odd_comm.group().compare(&odd_group)
43        );
44    } else {
45        assert!(odd_comm.is_none());
46    }
47
48    #[cfg(not(msmpi))]
49    {
50        if even_group.rank().is_some() {
51            let even_comm = world.split_by_subgroup(&even_group);
52            assert!(even_comm.is_some());
53            let even_comm = even_comm.unwrap();
54            assert_eq!(
55                GroupRelation::Identical,
56                even_comm.group().compare(&even_group)
57            );
58
59            let no_comm = world.split_by_subgroup(&odd_group);
60            assert!(no_comm.is_none());
61        }
62    }
63
64    let oddness_comm = world.split_by_color(Color::with_value(world.rank() % 2));
65    assert!(oddness_comm.is_some());
66    let oddness_comm = oddness_comm.unwrap();
67    assert_eq!(
68        GroupRelation::Identical,
69        oddness_comm.group().compare(my_group)
70    );
71
72    let odd_comm = world.split_by_color(if world.rank() % 2 != 0 {
73        Color::with_value(0)
74    } else {
75        Color::undefined()
76    });
77    if world.rank() % 2 != 0 {
78        assert!(odd_comm.is_some());
79        let odd_comm = odd_comm.unwrap();
80        assert_eq!(
81            GroupRelation::Identical,
82            odd_comm.group().compare(&odd_group)
83        );
84    } else {
85        assert!(odd_comm.is_none());
86    }
87}

Trait Implementations§

Source§

impl AsRaw for SystemGroup

Source§

type Raw = *mut ompi_group_t

The raw MPI C API type
Source§

fn as_raw(&self) -> Self::Raw

The raw value
Source§

impl Clone for SystemGroup

Source§

fn clone(&self) -> SystemGroup

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Group for SystemGroup

Source§

fn union<G>(&self, other: &G) -> UserGroup
where G: Group, Self: Sized,

Group union Read more
Source§

fn intersection<G>(&self, other: &G) -> UserGroup
where G: Group, Self: Sized,

Group intersection Read more
Source§

fn difference<G>(&self, other: &G) -> UserGroup
where G: Group, Self: Sized,

Group difference Read more
Source§

fn include(&self, ranks: &[Rank]) -> UserGroup

Subgroup including specified ranks Read more
Source§

fn exclude(&self, ranks: &[Rank]) -> UserGroup

Subgroup including specified ranks Read more
Source§

fn size(&self) -> Rank

Number of processes in the group. Read more
Source§

fn rank(&self) -> Option<Rank>

Rank of this process within the group. Read more
Source§

fn translate_rank<G>(&self, rank: Rank, other: &G) -> Option<Rank>
where G: Group, Self: Sized,

Find the rank in group other' of the process that has rank rank` in this group. Read more
Source§

fn translate_ranks<G>(&self, ranks: &[Rank], other: &G) -> Vec<Option<Rank>>
where G: Group, Self: Sized,

Find the ranks in group other' of the processes that have ranks ranks` in this group. Read more
Source§

fn compare<G>(&self, other: &G) -> GroupRelation
where G: Group, Self: Sized,

Compare two groups. Read more
Source§

impl Copy for SystemGroup

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
Source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

Source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
Source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, Dst> ConvAsUtil<Dst> for T

Source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
Source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
Source§

impl<T> ConvUtil for T

Source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
Source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
Source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
Source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
Source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<Src> TryFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

Source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<Src> ValueFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
Source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

Source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.