Struct lamellar::LamellarTeam

source ·
pub struct LamellarTeam { /* private fields */ }
Expand description

An abstraction used to group PEs into distributed computational units.

The ActiveMessaging trait is implemented for Arc<LamellarTeam>, new LamellarTeams will always be returned as Arc<LamellarTeam>.

Actions taking place on a team, only execute on members of the team.

§Examples

 use lamellar::active_messaging::prelude::*;
 use lamellar::array::prelude::*;

 #[AmData(Debug,Clone)]
 struct Am{
     world_pe: usize,
     team_pe: Option<usize>,
 }

 #[lamellar::am]
 impl LamellarAm for Am{
     async fn exec(self) {
         println!("Hello from world PE{:?}, team PE{:?}",self.world_pe, self.team_pe);
     }
 }

 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();
 let world_pe = world.my_pe();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
 let team_pe = match even_pes.team_pe_id(){
     Ok(pe) => Some(pe),
     Err(_) => None,
 };
 // we can launch and await the results of active messages on a given team
 let req = even_pes.exec_am_all(Am{world_pe,team_pe});
 let result = even_pes.block_on(req);
 // we can also create a distributed array so that its data only resides on the members of the team.
 let array: AtomicArray<usize> = AtomicArray::new(&even_pes, 100,Distribution::Block);

Implementations§

source§

impl LamellarTeam

source

pub fn get_pes(&self) -> Vec<usize>

Return a list of (world-based) pe ids representing the members of the team

§One-sided Operation

The result is returned only on the calling PE

§Examples
 use lamellar::active_messaging::prelude::*;

 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
 let pes = even_pes.get_pes();

 for (a,b) in (0..num_pes).step_by(2).zip(pes.iter()){
     assert_eq!(a,*b);
 }
source

pub fn num_pes(&self) -> usize

Return number of pes in team

§One-sided Operation

The result is returned only on the calling PE

§Examples
 use lamellar::active_messaging::prelude::*;

 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
 let pes = even_pes.get_pes();

 assert_eq!((num_pes as f64 / 2.0).ceil() as usize,even_pes.num_pes());
source

pub fn num_threads_per_pe(&self) -> usize

Returns nummber of threads on this PE (including the main thread)

§One-sided Operation

The result is returned only on the calling PE

§Examples
 use lamellar::active_messaging::prelude::*;

 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
 let pes = even_pes.get_pes();

 assert_eq!((num_pes as f64 / 2.0).ceil() as usize,even_pes.num_pes());
source

pub fn world_pe_id(&self) -> usize

Return the world-based id of this pe

§One-sided Operation

The result is returned only on the calling PE

§Examples
 use lamellar::active_messaging::prelude::*;

 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();
 let my_pe = world.my_pe();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
 let pes = even_pes.get_pes();

 assert_eq!(my_pe,even_pes.world_pe_id());
source

pub fn team_pe_id(&self) -> Result<usize, IdError>

Return the team-based id of this pe

§One-sided Operation

The result is returned only on the calling PE

§Examples
 use lamellar::active_messaging::prelude::*;

 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();
 let my_pe = world.my_pe();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
 let pes = even_pes.get_pes();

 if let Ok(team_pe) = even_pes.team_pe_id(){
    assert!(my_pe %2 == 0);
 }
source

pub fn create_subteam_from_arch<L>( parent: Arc<LamellarTeam>, arch: L ) -> Option<Arc<LamellarTeam>>
where L: LamellarArch + Hash + 'static,

create a subteam containing any number of pe’s from this team using the provided LamellarArch (layout)

§Collective Operation

Requrires all PEs present within parent to enter the call otherwise deadlock will occur. Note that this does include the PEs that will not exist within the new subteam.

§Examples
 use lamellar::active_messaging::prelude::*;

 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
source

pub fn print_arch(&self)

Text based representation of the team

§One-sided Operation

the team architecture will only be printed on the calling PE

§Examples
 use lamellar::active_messaging::prelude::*;

 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
 even_pes.print_arch();
source

pub fn barrier(&self)

team wide synchronization method which blocks calling thread until all PEs in the team have entered

§Collective Operation

Requrires all PEs present within the team to enter the barrier otherwise deadlock will occur.

§Examples
 use lamellar::active_messaging::prelude::*;
 let world = LamellarWorldBuilder::new().build();
 let num_pes = world.num_pes();

 //create a team consisting of the "even" PEs in the world
 let even_pes = world.create_team_from_arch(StridedArch::new(
    0,                                      // start pe
    2,                                      // stride
    (num_pes as f64 / 2.0).ceil() as usize, //num_pes in team
 )).expect("PE in world team");
 //do some work
 even_pes.barrier(); //block until all PEs have entered the barrier

Trait Implementations§

source§

impl Debug for LamellarTeam

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for LamellarTeam

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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<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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TeamInto<U> for T
where U: TeamFrom<T>,

source§

fn team_into(self, team: &Pin<Arc<LamellarTeamRT>>) -> U

converts this type into the (usually inferred) input type
source§

impl<T, U> TeamTryInto<U> for T
where U: TeamTryFrom<T>,

source§

fn team_try_into(self, team: &Pin<Arc<LamellarTeamRT>>) -> Result<U, Error>

Trys to convert this type into the (usually inferred) input type
source§

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

§

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<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> SyncSend for T
where T: Sync + Send,