Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Hercules
Commits
1f1c6cb9
Commit
1f1c6cb9
authored
2 months ago
by
Xavier Routh
Browse files
Options
Downloads
Patches
Plain Diff
rewrite forkify as single edit per loop
parent
ab434198
No related branches found
No related tags found
2 merge requests
!157
Fork fission bufferize
,
!144
Forkify fixes
Pipeline
#201367
passed
2 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hercules_opt/src/forkify.rs
+40
-35
40 additions, 35 deletions
hercules_opt/src/forkify.rs
with
40 additions
and
35 deletions
hercules_opt/src/forkify.rs
+
40
−
35
View file @
1f1c6cb9
...
@@ -298,29 +298,11 @@ pub fn forkify_loop(
...
@@ -298,29 +298,11 @@ pub fn forkify_loop(
let
(
_
,
factors
)
=
function
.nodes
[
fork_id
.idx
()]
.try_fork
()
.unwrap
();
let
(
_
,
factors
)
=
function
.nodes
[
fork_id
.idx
()]
.try_fork
()
.unwrap
();
let
dimension
=
factors
.len
()
-
1
;
let
dimension
=
factors
.len
()
-
1
;
// Create ThreadID
// Start failable edit:
editor
.edit
(|
mut
edit
|
{
let
thread_id
=
Node
::
ThreadID
{
control
:
fork_id
,
dimension
:
dimension
,
};
let
thread_id_id
=
edit
.add_node
(
thread_id
);
// Replace uses that are inside with the thread id
edit
=
edit
.replace_all_uses_where
(
canonical_iv
.phi
(),
thread_id_id
,
|
node
|
{
loop_nodes
.contains
(
node
)
})
?
;
// Replace uses that are outside with DC - 1. Or just give up.
let
redcutionable_phis_and_init
:
Vec
<
(
_
,
NodeID
)
>
=
let
bound_dc_node
=
edit
.add_node
(
Node
::
DynamicConstant
{
id
:
bound_dc_id
});
reductionable_phis
.iter
()
.map
(|
reduction_phi
|
{
edit
=
edit
.replace_all_uses_where
(
canonical_iv
.phi
(),
bound_dc_node
,
|
node
|
{
!
loop_nodes
.contains
(
node
)
})
?
;
edit
.delete_node
(
canonical_iv
.phi
())
});
for
reduction_phi
in
reductionable_phis
{
let
LoopPHI
::
Reductionable
{
let
LoopPHI
::
Reductionable
{
phi
,
phi
,
data_cycle
:
_
,
data_cycle
:
_
,
...
@@ -342,12 +324,41 @@ pub fn forkify_loop(
...
@@ -342,12 +324,41 @@ pub fn forkify_loop(
.unwrap
()
.unwrap
()
.1
;
.1
;
editor
.edit
(|
mut
edit
|
{
(
reduction_phi
,
init
)
})
.collect
();
editor
.edit
(|
mut
edit
|
{
let
thread_id
=
Node
::
ThreadID
{
control
:
fork_id
,
dimension
:
dimension
,
};
let
thread_id_id
=
edit
.add_node
(
thread_id
);
// Replace uses that are inside with the thread id
edit
=
edit
.replace_all_uses_where
(
canonical_iv
.phi
(),
thread_id_id
,
|
node
|
{
loop_nodes
.contains
(
node
)
})
?
;
edit
=
edit
.delete_node
(
canonical_iv
.phi
())
?
;
for
(
reduction_phi
,
init
)
in
redcutionable_phis_and_init
{
let
LoopPHI
::
Reductionable
{
phi
,
data_cycle
:
_
,
continue_latch
,
is_associative
:
_
,
}
=
*
reduction_phi
else
{
panic!
();
};
let
reduce
=
Node
::
Reduce
{
let
reduce
=
Node
::
Reduce
{
control
:
join_id
,
control
:
join_id
,
init
,
init
,
reduct
:
continue_latch
,
reduct
:
continue_latch
,
};
};
let
reduce_id
=
edit
.add_node
(
reduce
);
let
reduce_id
=
edit
.add_node
(
reduce
);
if
(
!
edit
.get_node
(
init
)
.is_reduce
()
if
(
!
edit
.get_node
(
init
)
.is_reduce
()
...
@@ -375,20 +386,14 @@ pub fn forkify_loop(
...
@@ -375,20 +386,14 @@ pub fn forkify_loop(
edit
=
edit
.replace_all_uses_where
(
continue_latch
,
reduce_id
,
|
usee
|
{
edit
=
edit
.replace_all_uses_where
(
continue_latch
,
reduce_id
,
|
usee
|
{
!
loop_nodes
.contains
(
usee
)
&&
*
usee
!=
reduce_id
!
loop_nodes
.contains
(
usee
)
&&
*
usee
!=
reduce_id
})
?
;
})
?
;
edit
.delete_node
(
phi
)
edit
=
edit
.delete_node
(
phi
)
?
});
}
// Replace all uses of the loop header with the fork
editor
.edit
(|
edit
|
edit
.replace_all_uses
(
l
.header
,
fork_id
));
editor
.edit
(|
edit
|
edit
.replace_all_uses
(
loop_continue_projection
,
fork_id
));
}
editor
.edit
(|
edit
|
edit
.replace_all_uses
(
loop_exit_projection
,
join_id
));
edit
=
edit
.replace_all_uses
(
l
.header
,
fork_id
)
?
;
edit
=
edit
.replace_all_uses
(
loop_continue_projection
,
fork_id
)
?
;
edit
=
edit
.replace_all_uses
(
loop_exit_projection
,
join_id
)
?
;
// Get rid of loop condition
// DCE should get these, but delete them ourselves because we are nice :)
editor
.edit
(|
mut
edit
|
{
edit
=
edit
.delete_node
(
loop_continue_projection
)
?
;
edit
=
edit
.delete_node
(
loop_continue_projection
)
?
;
edit
=
edit
.delete_node
(
condition_node
)
?
;
// Might have to get rid of other users of this.
edit
=
edit
.delete_node
(
condition_node
)
?
;
// Might have to get rid of other users of this.
edit
=
edit
.delete_node
(
loop_exit_projection
)
?
;
edit
=
edit
.delete_node
(
loop_exit_projection
)
?
;
...
@@ -396,7 +401,7 @@ pub fn forkify_loop(
...
@@ -396,7 +401,7 @@ pub fn forkify_loop(
edit
=
edit
.delete_node
(
l
.header
)
?
;
edit
=
edit
.delete_node
(
l
.header
)
?
;
Ok
(
edit
)
Ok
(
edit
)
});
});
return
true
;
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment