Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rdfriese committed Nov 13, 2024
1 parent 89c43ac commit 74e7360
Show file tree
Hide file tree
Showing 47 changed files with 898 additions and 900 deletions.
12 changes: 8 additions & 4 deletions examples/array_examples/array_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,15 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let num_pes = world.num_pes();
let my_pe = world.my_pe();
let array_f64 = AtomicArray::<f64>::new(world.clone(), num_pes * 10, Distribution::Block).block(); //non intrinsic atomic, non bitwise
let array_f64 =
AtomicArray::<f64>::new(world.clone(), num_pes * 10, Distribution::Block).block(); //non intrinsic atomic, non bitwise
let array_u8 = AtomicArray::<u8>::new(world.clone(), num_pes * 10, Distribution::Block).block(); //intrinsic atomic, bitwise
let array_i128 = AtomicArray::<i128>::new(world.clone(), num_pes * 10, Distribution::Block).block(); //non intrinsic atomic, bitwise
let array_custom = AtomicArray::<Custom>::new(world.clone(), num_pes * 10, Distribution::Block).block(); //non intrinsic atomic, non bitwise
let _array_bool = AtomicArray::<bool>::new(world.clone(), num_pes * 10, Distribution::Block).block();
let array_i128 =
AtomicArray::<i128>::new(world.clone(), num_pes * 10, Distribution::Block).block(); //non intrinsic atomic, bitwise
let array_custom =
AtomicArray::<Custom>::new(world.clone(), num_pes * 10, Distribution::Block).block(); //non intrinsic atomic, non bitwise
let _array_bool =
AtomicArray::<bool>::new(world.clone(), num_pes * 10, Distribution::Block).block();

