Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static scheduler #241

Draft
wants to merge 109 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
7de874e
Bring in the FS scheduler from the manual example.
lsk567 Jun 26, 2023
48d5bbf
Merge branch 'main' into static-schedule
lsk567 Jun 26, 2023
0a76f87
Implement DU using a hyperperiod-based semantics.
lsk567 Jun 28, 2023
66b22cc
Merge branch 'main' into static-schedule
lsk567 Jun 28, 2023
2015f09
Support reactor-local time
erlingrj Jun 30, 2023
05622fd
Hide chain optimization for the FS scheduler
erlingrj Jun 30, 2023
4616369
Add the infrastructure for resetting is_present of ports on a per-rea…
erlingrj Jul 3, 2023
f3e3ba0
Merge branch 'main' into static-schedule
lsk567 Jul 6, 2023
5d79291
Merge branch 'static-schedule' into fs-erling
lsk567 Jul 10, 2023
bf504df
Merge pull request #247 from lf-lang/fs-erling
lsk567 Jul 10, 2023
bfe021d
Comment out lf_request_stop() macro
lsk567 Jul 10, 2023
3e4bd00
Change ADV to advance to absolute time wrt hyperperiod; change sync-a…
lsk567 Jul 10, 2023
995a014
Merge branch 'main' into static-schedule
lsk567 Jul 17, 2023
edcae4f
Support lf_schedule
lsk567 Jul 18, 2023
a6e08b3
Support lf_schedule with payloads, given limitations
lsk567 Jul 18, 2023
42cad35
Rename FS to STATIC
lsk567 Jul 18, 2023
e497088
Enable tracing for VM instructions
lsk567 Jul 20, 2023
6aab8ed
Remove tracing hacks
lsk567 Jul 20, 2023
d2f5c9a
Support better tracing experience by storing line numbers
lsk567 Jul 21, 2023
176b74a
Support ADDI and refactor
lsk567 Jul 21, 2023
f2cc481
Update ADV and ADV2
lsk567 Jul 21, 2023
321e17c
Update comments
lsk567 Jul 24, 2023
aafa8c7
Merge pull request #254 from lf-lang/var-refs-in-schedules
lsk567 Jul 24, 2023
402d1da
Remove variables hyperperiod and iteration
lsk567 Jul 24, 2023
fbdb4ac
Merge branch 'main' into static-schedule
lsk567 Jul 24, 2023
e606e51
Fix BIT
lsk567 Jul 24, 2023
f669991
Fix tracing
lsk567 Jul 24, 2023
26bb4af
Fix a bug when initializing time offsets
lsk567 Jul 25, 2023
26439fc
Merge branch 'main' into static-schedule
lsk567 Jul 28, 2023
e7eac8a
Merge branch 'main' into static-schedule
lsk567 Aug 6, 2023
2387ae6
Fix race condition by removing the reactor_reached_stop_tag array sin…
lsk567 Aug 6, 2023
0ffbcc4
Add branch instructions and no longer initialize offsets when initial…
lsk567 Aug 10, 2023
fc5fb2b
Remove debug message
lsk567 Aug 14, 2023
185a0ae
Merge branch 'main' into static-schedule
lsk567 Aug 15, 2023
2d3c89c
Add ADD, ADVI, JAL, JALR, and WLT instructions to deprecate SAC.
lsk567 Aug 22, 2023
ccedcab
Merge branch 'main' into static-schedule
lsk567 Aug 22, 2023
890c54e
Update PRET VM instructions to be more portable
erlingrj Sep 23, 2023
7bea24f
Merge branch 'main' into static-schedule
lsk567 Sep 25, 2023
740d5cc
Merge remote-tracking branch 'origin/static-schedule' into static-upd…
erlingrj Sep 25, 2023
ac59cfa
Merge pull request #277 from lf-lang/static-update-instr
erlingrj Sep 25, 2023
838ad16
Merge branch 'main' into static-schedule
lsk567 Oct 5, 2023
031412e
Remove unnecessary debug msg
lsk567 Oct 5, 2023
e9edc18
Add a schedule init function to deal with the compile-time constant i…
lsk567 Oct 12, 2023
d3d39e9
Extend environment for static scheduling
lsk567 Oct 16, 2023
bb5ae6d
Get a simple example to work
lsk567 Oct 16, 2023
4d32a5c
More tracepoints of the PretVM instructions
ChadliaJerad Oct 26, 2023
90e8c8b
Uncomment static scheduler trace points
ChadliaJerad Nov 12, 2023
e49225a
Merge branch 'main' into static-schedule
lsk567 Nov 15, 2023
d4a1127
Change STATIC to SCHED_STATIC
lsk567 Nov 15, 2023
ce03252
Update include guard
lsk567 Nov 20, 2023
8971b1f
Merge branch 'static-schedule' into static-schedule-explicit-triggers
lsk567 Dec 7, 2023
3e498c8
Add WIP
lsk567 Dec 14, 2023
ce9d422
Add header file for helper functions used in the static schedule
lsk567 Jan 6, 2024
0f30f05
Add WIP. SimpleConnection kind of works.
lsk567 Jan 20, 2024
2512f0c
Make SimpleConnection test case work
lsk567 Jan 25, 2024
4118922
Merge branch 'main' into static-schedule
lsk567 Feb 11, 2024
31428ab
Prune unused code in the static scheduler
lsk567 Feb 12, 2024
2fe28a6
Fix seg fault in BEQ
lsk567 Feb 25, 2024
7fd9ba0
Merge branch 'main' into static-schedule
lsk567 Feb 25, 2024
ebbdb7c
Get logical tag of EXE_starts and EXE_ends
erlingrj Feb 26, 2024
ccf50e5
Add a version of EXE tracing function specific for reactions, clean u…
lsk567 Feb 29, 2024
cac23fb
Merge pull request #367 from lf-lang/static-tracing
lsk567 Feb 29, 2024
a47356b
Update tracing and add debug flag to instructions
lsk567 Mar 6, 2024
261cb8b
Improve static tracing
lsk567 Mar 6, 2024
55bb599
Use spin wait and fix tracing
lsk567 Mar 7, 2024
57fffe1
Add WIP for chrome tracing
lsk567 Mar 9, 2024
3dbb4a1
Add WIP
lsk567 Mar 10, 2024
2d27f14
Only trace EXE now
lsk567 Mar 13, 2024
3635412
Fix unrecognized instruction error
lsk567 Mar 14, 2024
40b45dd
Implement a more flexible DU that decides between spinning and sleep …
lsk567 Mar 14, 2024
4c57e17
Increase spin wait threshold to 100 msec
lsk567 Mar 19, 2024
e27fcd9
Use spin wait for NP for fairness
lsk567 Mar 19, 2024
f783227
Merge branch 'static-schedule' into static-schedule-circular-buffer
lsk567 Mar 22, 2024
e89f09a
Use circular buffers
lsk567 Mar 22, 2024
ca533a9
Increase trace buffer and optimize circular buffer
lsk567 Mar 22, 2024
ec0f645
Increase trace buffer capacity to 64k
lsk567 Mar 22, 2024
d4af904
Drop the buffer capacity back to 32k
lsk567 Mar 22, 2024
732b13a
Drop to 16KB to try to get chrome to work
lsk567 Mar 22, 2024
4ad2cdf
Back to 32k
lsk567 Mar 22, 2024
05fcd4c
Use function pointers to execute virtual instructions. Stop tracing a…
lsk567 Mar 23, 2024
0969328
Remove tracepoints except reaction starts and stops
lsk567 Mar 23, 2024
884386e
ADVI stops clearing is_present fields
lsk567 Mar 24, 2024
bd0b5a2
Use pure spin wait in DU for evaluation
lsk567 Mar 24, 2024
c7b7285
Add useful debugging messages
lsk567 Mar 29, 2024
0e1e61b
Bump trace buffer to 128KB
lsk567 Mar 29, 2024
3a37b15
Stop setting the token field in lf_set
lsk567 Apr 7, 2024
2e0f2ff
Add debug messages back
lsk567 Apr 22, 2024
b230663
Revert "Stop setting the token field in lf_set"
lsk567 Jun 1, 2024
cd5a633
Merge branch 'static-schedule' into static-schedule-opt
lsk567 Jun 2, 2024
44313a2
Fix the incompatible conversion warning/error
lsk567 Jul 3, 2024
5f1c224
Merge branch 'static-schedule' into static-schedule-opt
lsk567 Aug 4, 2024
11dc8de
Fix JAL and update ADVI debug output
lsk567 Aug 14, 2024
7ab1111
Fix port setting for ADVI
lsk567 Aug 31, 2024
6188090
Combine spin wait and thread sleep, and adjust spin wait threshold
Sep 1, 2024
4c8f3fd
Merge branch 'main' into static-schedule
lsk567 Sep 24, 2024
d76e82e
Merge branch 'main' into static-schedule-merge
lsk567 Oct 7, 2024
08e2506
Get tracing to work and various fixes
lsk567 Oct 8, 2024
5874882
Fix tracing
lsk567 Oct 8, 2024
700835b
Remove an unused header
lsk567 Oct 9, 2024
998f555
Fix operand naming and add a debug message to BLT
lsk567 Oct 17, 2024
e8975a9
Merge branch 'main' into static-schedule
lsk567 Oct 21, 2024
51e63f6
Turn off -Werror for now
erlingrj Oct 24, 2024
1082131
Unify the semantics of ADV and ADVI
lsk567 Oct 24, 2024
1837c6c
Merge branch 'static-schedule' of https://github.com/lf-lang/reactor-…
erlingrj Oct 25, 2024
75df70f
Use lf_sleep instead of busywait
erlingrj Nov 7, 2024
9b4b818
Merge branch 'static-schedule' into static-use-lf-sleep
erlingrj Nov 7, 2024
e8f0d54
Typo
erlingrj Nov 8, 2024
6538c34
Merge pull request #495 from lf-lang/static-use-lf-sleep
lsk567 Nov 8, 2024
c63e804
Fix a race condition related to out-of-order execution
lsk567 Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ int lf_clock_cond_timedwait(lf_cond_t *cond, instant_t wakeup_time) {
// Remove any clock sync offset and call the Platform API.
clock_sync_remove_offset(&wakeup_time);
#endif
return _lf_cond_timedwait(cond, wakeup_time);
// return _lf_cond_timedwait(cond, wakeup_time);
while (lf_time_physical() < wakeup_time);
return true;
}
#endif
4 changes: 4 additions & 0 deletions core/lf_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ lf_token_t* _lf_new_token(token_type_t* type, void* value, size_t length) {
return result;
}

