Skip to content
Snippets Groups Projects
Commit 232e6627 authored by rarbore2's avatar rarbore2
Browse files

Misc.

parent ef4797ad
No related branches found
No related tags found
1 merge request!217Misc.
...@@ -221,6 +221,31 @@ fn preliminary_fixups( ...@@ -221,6 +221,31 @@ fn preliminary_fixups(
} }
} }
// Add region nodes between join nodes and loop headers to aid in block
// placement.
for (_, join) in fork_join_map {
let control_user = editor
.get_users(*join)
.filter(|id| nodes[id.idx()].is_control())
.next()
.unwrap();
if nodes[control_user.idx()].is_fork()
|| nodes[control_user.idx()]
.try_region()
.map(|preds| preds.len() > 1)
.unwrap_or(false)
{
let success = editor.edit(|mut edit| {
let region = edit.add_node(Node::Region {
preds: Box::new([*join]),
});
edit.replace_all_uses_where(*join, region, |id| *id == control_user)
});
assert!(success);
return true;
}
}
false false
} }
......
...@@ -5,6 +5,7 @@ use std::future::Future; ...@@ -5,6 +5,7 @@ use std::future::Future;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ptr::{copy_nonoverlapping, write_bytes, NonNull}; use std::ptr::{copy_nonoverlapping, write_bytes, NonNull};
use std::slice::{from_raw_parts, from_raw_parts_mut}; use std::slice::{from_raw_parts, from_raw_parts_mut};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::OnceLock; use std::sync::OnceLock;
/* /*
...@@ -928,3 +929,30 @@ unsafe impl GlobalAlloc for AlignedAlloc { ...@@ -928,3 +929,30 @@ unsafe impl GlobalAlloc for AlignedAlloc {
#[global_allocator] #[global_allocator]
static A: AlignedAlloc = AlignedAlloc; static A: AlignedAlloc = AlignedAlloc;
pub struct SpinBarrier {
num: usize,
waiting: AtomicUsize,
gen: AtomicUsize,
}
impl SpinBarrier {
pub const fn new(num: usize) -> Self {
SpinBarrier {
num,
waiting: AtomicUsize::new(0),
gen: AtomicUsize::new(0),
}
}
pub fn wait(&self) {
let old_gen = self.gen.load(Ordering::Acquire);
let old_waiting = self.waiting.fetch_add(1, Ordering::Relaxed);
if old_waiting + 1 == self.num {
self.waiting.store(0, Ordering::Relaxed);
self.gen.fetch_add(1, Ordering::Release);
} else {
while old_gen == self.gen.load(Ordering::Acquire) {}
}
}
}
...@@ -50,7 +50,7 @@ fork-tile[32, 0, false, true](init); ...@@ -50,7 +50,7 @@ fork-tile[32, 0, false, true](init);
let (outer, inner) = fork-reshape[[1], [0]](init); let (outer, inner) = fork-reshape[[1], [0]](init);
let init_body = outline(inner); let init_body = outline(inner);
inline(bfs@loop1, bfs@loop2); inline(bfs@cost_init, bfs@loop1, bfs@loop2);
delete-uncalled(*); delete-uncalled(*);
const-inline(*); const-inline(*);
simpl!(*); simpl!(*);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment