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
37567e75
Commit
37567e75
authored
1 month ago
by
Russel Arbore
Browse files
Options
Downloads
Patches
Plain Diff
Add extra dimensions to arrays when they'd cause a race otherwise
parent
65aae3b1
No related branches found
No related tags found
1 merge request
!198
Optimization for miranda
Pipeline
#201857
passed
1 month ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hercules_opt/src/gcm.rs
+46
-8
46 additions, 8 deletions
hercules_opt/src/gcm.rs
with
46 additions
and
8 deletions
hercules_opt/src/gcm.rs
+
46
−
8
View file @
37567e75
...
...
@@ -1053,19 +1053,22 @@ fn add_extra_collection_dims(
devices
:
&
Vec
<
Device
>
,
bbs
:
&
BasicBlocks
,
)
->
bool
{
if
devices
[
editor
.func_id
()
.idx
()]
==
Device
::
AsyncRust
&&
editor
.func
()
.name
==
"_1_laplacian_estimate"
{
if
devices
[
editor
.func_id
()
.idx
()]
==
Device
::
AsyncRust
{
// Look for collection constant nodes inside fork-joins that are mutated
// inside the fork-join, aren't involved in any of the reduces of the
// fork-join, and have a user that isn't a direct read based on all of
// the thread IDs.
let
nodes
=
&
editor
.func
()
.nodes
;
let
fco
=
&
objects
[
&
editor
.func_id
()];
for
id
in
editor
.node_ids
()
.filter
(|
id
|
{
nodes
[
id
.idx
()]
.is_constant
()
&&
!
editor
.get_type
(
typing
[
id
.idx
()])
.is_primitive
()
})
{
let
candidates
:
Vec
<
_
>
=
editor
.node_ids
()
.filter
(|
id
|
{
editor
.func
()
.nodes
[
id
.idx
()]
.is_constant
()
&&
!
editor
.get_type
(
typing
[
id
.idx
()])
.is_primitive
()
})
.collect
();
for
id
in
candidates
{
// Check all of the above conditions.
let
nodes
=
&
editor
.func
()
.nodes
;
if
editor
.get_users
(
id
)
.len
()
!=
1
{
continue
;
}
...
...
@@ -1115,7 +1118,42 @@ fn add_extra_collection_dims(
// We know that this collection needs to be replicated across the
// fork-join dimensions, so do that.
todo!
()
let
ty
=
typing
[
id
.idx
()];
let
num_dims
:
Vec
<
_
>
=
forks
.into_iter
()
.rev
()
.map
(|
id
|
nodes
[
id
.idx
()]
.try_fork
()
.unwrap
()
.1
.len
())
.collect
();
let
factors
=
forks
.into_iter
()
.rev
()
.flat_map
(|
id
|
nodes
[
id
.idx
()]
.try_fork
()
.unwrap
()
.1
.into_iter
())
.map
(|
dc
|
*
dc
)
.collect
();
let
array_ty
=
Type
::
Array
(
ty
,
factors
);
let
success
=
editor
.edit
(|
mut
edit
|
{
let
new_ty
=
edit
.add_type
(
array_ty
);
let
new_cons
=
edit
.add_zero_constant
(
new_ty
);
let
new_cons
=
edit
.add_node
(
Node
::
Constant
{
id
:
new_cons
});
let
mut
tids
=
vec!
[];
for
(
fork
,
num_dims
)
in
forks
.into_iter
()
.rev
()
.zip
(
num_dims
)
{
for
dim
in
0
..
num_dims
{
tids
.push
(
edit
.add_node
(
Node
::
ThreadID
{
control
:
*
fork
,
dimension
:
dim
,
}));
}
}
let
read
=
edit
.add_node
(
Node
::
Read
{
collect
:
new_cons
,
indices
:
Box
::
new
([
Index
::
Position
(
tids
.into_boxed_slice
())]),
});
edit
=
edit
.replace_all_uses
(
id
,
read
)
?
;
edit
=
edit
.delete_node
(
id
)
?
;
Ok
(
edit
)
});
assert!
(
success
);
return
true
;
}
}
false
...
...
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