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
84dfd900
Commit
84dfd900
authored
1 month ago
by
Russel Arbore
Browse files
Options
Downloads
Patches
Plain Diff
Inline dynamic constants
parent
4572a7ec
No related branches found
No related tags found
1 merge request
!202
Round 1 of rodinia schedule optimization
Pipeline
#201898
passed
1 month ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hercules_opt/src/inline.rs
+15
-32
15 additions, 32 deletions
hercules_opt/src/inline.rs
juno_samples/rodinia/bfs/src/bfs.jn
+1
-1
1 addition, 1 deletion
juno_samples/rodinia/bfs/src/bfs.jn
with
16 additions
and
33 deletions
hercules_opt/src/inline.rs
+
15
−
32
View file @
84dfd900
...
@@ -255,16 +255,6 @@ impl ParameterLattice {
...
@@ -255,16 +255,6 @@ impl ParameterLattice {
}
}
}
}
fn
try_const_dc
(
self
,
dcs
:
Ref
<
'_
,
Vec
<
DynamicConstant
>>
)
->
Option
<
usize
>
{
if
let
ParameterLattice
::
DynamicConstant
(
id
,
_
)
=
self
&&
let
DynamicConstant
::
Constant
(
val
)
=
&
dcs
[
id
.idx
()]
{
Some
(
*
val
)
}
else
{
None
}
}
fn
meet
(
&
mut
self
,
b
:
Self
,
cons
:
Ref
<
'_
,
Vec
<
Constant
>>
,
dcs
:
Ref
<
'_
,
Vec
<
DynamicConstant
>>
)
{
fn
meet
(
&
mut
self
,
b
:
Self
,
cons
:
Ref
<
'_
,
Vec
<
Constant
>>
,
dcs
:
Ref
<
'_
,
Vec
<
DynamicConstant
>>
)
{
use
ParameterLattice
::
*
;
use
ParameterLattice
::
*
;
*
self
=
match
(
*
self
,
b
)
{
*
self
=
match
(
*
self
,
b
)
{
...
@@ -312,8 +302,7 @@ impl ParameterLattice {
...
@@ -312,8 +302,7 @@ impl ParameterLattice {
*
*
* 1. Not marked as entry.
* 1. Not marked as entry.
* 2. At every call site, a particular parameter is always a specific constant
* 2. At every call site, a particular parameter is always a specific constant
* or dynamic constant OR a particular dynamic constant parameter is always a
* or dynamic constant.
* specific constant.
*
*
* These functions can have that constant "inlined" - the parameter is removed
* These functions can have that constant "inlined" - the parameter is removed
* and all uses of the parameter becomes uses of the constant directly.
* and all uses of the parameter becomes uses of the constant directly.
...
@@ -327,16 +316,14 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
...
@@ -327,16 +316,14 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
continue
;
continue
;
}
}
// Figure out what we know about the parameters (both normal and dynamic
// Figure out what we know about the parameters to this function.
// constant) to this function.
let
mut
param_lattice
=
vec!
[
ParameterLattice
::
Top
;
func
.param_types
.len
()];
let
mut
param_lattice
=
vec!
[
ParameterLattice
::
Top
;
func
.param_types
.len
()];
let
mut
dc_param_lattice
=
vec!
[
ParameterLattice
::
Top
;
func
.num_dynamic_constants
as
usize
];
let
mut
callers
=
vec!
[];
let
mut
callers
=
vec!
[];
for
caller
in
callgraph
.get_callers
(
func_id
)
{
for
caller
in
callgraph
.get_callers
(
func_id
)
{
let
editor
=
&
editors
[
caller
.idx
()];
let
editor
=
&
editors
[
caller
.idx
()];
let
nodes
=
&
editor
.func
()
.nodes
;
let
nodes
=
&
editor
.func
()
.nodes
;
for
id
in
editor
.node_ids
()
{
for
id
in
editor
.node_ids
()
{
if
let
Some
((
_
,
callee
,
dc_args
,
args
))
=
nodes
[
id
.idx
()]
.try_call
()
if
let
Some
((
_
,
callee
,
_
,
args
))
=
nodes
[
id
.idx
()]
.try_call
()
&&
callee
==
func_id
&&
callee
==
func_id
{
{
if
editor
.is_mutable
(
id
)
{
if
editor
.is_mutable
(
id
)
{
...
@@ -348,31 +335,16 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
...
@@ -348,31 +335,16 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
editor
.get_dynamic_constants
(),
editor
.get_dynamic_constants
(),
);
);
}
}
for
(
idx
,
id
)
in
dc_args
.into_iter
()
.enumerate
()
{
let
lattice
=
ParameterLattice
::
DynamicConstant
(
*
id
,
func_id
);
dc_param_lattice
[
idx
]
.meet
(
lattice
,
editor
.get_constants
(),
editor
.get_dynamic_constants
(),
);
}
}
else
{
}
else
{
// If we can't modify the call node in the caller, then
// If we can't modify the call node in the caller, then
// we can't perform the inlining.
// we can't perform the inlining.
param_lattice
=
vec!
[
ParameterLattice
::
Bottom
;
func
.param_types
.len
()];
param_lattice
=
vec!
[
ParameterLattice
::
Bottom
;
func
.param_types
.len
()];
dc_param_lattice
=
vec!
[
ParameterLattice
::
Bottom
;
func
.num_dynamic_constants
as
usize
];
}
}
callers
.push
((
caller
,
id
));
callers
.push
((
caller
,
id
));
}
}
}
}
}
}
if
param_lattice
.iter
()
.all
(|
v
|
*
v
==
ParameterLattice
::
Bottom
)
if
param_lattice
.iter
()
.all
(|
v
|
*
v
==
ParameterLattice
::
Bottom
)
{
&&
dc_param_lattice
.iter
()
.all
(|
v
|
*
v
==
ParameterLattice
::
Bottom
)
{
continue
;
continue
;
}
}
...
@@ -392,6 +364,17 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
...
@@ -392,6 +364,17 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
if
let
Some
(
node
)
=
match
param_lattice
[
idx
]
{
if
let
Some
(
node
)
=
match
param_lattice
[
idx
]
{
ParameterLattice
::
Top
=>
Some
(
Node
::
Undef
{
ty
:
param_tys
[
idx
]
}),
ParameterLattice
::
Top
=>
Some
(
Node
::
Undef
{
ty
:
param_tys
[
idx
]
}),
ParameterLattice
::
Constant
(
id
)
=>
Some
(
Node
::
Constant
{
id
}),
ParameterLattice
::
Constant
(
id
)
=>
Some
(
Node
::
Constant
{
id
}),
ParameterLattice
::
DynamicConstant
(
id
,
_
)
=>
{
// Rust moment.
let
maybe_cons
=
edit
.get_dynamic_constant
(
id
)
.try_constant
();
if
let
Some
(
val
)
=
maybe_cons
{
Some
(
Node
::
DynamicConstant
{
id
:
edit
.add_dynamic_constant
(
DynamicConstant
::
Constant
(
val
)),
})
}
else
{
None
}
}
_
=>
None
,
_
=>
None
,
}
&&
let
Some
(
ids
)
=
param_idx_to_ids
.get
(
&
idx
)
}
&&
let
Some
(
ids
)
=
param_idx_to_ids
.get
(
&
idx
)
{
{
...
...
This diff is collapsed.
Click to expand it.
juno_samples/rodinia/bfs/src/bfs.jn
+
1
−
1
View file @
84dfd900
...
@@ -13,7 +13,7 @@ fn bfs<n, m: usize>(graph_nodes: Node[n], source: u32, edges: u32[m]) -> i32[n]
...
@@ -13,7 +13,7 @@ fn bfs<n, m: usize>(graph_nodes: Node[n], source: u32, edges: u32[m]) -> i32[n]
let
visited
:
bool
[
n
];
let
visited
:
bool
[
n
];
visited
[
source
as
u64
]
=
true
;
visited
[
source
as
u64
]
=
true
;
@
cost
let
cost
:
i32
[
n
];
@
cost
@
cost_init
let
cost
:
i32
[
n
];
@
cost_init
for
i
in
0
..
n
{
@
cost_init
for
i
in
0
..
n
{
cost
[
i
]
=
-
1
;
cost
[
i
]
=
-
1
;
}
}
...
...
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