// FIXME (Shaokai): The function name is probably a misnomer.
// It should better be _lf_get_new_token.
// I also don't get why the token isn't simply returned, and
// _lf_free_token_value or _lf_done_using has to be called.
Comment on lines +239 to +242
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming _lf_get_token to _lf_get_new_token and clarify the function's logic.

The comments suggest that the function name _lf_get_token is a misnomer and should be renamed to _lf_get_new_token. Additionally, the logic of calling _lf_free_token_value or _lf_done_using should be clarified.

Would you like assistance in refactoring the function name and clarifying the logic?

lf_token_t* _lf_get_token(token_template_t* tmplt) {
if (tmplt->token != NULL) {
if (tmplt->token->ref_count == 1) {
Expand Down
4 changes: 3 additions & 1 deletion core/reactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ void lf_set_present(lf_port_base_t* port) {
int wait_until(environment_t* env, instant_t wakeup_time) {
if (!fast) {
LF_PRINT_LOG("Waiting for elapsed logical time " PRINTF_TIME ".", wakeup_time - start_time);
return lf_clock_interruptable_sleep_until_locked(env, wakeup_time);
// return lf_clock_interruptable_sleep_until_locked(env, wakeup_time);
while (lf_time_physical() < wakeup_time);
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using a busy-wait loop.

The busy-wait loop in the wait_until function can lead to high CPU usage. It is recommended to retain the original function call to lf_clock_interruptable_sleep_until_locked or replace it with a more efficient waiting mechanism.

- while (lf_time_physical() < wakeup_time);
+ return lf_clock_interruptable_sleep_until_locked(env, wakeup_time);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// return lf_clock_interruptable_sleep_until_locked(env, wakeup_time);
while (lf_time_physical() < wakeup_time);
return 0;
return lf_clock_interruptable_sleep_until_locked(env, wakeup_time);

}
return 0;
}
Expand Down
6 changes: 6 additions & 0 deletions core/reactor_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ void schedule_output_reactions(environment_t *env, reaction_t* reaction, int wor
downstream_reaction->is_STP_violated, downstream_reaction->name);
}
#endif
// FIXME (erj): This is super hacky and only a temporary fix.
#if defined REACTION_CHAIN_OPTIMIZATION
if (downstream_reaction != NULL && downstream_reaction != downstream_to_execute_now) {
num_downstream_reactions++;
// If there is exactly one downstream reaction that is enabled by this
Expand Down Expand Up @@ -897,6 +899,10 @@ void schedule_output_reactions(environment_t *env, reaction_t* reaction, int wor
_lf_trigger_reaction(env, downstream_reaction, worker);
}
}
#else
// Queue the reaction.
_lf_trigger_reaction(env, downstream_reaction, worker);
#endif
}
}
}
Expand Down
1 change: 1 addition & 0 deletions core/threaded/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set(
THREADED_SOURCES
reactor_threaded.c
scheduler_adaptive.c
scheduler_static.c
scheduler_GEDF_NP.c
scheduler_NP.c
scheduler_sync_tag_advance.c
Expand Down
Loading