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
1b78bc2e
Commit
1b78bc2e
authored
3 weeks ago
by
Russel Arbore
Browse files
Options
Downloads
Patches
Plain Diff
Refactor infer parallelreduce
parent
da2cf755
No related branches found
No related tags found
1 merge request
!206
More misc. rodinia opts
Pipeline
#201946
canceled
3 weeks ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hercules_opt/src/schedule.rs
+11
-35
11 additions, 35 deletions
hercules_opt/src/schedule.rs
juno_samples/rodinia/backprop/src/cpu.sch
+1
-0
1 addition, 0 deletions
juno_samples/rodinia/backprop/src/cpu.sch
with
12 additions
and
35 deletions
hercules_opt/src/schedule.rs
+
11
−
35
View file @
1b78bc2e
use
std
::
collections
::{
BTreeSet
,
HashMap
,
HashSet
};
use
std
::
iter
::
once
;
use
hercules_ir
::
def_use
::
*
;
use
hercules_ir
::
ir
::
*
;
use
crate
::
*
;
...
...
@@ -42,6 +42,10 @@ pub fn infer_parallel_reduce(
fork_join_map
:
&
HashMap
<
NodeID
,
NodeID
>
,
reduce_cycles
:
&
HashMap
<
NodeID
,
HashSet
<
NodeID
>>
,
)
{
let
join_fork_map
:
HashMap
<
_
,
_
>
=
fork_join_map
.into_iter
()
.map
(|(
fork
,
join
)|
(
*
join
,
*
fork
))
.collect
();
for
id
in
editor
.node_ids
()
{
let
func
=
editor
.func
();
if
!
func
.nodes
[
id
.idx
()]
.is_reduce
()
{
...
...
@@ -98,40 +102,11 @@ pub fn infer_parallel_reduce(
&&
*
collect
==
last_reduce
&&
!
reduce_cycles
[
&
last_reduce
]
.contains
(
data
)
{
// If there is a Write-Reduce tight cycle, get the position indices.
let
positions
=
indices
.iter
()
.filter_map
(|
index
|
{
if
let
Index
::
Position
(
indices
)
=
index
{
Some
(
indices
)
}
else
{
None
}
})
.flat_map
(|
pos
|
pos
.iter
());
// Get the Forks corresponding to uses of bare ThreadIDs.
let
fork_thread_id_pairs
=
positions
.filter_map
(|
id
|
{
if
let
Node
::
ThreadID
{
control
,
dimension
}
=
func
.nodes
[
id
.idx
()]
{
Some
((
control
,
dimension
))
}
else
{
None
}
});
let
mut
forks
=
HashMap
::
<
NodeID
,
Vec
<
usize
>>
::
new
();
for
(
fork
,
dim
)
in
fork_thread_id_pairs
{
forks
.entry
(
fork
)
.or_default
()
.push
(
dim
);
}
// Check if one of the Forks correspond to the Join associated with
// the Reduce being considered, and has all of its dimensions
// represented in the indexing.
let
is_parallel
=
forks
.into_iter
()
.any
(|(
id
,
mut
rep_dims
)|
{
rep_dims
.sort
();
rep_dims
.dedup
();
fork_join_map
[
&
id
]
==
first_control
.unwrap
()
&&
func
.nodes
[
id
.idx
()]
.try_fork
()
.unwrap
()
.1
.len
()
==
rep_dims
.len
()
});
let
is_parallel
=
indices_parallel_over_forks
(
editor
,
indices
,
once
(
join_fork_map
[
&
first_control
.unwrap
()]),
);
if
is_parallel
{
editor
.edit
(|
edit
|
edit
.add_schedule
(
id
,
Schedule
::
ParallelReduce
));
...
...
@@ -145,6 +120,7 @@ pub fn infer_parallel_reduce(
* operands must be the Reduce node, and all other operands must not be in the
* Reduce node's cycle.
*/
#[rustfmt::skip]
pub
fn
infer_monoid_reduce
(
editor
:
&
mut
FunctionEditor
,
reduce_cycles
:
&
HashMap
<
NodeID
,
HashSet
<
NodeID
>>
,
...
...
This diff is collapsed.
Click to expand it.
juno_samples/rodinia/backprop/src/cpu.sch
+
1
−
0
View file @
1b78bc2e
...
...
@@ -23,6 +23,7 @@ fixpoint {
fork-guard-elim(*);
fork-coalesce(*);
}
reduce-slf(*);
simpl!(*);
fork-split(*);
...
...
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