println!("ADD-----------------------");
test_add(array_f64.clone(), 0.0, 1.0);
Expand Down
11 changes: 2 additions & 9 deletions examples/array_examples/array_put_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,8 @@ fn main() {
UnsafeArray::<usize>::new(world.team(), total_len, Distribution::Block).await;
let cyclic_array =
UnsafeArray::<usize>::new(world.team(), total_len, Distribution::Cyclic).await;
let shared_mem_region = world
.alloc_shared_mem_region(total_len)
.await

.into(); //Convert into abstract LamellarMemoryRegion
let local_mem_region = world
.alloc_one_sided_mem_region(total_len)

.into();
let shared_mem_region = world.alloc_shared_mem_region(total_len).await.into(); //Convert into abstract LamellarMemoryRegion
let local_mem_region = world.alloc_one_sided_mem_region(total_len).into();
initialize_array(&block_array).await;
initialize_array(&cyclic_array).await;
initialize_mem_region(&shared_mem_region);
Expand Down
3 changes: 2 additions & 1 deletion examples/array_examples/atomic_compare_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ fn main() {
array.barrier();
array.print();

let array_2 = AtomicArray::<f32>::new(world.team(), num_pes * 100000, Distribution::Cyclic).block();
let array_2 =
AtomicArray::<f32>::new(world.team(), num_pes * 100000, Distribution::Cyclic).block();
array_2.dist_iter_mut().for_each(|x| x.store(0.0)).block();
array_2.barrier();

Expand Down
16 changes: 10 additions & 6 deletions examples/bandwidths/am_bw_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ fn main() {
if my_pe == num_pes - 1 {
for _j in (0..(2_u64.pow(exp))).step_by(num_bytes as usize) {
let sub_timer = Instant::now();
let _ = world.exec_am_pe(0,
DataAM {
array: array.clone(),
index: 0 as usize,
length: num_bytes as usize,
},).spawn();
let _ = world
.exec_am_pe(
0,
DataAM {
array: array.clone(),
index: 0 as usize,
length: num_bytes as usize,
},
)
.spawn();
sub_time += sub_timer.elapsed().as_secs_f64();
sum += num_bytes * 1 as u64;
cnt += 1;
Expand Down
4 changes: 1 addition & 3 deletions examples/bandwidths/get_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let num_pes = world.num_pes();
let mem_reg = world
.alloc_shared_mem_region::<u8>(MEMREG_LEN)
.block();
let mem_reg = world.alloc_shared_mem_region::<u8>(MEMREG_LEN).block();
let data = world.alloc_one_sided_mem_region::<u8>(MEMREG_LEN);
for j in 0..MEMREG_LEN as usize {
unsafe {
Expand Down
8 changes: 2 additions & 6 deletions examples/bandwidths/put_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let num_pes = world.num_pes();
let array = world
.alloc_shared_mem_region::<u8>(ARRAY_LEN)
.block();
let data = world
.alloc_one_sided_mem_region::<u8>(ARRAY_LEN)
;
let array = world.alloc_shared_mem_region::<u8>(ARRAY_LEN).block();
let data = world.alloc_one_sided_mem_region::<u8>(ARRAY_LEN);
unsafe {
for i in data.as_mut_slice().unwrap() {
*i = my_pe as u8;
Expand Down
3 changes: 2 additions & 1 deletion examples/bandwidths/unsafe_array_get_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let num_pes = world.num_pes();
let array: UnsafeArray<u8> = UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let array: UnsafeArray<u8> =
UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let data = world.alloc_one_sided_mem_region::<u8>(ARRAY_LEN);
unsafe {
for i in data.as_mut_slice().unwrap() {
Expand Down
3 changes: 2 additions & 1 deletion examples/bandwidths/unsafe_array_get_unchecked_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let num_pes = world.num_pes();
let array: UnsafeArray<u8> = UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let array: UnsafeArray<u8> =
UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let data = world.alloc_one_sided_mem_region::<u8>(ARRAY_LEN);
unsafe {
for i in data.as_mut_slice().unwrap() {
Expand Down
3 changes: 2 additions & 1 deletion examples/bandwidths/unsafe_array_put_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let num_pes = world.num_pes();
let array: UnsafeArray<u8> = UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let array: UnsafeArray<u8> =
UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let data = world.alloc_one_sided_mem_region::<u8>(ARRAY_LEN);
unsafe {
for i in data.as_mut_slice().unwrap() {
Expand Down
3 changes: 2 additions & 1 deletion examples/bandwidths/unsafe_array_put_unchecked_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let num_pes = world.num_pes();
let array: UnsafeArray<u8> = UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let array: UnsafeArray<u8> =
UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let data = world.alloc_one_sided_mem_region::<u8>(ARRAY_LEN);
unsafe {
for i in data.as_mut_slice().unwrap() {
Expand Down
7 changes: 5 additions & 2 deletions examples/bandwidths/unsafe_array_store_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let num_pes = world.num_pes();
let array: UnsafeArray<u8> = UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let array: UnsafeArray<u8> =
UnsafeArray::new(&world, ARRAY_LEN * num_pes, Distribution::Block).block();
let data = world.alloc_one_sided_mem_region::<u8>(ARRAY_LEN);
unsafe {
for i in data.as_mut_slice().unwrap() {
Expand Down Expand Up @@ -58,7 +59,9 @@ fn main() {

// array.get(ARRAY_LEN * (num_pes - 1), &sub_reg);
let _ = unsafe {
array.batch_store(ARRAY_LEN * (num_pes - 1), sub_reg.as_slice().unwrap()).spawn()
array
.batch_store(ARRAY_LEN * (num_pes - 1), sub_reg.as_slice().unwrap())
.spawn()
};
sub_time += sub_timer.elapsed().as_secs_f64();
sum += num_bytes * 1 as u64;
Expand Down
17 changes: 6 additions & 11 deletions examples/kernels/cached_am_gemm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ struct MatMulAM {
impl LamellarAM for MatMulAM {
async fn exec() {
let b = lamellar::world
.alloc_one_sided_mem_region::<f32>(self.b.block_size * self.b.block_size)
;
.alloc_one_sided_mem_region::<f32>(self.b.block_size * self.b.block_size);
get_sub_mat(&self.b, &b).await;
// we dont actually want to alloc a shared memory region as there is an implicit barrier here
// introduces sync point and potential for deadlock
Expand All @@ -120,9 +119,8 @@ impl LamellarAM for MatMulAM {
a.row_block = row;
let mut c = self.c.clone();
c.row_block = row;
let sub_a = lamellar::world
.alloc_one_sided_mem_region::<f32>(a.block_size * a.block_size)
;
let sub_a =
lamellar::world.alloc_one_sided_mem_region::<f32>(a.block_size * a.block_size);
get_sub_mat(&a, &sub_a).await; //this should be local copy so returns immediately
do_gemm(&sub_a, &b, c, self.block_size);
}
Expand Down Expand Up @@ -178,16 +176,13 @@ fn main() {

let a = world
.alloc_shared_mem_region::<f32>((m * n) / num_pes)
.block()
;
.block();
let b = world
.alloc_shared_mem_region::<f32>((n * p) / num_pes)
.block()
;
.block();
let c = world
.alloc_shared_mem_region::<f32>((m * p) / num_pes)
.block()
;
.block();
// let c2 = world.alloc_shared_mem_region::<f32>((m * p) / num_pes);
unsafe {
let mut cnt = my_pe as f32 * ((m * n) / num_pes) as f32;
Expand Down
9 changes: 2 additions & 7 deletions examples/rdma_examples/rdma_am.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ impl LamellarAM for RdmaAM {
}

//get the original nodes data
let local = lamellar::world
.alloc_one_sided_mem_region::<u8>(ARRAY_LEN)
;
let local = lamellar::world.alloc_one_sided_mem_region::<u8>(ARRAY_LEN);
let local_slice = unsafe { local.as_mut_slice().unwrap() };
local_slice[ARRAY_LEN - 1] = lamellar::num_pes as u8;
unsafe {
Expand Down Expand Up @@ -107,10 +105,7 @@ fn main() {
let world = lamellar::LamellarWorldBuilder::new().build();
let my_pe = world.my_pe();
let num_pes = world.num_pes();
let array = world
.alloc_shared_mem_region::<u8>(ARRAY_LEN)
.block()
;
let array = world.alloc_shared_mem_region::<u8>(ARRAY_LEN).block();
let local_array = world.alloc_one_sided_mem_region::<u8>(ARRAY_LEN);
unsafe {
for i in array.as_mut_slice().unwrap() {
Expand Down
5 changes: 1 addition & 4 deletions examples/rdma_examples/rdma_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ fn main() {
if num_pes > 1 {
// instatiates a shared memory region on every PE in world
// all other pes can put/get into this region
let array = world
.alloc_shared_mem_region::<u8>(ARRAY_LEN)
.block()
;
let array = world.alloc_shared_mem_region::<u8>(ARRAY_LEN).block();
let array_slice = unsafe { array.as_slice().unwrap() }; //we can unwrap because we know array is local
// instatiates a local array whos memory is registered with
// the underlying network device, so that it can be used
Expand Down
2 changes: 1 addition & 1 deletion src/active_messaging/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use crate::inventory;
pub use crate::lamellar_arch::*;
pub use crate::lamellar_team::LamellarTeam;
//#[doc(hidden)]
pub use crate::lamellar_team::{IntoLamellarTeam};
pub use crate::lamellar_team::IntoLamellarTeam;
pub use crate::lamellar_world::LamellarWorld;
pub use crate::lamellar_world::LamellarWorldBuilder;
pub use crate::LamellarEnv;
Expand Down
11 changes: 7 additions & 4 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,6 @@ impl<T: Dist> LamellarEnv for LamellarWriteArray<T> {
}
}


// private sealed trait
#[doc(hidden)]
pub trait InnerArray: Sized {
Expand Down Expand Up @@ -1076,7 +1075,8 @@ pub(crate) mod private {
where
F: LamellarActiveMessage + LocalAM + 'static,
{
self.team_rt().exec_am_local_tg(am, Some(self.team_counters()))
self.team_rt()
.exec_am_local_tg(am, Some(self.team_counters()))
}
fn exec_am_pe_tg<F>(&self, pe: usize, am: F) -> AmHandle<F::Output>
where
Expand All @@ -1103,15 +1103,18 @@ pub(crate) mod private {
where
F: RemoteActiveMessage + LamellarAM + AmDist,
{
self.team_rt().exec_am_all_tg(am, Some(self.team_counters()))
self.team_rt()
.exec_am_all_tg(am, Some(self.team_counters()))
}
}
}

/// Represents a distributed array, providing some convenience functions for getting simple information about the array.
/// This is mostly intended for use within the runtime (specifically for use in Proc Macros) but the available functions may be useful to endusers as well.
#[enum_dispatch(LamellarReadArray<T>,LamellarWriteArray<T>)]
pub trait LamellarArray<T: Dist>: private::LamellarArrayPrivate<T> + ActiveMessaging + LamellarEnv {
pub trait LamellarArray<T: Dist>:
private::LamellarArrayPrivate<T> + ActiveMessaging + LamellarEnv
{
// #[doc(alias("One-sided", "onesided"))]
/// Returns the team used to construct this array, the PEs in the team represent the same PEs which have a slice of data of the array
///
Expand Down
2 changes: 0 additions & 2 deletions src/array/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,8 +1166,6 @@ impl<T: Dist> AtomicArray<T> {
}
}



// #[async_trait]
impl<T: Dist + ArrayOps> AsyncTeamFrom<(Vec<T>, Distribution)> for AtomicArray<T> {
async fn team_from(input: (Vec<T>, Distribution), team: &Arc<LamellarTeam>) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/array/atomic/iteration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use crate::array::iterator::{
private::{InnerIter, Sealed},
LamellarArrayIterators, LamellarArrayMutIterators,
};
use crate::array::private::ArrayExecAm;
use crate::array::r#unsafe::private::UnsafeArrayInner;
use crate::array::*;
use crate::array::private::ArrayExecAm;
use crate::memregion::Dist;

use self::iterator::IterLockFuture;
Expand Down
5 changes: 3 additions & 2 deletions src/array/global_lock_atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,9 @@ impl<T: Dist> AsyncFrom<UnsafeArray<T>> for GlobalLockArray<T> {
async fn async_from(array: UnsafeArray<T>) -> Self {
// println!("GlobalLock from unsafe");
array.await_on_outstanding(DarcMode::GlobalLockArray).await;
let lock = GlobalRwDarc::new(array.team_rt(), ()).await.expect("PE in team");
let lock = GlobalRwDarc::new(array.team_rt(), ())
.await
.expect("PE in team");

GlobalLockArray {
lock: lock,
Expand All @@ -743,7 +745,6 @@ impl<T: Dist> AsyncFrom<UnsafeArray<T>> for GlobalLockArray<T> {
}
}


impl<T: Dist> From<GlobalLockArray<T>> for GlobalLockByteArray {
fn from(array: GlobalLockArray<T>) -> Self {
GlobalLockByteArray {
Expand Down
1 change: 0 additions & 1 deletion src/array/iterator/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::pin::Pin;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;


// trait Consumer{
// type Item;
// fn init(&self, start: usize, cnt: usize, _s: Sealed) -> Self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crate::array::operations::ArrayOps;
use crate::array::r#unsafe::private::UnsafeArrayInner;
use crate::array::{AsyncTeamFrom, AsyncTeamInto, Distribution};
use crate::barrier::BarrierHandle;
use crate::lamellar_env::LamellarEnv;
use crate::lamellar_request::LamellarRequest;
use crate::lamellar_task_group::TaskGroupLocalAmHandle;
use crate::lamellar_team::LamellarTeamRT;
use crate::memregion::Dist;
use crate::scheduler::LamellarTask;
use crate::warnings::RuntimeWarning;
use crate::lamellar_env::LamellarEnv;

use core::marker::PhantomData;
use futures_util::{ready, Future};
Expand Down
6 changes: 3 additions & 3 deletions src/array/iterator/distributed_iterator/skip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ pub struct Skip<I> {
}

impl<I: InnerIter> InnerIter for Skip<I> {
fn lock_if_needed(&self, _s: Sealed) -> Option<IterLockFuture> {
None
}
fn lock_if_needed(&self, _s: Sealed) -> Option<IterLockFuture> {
None
}
fn iter_clone(&self, _s: Sealed) -> Self {
Skip {
iter: self.iter.iter_clone(Sealed),
Expand Down
6 changes: 3 additions & 3 deletions src/array/iterator/distributed_iterator/step_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ pub struct StepBy<I> {
}

impl<I: InnerIter> InnerIter for StepBy<I> {
fn lock_if_needed(&self, _s: Sealed) -> Option<IterLockFuture> {
None
}
fn lock_if_needed(&self, _s: Sealed) -> Option<IterLockFuture> {
None
}
fn iter_clone(&self, _s: Sealed) -> Self {
StepBy {
iter: self.iter.iter_clone(Sealed),
Expand Down
2 changes: 1 addition & 1 deletion src/array/iterator/local_iterator/consumer/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use crate::array::iterator::{consumer::*, IterLockFuture};
use crate::array::operations::ArrayOps;
use crate::array::r#unsafe::private::UnsafeArrayInner;
use crate::array::{AsyncTeamFrom, AsyncTeamInto, Distribution};
use crate::lamellar_env::LamellarEnv;
use crate::lamellar_request::LamellarRequest;
use crate::lamellar_task_group::TaskGroupLocalAmHandle;
use crate::lamellar_team::LamellarTeamRT;
use crate::memregion::Dist;
use crate::scheduler::LamellarTask;
use crate::warnings::RuntimeWarning;
use crate::lamellar_env::LamellarEnv;

use core::marker::PhantomData;
use futures_util::{ready, Future};
Expand Down
Loading

0 comments on commit 74e7360

Please sign in to comment.