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
Merge requests
!192
Optimize edge detection
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Optimize edge detection
edge_opt
into
main
Overview
0
Commits
3
Pipelines
1
Changes
7
Merged
rarbore2
requested to merge
edge_opt
into
main
1 month ago
Overview
0
Commits
3
Pipelines
1
Changes
7
Expand
Forkify all loops in edge detection.
Use channels in RT backend to send data between async calls.
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
72411669
3 commits,
1 month ago
7 files
+
141
−
41
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
hercules_cg/src/rt.rs
+
43
−
15
Options
@@ -560,23 +560,33 @@ impl<'a> RTContext<'a> {
// same interface as AsyncRust functions.
let
block
=
&
mut
blocks
.get_mut
(
&
bb
)
.unwrap
()
.data
;
let
is_async
=
func
.schedules
[
id
.idx
()]
.contains
(
&
Schedule
::
AsyncCall
);
if
is_async
{
for
arg
in
args
{
if
let
Some
(
arc
)
=
self
.clone_arc
(
*
arg
,
false
)
{
write!
(
block
,
"{}"
,
arc
)
?
;
}
}
}
let
device
=
self
.devices
[
callee_id
.idx
()];
let
prefix
=
match
(
device
,
is_async
)
{
(
Device
::
AsyncRust
,
false
)
=>
""
,
(
_
,
false
)
=>
""
,
(
Device
::
AsyncRust
,
true
)
=>
"Some(::async_std::task::spawn("
,
(
_
,
true
)
=>
"Some(::async_std::task::spawn(async move {"
,
(
Device
::
AsyncRust
,
false
)
|
(
_
,
false
)
=>
{
format!
(
"{} = "
,
self
.get_value
(
id
,
bb
,
true
))
}
(
_
,
true
)
=>
format!
(
"{}::async_std::task::spawn(async move {{ async_call_sender_{}.send("
,
self
.clone_arc
(
id
,
true
)
.unwrap
(),
id
.idx
()
),
};
let
postfix
=
match
(
device
,
is_async
)
{
(
Device
::
AsyncRust
,
false
)
=>
".await"
,
(
_
,
false
)
=>
""
,
(
Device
::
AsyncRust
,
true
)
=>
"
)
)"
,
(
_
,
true
)
=>
"
}
))"
,
(
Device
::
AsyncRust
,
true
)
=>
"
.await).await}
)"
,
(
_
,
true
)
=>
")
.await}
)"
,
};
write!
(
block
,
"{} = {}{}("
,
self
.get_value
(
id
,
bb
,
true
),
"{}{}("
,
prefix
,
self
.module.functions
[
callee_id
.idx
()]
.name
)
?
;
@@ -1069,11 +1079,15 @@ impl<'a> RTContext<'a> {
}
// If the node is a call with an AsyncCall schedule, it should be
//
spawn
ed
as
a
task and awaited later
.
//
lower
ed
to
a
channel
.
let
is_async_call
=
func
.nodes
[
idx
]
.is_call
()
&&
func
.schedules
[
idx
]
.contains
(
&
Schedule
::
AsyncCall
);
if
is_async_call
{
write!
(
w
,
"let mut async_call_{} = None;"
,
idx
)
?
;
write!
(
w
,
"let mut async_call_channel_{} = ::async_std::channel::bounded(1);let async_call_sender_{} = ::std::sync::Arc::new(async_call_channel_{}.0);let async_call_receiver_{} = ::std::sync::Arc::new(async_call_channel_{}.1);"
,
idx
,
idx
,
idx
,
idx
,
idx
)
?
;
}
else
{
write!
(
w
,
@@ -1356,16 +1370,30 @@ impl<'a> RTContext<'a> {
}
else
if
func
.nodes
[
id
.idx
()]
.is_call
()
&&
func
.schedules
[
id
.idx
()]
.contains
(
&
Schedule
::
AsyncCall
)
{
format!
(
"async_call_{}{}"
,
id
.idx
(),
if
lhs
{
""
}
else
{
".unwrap().await"
}
)
assert!
(
!
lhs
);
format!
(
"async_call_receiver_{}.recv().await.unwrap()"
,
id
.idx
(),)
}
else
{
format!
(
"node_{}"
,
id
.idx
())
}
}
fn
clone_arc
(
&
self
,
id
:
NodeID
,
lhs
:
bool
)
->
Option
<
String
>
{
let
func
=
self
.get_func
();
if
func
.nodes
[
id
.idx
()]
.is_call
()
&&
func
.schedules
[
id
.idx
()]
.contains
(
&
Schedule
::
AsyncCall
)
{
let
kind
=
if
lhs
{
"sender"
}
else
{
"receiver"
};
Some
(
format!
(
"let async_call_{}_{} = async_call_{}_{}.clone();"
,
kind
,
id
.idx
(),
kind
,
id
.idx
()
))
}
else
{
None
}
}
fn
get_type
(
&
self
,
id
:
TypeID
)
->
&
'static
str
{
convert_type
(
&
self
.module.types
[
id
.idx
()])
}
Loading