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
...@@ -152,6 +152,7 @@ pub fn gcm( ...@@ -152,6 +152,7 @@ pub fn gcm(
let backing_allocation = object_allocation( let backing_allocation = object_allocation(
editor, editor,
typing, typing,
fork_join_nest,
&node_colors, &node_colors,
&alignments, &alignments,
&liveness, &liveness,
...@@ -1148,6 +1149,7 @@ fn add_extra_collection_dims( ...@@ -1148,6 +1149,7 @@ fn add_extra_collection_dims(
collect: new_cons, collect: new_cons,
indices: Box::new([Index::Position(tids.into_boxed_slice())]), indices: Box::new([Index::Position(tids.into_boxed_slice())]),
}); });
edit.sub_edit(id, new_cons);
edit = edit.replace_all_uses(id, read)?; edit = edit.replace_all_uses(id, read)?;
edit = edit.delete_node(id)?; edit = edit.delete_node(id)?;
Ok(edit) Ok(edit)
...@@ -1639,6 +1641,7 @@ fn type_size(edit: &mut FunctionEdit, ty_id: TypeID, alignments: &Vec<usize>) -> ...@@ -1639,6 +1641,7 @@ fn type_size(edit: &mut FunctionEdit, ty_id: TypeID, alignments: &Vec<usize>) ->
fn object_allocation( fn object_allocation(
editor: &mut FunctionEditor, editor: &mut FunctionEditor,
typing: &Vec<TypeID>, typing: &Vec<TypeID>,
fork_join_nest: &HashMap<NodeID, Vec<NodeID>>,
node_colors: &FunctionNodeColors, node_colors: &FunctionNodeColors,
alignments: &Vec<usize>, alignments: &Vec<usize>,
_liveness: &Liveness, _liveness: &Liveness,
...@@ -1664,7 +1667,7 @@ fn object_allocation( ...@@ -1664,7 +1667,7 @@ fn object_allocation(
} }
} }
Node::Call { Node::Call {
control: _, control,
function: callee, function: callee,
ref dynamic_constants, ref dynamic_constants,
args: _, args: _,
...@@ -1694,9 +1697,25 @@ fn object_allocation( ...@@ -1694,9 +1697,25 @@ fn object_allocation(
callee_backing_size, callee_backing_size,
&mut edit, &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 = edit.add_dynamic_constant(DynamicConstant::add(
*total, *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