dont consider imported resources in the lifetimes building
This commit is contained in:
parent
88512b37ac
commit
c0f60b890c
|
|
@ -69,16 +69,17 @@ pub struct ResourceInterference {
|
||||||
|
|
||||||
impl ResourceInterference {
|
impl ResourceInterference {
|
||||||
/// Build a symmetric interference graph from inclusive resource lifetimes.
|
/// Build a symmetric interference graph from inclusive resource lifetimes.
|
||||||
pub fn from_lifetimes(lifetimes: &HashMap<ResourceId, ResourceLifetime>) -> Self {
|
pub fn from_lifetimes(
|
||||||
|
lifetimes: impl IntoIterator<Item = (ResourceId, ResourceLifetime)>,
|
||||||
|
) -> Self {
|
||||||
let mut max_id = ResourceId(0);
|
let mut max_id = ResourceId(0);
|
||||||
let mut resources: Vec<_> = lifetimes
|
let mut resources: Vec<_> = lifetimes
|
||||||
.iter()
|
.into_iter()
|
||||||
.inspect(|(id, _)| {
|
.inspect(|(id, _)| {
|
||||||
if **id > max_id {
|
if *id > max_id {
|
||||||
max_id = **id;
|
max_id = *id;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|(&id, lifetime)| (id, *lifetime))
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut edges = vec![BTreeSet::new(); max_id.index() + 1];
|
let mut edges = vec![BTreeSet::new(); max_id.index() + 1];
|
||||||
|
|
@ -419,7 +420,14 @@ impl<'a> GraphCompiler<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let interference = ResourceInterference::from_lifetimes(&lifetimes);
|
let interference = ResourceInterference::from_lifetimes(
|
||||||
|
lifetimes
|
||||||
|
.iter()
|
||||||
|
// TODO: consider resource usage across multiple queues.
|
||||||
|
// when two resources do not overlap in time but their last-first commands are not connected via an edge in the dag, they must be marked as interfering.
|
||||||
|
.filter(|&(id, _)| self.resources[id.0 as usize].is_created())
|
||||||
|
.map(|(&id, &lifetime)| (id, lifetime)),
|
||||||
|
);
|
||||||
|
|
||||||
// Skeleton aliasing policy: resources with non-overlapping lifetimes may
|
// Skeleton aliasing policy: resources with non-overlapping lifetimes may
|
||||||
// share a heap offset. The graph test is equivalent to the previous
|
// share a heap offset. The graph test is equivalent to the previous
|
||||||
|
|
@ -895,7 +903,9 @@ mod tests {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
let interference = ResourceInterference::from_lifetimes(&lifetimes);
|
let interference = ResourceInterference::from_lifetimes(
|
||||||
|
lifetimes.iter().map(|(&id, &lifetime)| (id, lifetime)),
|
||||||
|
);
|
||||||
|
|
||||||
assert!(interference.interferes(ResourceId(0), ResourceId(1)));
|
assert!(interference.interferes(ResourceId(0), ResourceId(1)));
|
||||||
assert!(interference.interferes(ResourceId(1), ResourceId(0)));
|
assert!(interference.interferes(ResourceId(1), ResourceId(0)));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue