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
b99128b7
Commit
b99128b7
authored
4 months ago
by
Xavier Routh
Browse files
Options
Downloads
Patches
Plain Diff
forkify more aggressively
parent
878956fd
No related branches found
No related tags found
No related merge requests found
Pipeline
#201638
passed
4 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hercules_opt/src/forkify.rs
+9
-41
9 additions, 41 deletions
hercules_opt/src/forkify.rs
with
9 additions
and
41 deletions
hercules_opt/src/forkify.rs
+
9
−
41
View file @
b99128b7
...
@@ -183,8 +183,7 @@ pub fn forkify_loop(
...
@@ -183,8 +183,7 @@ pub fn forkify_loop(
let
reductionable_phis
:
Vec
<
_
>
=
analyze_phis
(
&
editor
,
&
l
,
&
candidate_phis
,
&
loop_nodes
)
let
reductionable_phis
:
Vec
<
_
>
=
analyze_phis
(
&
editor
,
&
l
,
&
candidate_phis
,
&
loop_nodes
)
.into_iter
()
.into_iter
()
.collect
();
.collect
();
// TODO: Handle multiple loop body lasts.
// If there are multiple candidates for loop body last, return false.
if
editor
if
editor
.get_uses
(
loop_if
)
.get_uses
(
loop_if
)
.filter
(|
id
|
l
.control
[
id
.idx
()])
.filter
(|
id
|
l
.control
[
id
.idx
()])
...
@@ -417,9 +416,9 @@ nest! {
...
@@ -417,9 +416,9 @@ nest! {
continue_latch
:
NodeID
,
continue_latch
:
NodeID
,
is_associative
:
bool
,
is_associative
:
bool
,
},
},
LoopDependant
(
NodeID
),
OutsideUse
(
NodeID
),
C
on
trolDependant
(
NodeID
),
// This phi is redcutionable, but its cycle might depend on internal control within the loop.
N
on
Cyclic
(
NodeID
),
UsedByDependant
(
NodeID
),
}
}
}
}
...
@@ -427,9 +426,8 @@ impl LoopPHI {
...
@@ -427,9 +426,8 @@ impl LoopPHI {
pub
fn
get_phi
(
&
self
)
->
NodeID
{
pub
fn
get_phi
(
&
self
)
->
NodeID
{
match
self
{
match
self
{
LoopPHI
::
Reductionable
{
phi
,
..
}
=>
*
phi
,
LoopPHI
::
Reductionable
{
phi
,
..
}
=>
*
phi
,
LoopPHI
::
LoopDependant
(
node_id
)
=>
*
node_id
,
LoopPHI
::
OutsideUse
(
node_id
)
=>
*
node_id
,
LoopPHI
::
UsedByDependant
(
node_id
)
=>
*
node_id
,
LoopPHI
::
NonCyclic
(
node_id
)
=>
*
node_id
,
LoopPHI
::
ControlDependant
(
node_id
)
=>
*
node_id
,
}
}
}
}
}
}
...
@@ -500,42 +498,12 @@ pub fn analyze_phis<'a>(
...
@@ -500,42 +498,12 @@ pub fn analyze_phis<'a>(
let
uses
=
walk_all_uses_stop_on
(
loop_continue_latch
,
editor
,
stop_on
.clone
());
let
uses
=
walk_all_uses_stop_on
(
loop_continue_latch
,
editor
,
stop_on
.clone
());
let
users
=
walk_all_users_stop_on
(
*
phi
,
editor
,
stop_on
.clone
());
let
users
=
walk_all_users_stop_on
(
*
phi
,
editor
,
stop_on
.clone
());
let
other_stop_on
:
HashSet
<
NodeID
>
=
editor
.node_ids
()
.filter
(|
node
|
{
let
data
=
&
editor
.func
()
.nodes
[
node
.idx
()];
// Phi, Reduce
if
data
.is_phi
()
{
return
true
;
}
if
data
.is_reduce
()
{
return
true
;
}
// External Control
if
data
.is_control
()
{
return
true
;
}
return
false
;
})
.collect
();
let
mut
uses_for_dependance
=
walk_all_users_stop_on
(
loop_continue_latch
,
editor
,
other_stop_on
);
let
set1
:
HashSet
<
_
>
=
HashSet
::
from_iter
(
uses
);
let
set1
:
HashSet
<
_
>
=
HashSet
::
from_iter
(
uses
);
let
set2
:
HashSet
<
_
>
=
HashSet
::
from_iter
(
users
);
let
set2
:
HashSet
<
_
>
=
HashSet
::
from_iter
(
users
);
let
intersection
:
HashSet
<
_
>
=
set1
.intersection
(
&
set2
)
.cloned
()
.collect
();
let
intersection
:
HashSet
<
_
>
=
set1
.intersection
(
&
set2
)
.cloned
()
.collect
();
// If this phi uses any other phis the node is loop dependant,
if
intersection
.clone
()
.iter
()
.next
()
.is_some
()
{
// we use `phis` because this phi can actually contain the loop iv and its fine.
if
uses_for_dependance
.any
(|
node
|
phis
.contains
(
&
node
)
&&
node
!=
*
phi
)
{
LoopPHI
::
LoopDependant
(
*
phi
)
}
else
if
intersection
.clone
()
.iter
()
.next
()
.is_some
()
{
// PHIs on the frontier of the uses by the candidate phi, i.e in uses_for_dependance need
// PHIs on the frontier of the uses by the candidate phi, i.e in uses_for_dependance need
// to have headers that postdominate the loop continue latch. The value of the PHI used needs to be defined
// to have headers that postdominate the loop continue latch. The value of the PHI used needs to be defined
// by the time the reduce is triggered (at the end of the loop's internal control).
// by the time the reduce is triggered (at the end of the loop's internal control).
...
@@ -555,7 +523,7 @@ pub fn analyze_phis<'a>(
...
@@ -555,7 +523,7 @@ pub fn analyze_phis<'a>(
// 3) Split the cycle into two phis, add them or multiply them together at the end.
// 3) Split the cycle into two phis, add them or multiply them together at the end.
// 4) Split the cycle into two reduces, add them or multiply them together at the end.
// 4) Split the cycle into two reduces, add them or multiply them together at the end.
// Somewhere else should handle this.
// Somewhere else should handle this.
return
LoopPHI
::
LoopDependant
(
*
phi
);
return
LoopPHI
::
OutsideUse
(
*
phi
);
}
}
// FIXME: Do we want to calculate associativity here, there might be a case where this information is used in forkify
// FIXME: Do we want to calculate associativity here, there might be a case where this information is used in forkify
...
@@ -571,7 +539,7 @@ pub fn analyze_phis<'a>(
...
@@ -571,7 +539,7 @@ pub fn analyze_phis<'a>(
}
}
}
else
{
}
else
{
// No cycles exist, this isn't a reduction.
// No cycles exist, this isn't a reduction.
LoopPHI
::
LoopDependant
(
*
phi
)
LoopPHI
::
NonCyclic
(
*
phi
)
}
}
})
})
}
}
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