Skip to content
Snippets Groups Projects
Commit 2b60a19f authored by Russel Arbore's avatar Russel Arbore
Browse files

Allocate more memory for calls inside fork-joins

parent 3d1e5b15
No related branches found
No related tags found
1 merge request!198Optimization for miranda
Pipeline #201859 passed
This commit is part of merge request !198. Comments created here will be created in the context of that merge request.
......@@ -152,6 +152,7 @@ pub fn gcm(
let backing_allocation = object_allocation(
editor,
typing,
fork_join_nest,
&node_colors,
&alignments,
&liveness,
......@@ -1148,6 +1149,7 @@ fn add_extra_collection_dims(
collect: new_cons,
indices: Box::new([Index::Position(tids.into_boxed_slice())]),
});
edit.sub_edit(id, new_cons);
edit = edit.replace_all_uses(id, read)?;
edit = edit.delete_node(id)?;
Ok(edit)
......@@ -1639,6 +1641,7 @@ fn type_size(edit: &mut FunctionEdit, ty_id: TypeID, alignments: &Vec<usize>) ->
fn object_allocation(
editor: &mut FunctionEditor,
typing: &Vec<TypeID>,
fork_join_nest: &HashMap<NodeID, Vec<NodeID>>,
node_colors: &FunctionNodeColors,
alignments: &Vec<usize>,
_liveness: &Liveness,
......@@ -1664,7 +1667,7 @@ fn object_allocation(
}
}
Node::Call {
control: _,
control,
function: callee,
ref dynamic_constants,
args: _,
......@@ -1694,9 +1697,25 @@ fn object_allocation(
callee_backing_size,
&mut edit,
);
// Multiply the backing allocation size of the
// callee by the number of parallel threads that
// will call the function.
let forks = &fork_join_nest[&control];
let factors: Vec<_> = forks
.into_iter()
.rev()
.flat_map(|id| edit.get_node(*id).try_fork().unwrap().1.into_iter())
.map(|dc| *dc)
.collect();
let mut multiplied_callee_backing_size = callee_backing_size;
for factor in factors {
multiplied_callee_backing_size = edit.add_dynamic_constant(
DynamicConstant::mul(multiplied_callee_backing_size, factor),
);
}
*total = edit.add_dynamic_constant(DynamicConstant::add(
*total,
callee_backing_size,
multiplied_callee_backing_size,
));
}
}
......
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