dont consider imported resources in the lifetimes building

This commit is contained in:
janis 2026-10-25 02:49:20 +02:00
parent 88512b37ac
commit c0f60b890c
Signed by: janis
SSH key fingerprint: SHA256:bB1qbbqmDXZNT0KKD5c2Dfjg53JGhj7B3CFcLIzSqq8

View file

@ -69,16 +69,17 @@ pub struct ResourceInterference {
impl ResourceInterference {
/// 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 resources: Vec<_> = lifetimes
.iter()
.into_iter()
.inspect(|(id, _)| {
if **id > max_id {
max_id = **id;
if *id > max_id {
max_id = *id;
}
})
.map(|(&id, lifetime)| (id, *lifetime))
.collect();
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
// 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(1), ResourceId(0)));