Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
fix: now aligned neighbors are correctly returned
Browse files Browse the repository at this point in the history
  • Loading branch information
PaoloPenazzi authored and lm98 committed Jul 27, 2023
1 parent fba8c89 commit e9f906f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/core/lang/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn rep<A: Copy + 'static>(mut vm: RoundVM, init: impl Fn() -> A, fun: impl F

pub fn foldhood<A: Copy + 'static + Debug>(mut vm: RoundVM, init: impl Fn() -> A, aggr: impl Fn(A, A) -> A, expr: impl Fn(RoundVM) -> (RoundVM, A)) -> (RoundVM, A) {
// here we do nest_in after retrieving the neighbours because otherwise it would disalign the device
let nbrs = vm.aligned_neighbours().clone();
let nbrs = vm.aligned_neighbours::<A>().clone();
vm.nest_in(FoldHood(vm.index().clone()));
let (vm_, preval) = expr(vm);
let (mut vm__, local_init) = locally(vm_, |vm_| (vm_, init()));
Expand Down
2 changes: 1 addition & 1 deletion src/core/path/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Slot {
match self {
Slot::Nbr(index) => "Nbr(".to_owned() + &index.to_string() + ")",
Slot::Rep(index) => "Rep(".to_owned() + &index.to_string() + ")",
Slot::FoldHood(index) => "FoldHood".to_owned() + &index.to_string() + ")",
Slot::FoldHood(index) => "FoldHood(".to_owned() + &index.to_string() + ")",
Slot::Branch(index) => "Branch(".to_owned() + &index.to_string() + ")",
Slot::Exchange(index) => "Exchange(".to_owned() + &index.to_string() + ")",
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/vm/round_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl RoundVM {
/// # Returns
///
/// A vector of aligned neighbor identifiers.
pub fn aligned_neighbours(&self) -> Vec<i32> {
pub fn aligned_neighbours<A: 'static>(&self) -> Vec<i32> {
let mut tmp: Vec<i32> = Vec::new();
if !self.isolated {
tmp = self
Expand All @@ -226,7 +226,7 @@ impl RoundVM {
.filter(|(id, _)| id.clone() != &self.self_id())
.filter(|(_, export)| {
self.status.path.is_root()
|| export.get::<Box<dyn Any>>(&self.status.path).is_some()
|| export.get::<A>(&self.status.path).is_some()
})
.map(|(id, _)| id.clone())
.collect();
Expand Down Expand Up @@ -398,7 +398,7 @@ mod tests {
#[test]
fn test_aligned_neighbours() {
let vm = round_vm_builder();
assert_eq!(vm.aligned_neighbours(), vec![7, 0])
assert_eq!(vm.aligned_neighbours::<i32>(), vec![7, 0])
}

#[test]
Expand Down

0 comments on commit e9f906f

Please sign in to comment.