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
impl LamellarTeam
sourcepub fn get_pes(&self) -> Vec<usize>
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);
}
sourcepub fn num_pes(&self) -> usize
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());
sourcepub fn num_threads_per_pe(&self) -> usize
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());
sourcepub fn world_pe_id(&self) -> usize
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());
sourcepub fn team_pe_id(&self) -> Result<usize, IdError>
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);
}
sourcepub fn create_subteam_from_arch<L>(
parent: Arc<LamellarTeam>,
arch: L
) -> Option<Arc<LamellarTeam>>where
L: LamellarArch + Hash + 'static,
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");
sourcepub fn print_arch(&self)
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();
sourcepub fn barrier(&self)
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