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 #1830

Open
wants to merge 299 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
299 commits
Select commit Hold shift + click to select a range
94adb28
Refactor to support compiling fragments of a state space diagram
lsk567 Jul 13, 2023
26e07d8
Generate instances for built-in triggers
lsk567 Jul 14, 2023
5a23eda
Major refactoring of the pipeline
lsk567 Jul 14, 2023
cfd1599
Refactor DAG generation
lsk567 Jul 16, 2023
c177c25
Make generating periodic fragments work properly.
lsk567 Jul 17, 2023
42b4f31
Add a simple test program
lsk567 Jul 17, 2023
221f450
When generating DAGs, connect an earlier reaction invocation to a SYN…
lsk567 Jul 17, 2023
65b8b4e
Adjust spotless settings temporarily, apply spotless, and shorten com…
lsk567 Jul 17, 2023
5ccd03a
Bump reactor-c
lsk567 Jul 17, 2023
87d8fee
Merge branch 'master' into static-schedule
lsk567 Jul 17, 2023
f74145a
Complete simple link function
lsk567 Jul 17, 2023
a8c9a42
Apply spotless
lsk567 Jul 17, 2023
e83875b
Rename FS to STATIC
lsk567 Jul 18, 2023
145fa03
Apply spotless
lsk567 Jul 18, 2023
051e239
Store graphs in a graphs directory
lsk567 Jul 18, 2023
2125fbd
Revert "When generating DAGs, connect an earlier reaction invocation …
lsk567 Jul 20, 2023
5a411dc
Generate ADV and DU together.
lsk567 Jul 20, 2023
a02f2fa
Begin to work on tracing
lsk567 Jul 20, 2023
02349be
Remove tracing hacks
lsk567 Jul 20, 2023
2780a8b
Support better tracing experience by storing line numbers
lsk567 Jul 21, 2023
e4e51bf
Support ADDI and refactor
lsk567 Jul 21, 2023
ce86d73
Update ADV and ADV2
lsk567 Jul 21, 2023
e7ec971
Bump reactor-c
lsk567 Jul 24, 2023
0e5ba8c
Merge pull request #1908 from lf-lang/var-refs-in-schedules
lsk567 Jul 24, 2023
15e978d
Remove variables hyperperiod and iteration
lsk567 Jul 24, 2023
90fc309
Bump reactor-c
lsk567 Jul 24, 2023
e8c52b3
Apply spotless
lsk567 Jul 24, 2023
53d9eca
Apply suggestions from @oowekyala
lsk567 Jul 24, 2023
b80f594
Bump reactor-c
lsk567 Jul 24, 2023
ff93f34
Merge branch 'master' into static-schedule
lsk567 Jul 24, 2023
2de2572
Fix BIT
lsk567 Jul 24, 2023
1ae1a2f
Fix tracing
lsk567 Jul 24, 2023
22ee116
Apply spotless
lsk567 Jul 24, 2023
9b393f5
Generate more STP instructions, and generate missing ADV instructions…
lsk567 Jul 25, 2023
0accbf7
Apply spotless
lsk567 Jul 25, 2023
08dbdc7
Stop generating BIT and STP for acyclic fragments
lsk567 Jul 25, 2023
9b72432
Add STP at link phase, do not add SAC, DU, ADDI when SYNC is at max T…
lsk567 Jul 26, 2023
475397d
Enforce timeout on all static tests
lsk567 Jul 26, 2023
a1cde8d
Turn off tracing by default
lsk567 Jul 26, 2023
69193d7
Fix the nodes generation into the .dot to match the EGS. Give all wce…
ChadliaJerad Jul 26, 2023
6976667
Update updateDag to retreive the worker id from the generation partition
ChadliaJerad Jul 26, 2023
9bef82a
Update partitionDag() to align with EGS and the needed script
ChadliaJerad Jul 26, 2023
6447874
Add todos
ChadliaJerad Jul 26, 2023
60c8622
Merge branch 'master' into static-schedule
lsk567 Jul 27, 2023
4a49ed2
Undo an accidental edit
lsk567 Jul 27, 2023
8732324
Start to work on a CI test workflow
lsk567 Jul 27, 2023
12b3c0d
Apply spotless
lsk567 Jul 27, 2023
d4df62a
Disable @wcet for now so that CI can pass
lsk567 Jul 27, 2023
4c7c185
Merge branch 'master' into static-schedule
lsk567 Jul 27, 2023
1d9ef09
Merge branch 'master' into static-schedule
lsk567 Jul 28, 2023
c269a18
Remove the static scheduler CI workflow to see if workflow count fall…
lsk567 Jul 28, 2023
171da5e
Merge verifier and static scheduler CI workflows
lsk567 Jul 28, 2023
310ef57
Commit changes to the CI file, which were missing for some reason
lsk567 Jul 28, 2023
eb57ad9
Add WIP to let @wcet pass the round trip test
lsk567 Jul 28, 2023
c353e08
Update formatter to handle new annotation syntax.
petervdonovan Jul 29, 2023
5d4f7fe
Small fix in FormattingUnitTests.java
lsk567 Jul 29, 2023
e98135a
Merge branch 'master' into static-schedule
lsk567 Jul 29, 2023
19732ff
Rename RL to EGS
lsk567 Jul 31, 2023
9e74d03
Minor comment update
lsk567 Jul 31, 2023
064f7d6
Start to work on a mocasin scheduler
lsk567 Jul 31, 2023
7acb888
Add comments
lsk567 Jul 31, 2023
44bf2d4
Rename EVM to PRET VM
lsk567 Jul 31, 2023
1d40dbc
Apply spotless
lsk567 Jul 31, 2023
6ac3727
Reduce the timeout value of ScheduleTest, so the CI does not fail due…
lsk567 Jul 31, 2023
6e98c69
WIP for generating mocasin XML SDF3 files
lsk567 Jul 31, 2023
db89415
Merge branch 'master' into static-schedule
lsk567 Aug 1, 2023
7ed4126
Do not generate DU if fast mode is on
lsk567 Aug 1, 2023
4185a15
Apply spotless
lsk567 Aug 1, 2023
667dc8a
Refactor state space explorer
lsk567 Aug 1, 2023
f4646a6
Update loopFound to loopIsFound()
lsk567 Aug 1, 2023
8d8529e
Update comments and author tags
lsk567 Aug 1, 2023
3f4f9f1
Merge branch 'master' into static-schedule
lsk567 Aug 1, 2023
6d22246
Add WIP for supporting port hierarchies in state space explorer
lsk567 Aug 1, 2023
748f71c
Add a comment about addAll()
lsk567 Aug 1, 2023
50d7899
Make the explore() function static and enforce loop finding
lsk567 Aug 2, 2023
dc95efe
Begin to support shutdown, and set the stage for supporting multiple …
lsk567 Aug 3, 2023
3aa9faf
Generate timeout scenario in the shutdown phase
lsk567 Aug 3, 2023
c14519a
Do not generate dot files if diagrams are empty.
lsk567 Aug 3, 2023
bf532aa
Add validator for the generated SDF3 XML files
lsk567 Aug 4, 2023
51d3c57
Generate actorProperties and channelProperties in SDF3 XML
lsk567 Aug 4, 2023
24381b8
Skip certain compilation steps for MOCASIN. Append postfix to XML files.
lsk567 Aug 4, 2023
d267bab
Add @wcet to TwoPhases.lf
lsk567 Aug 4, 2023
ba22c67
Merge branch 'master' into static-schedule
lsk567 Aug 6, 2023
41085fc
Fix race condition by removing the reactor_reached_stop_tag array sin…
lsk567 Aug 6, 2023
465e75f
Turn upstream and downstream fragments into lists
lsk567 Aug 7, 2023
ec6c26a
Generate labels for different phases
lsk567 Aug 7, 2023
7fdc706
Generate macros for labels
lsk567 Aug 7, 2023
9917b6b
Support branch instructions and transition guards
lsk567 Aug 8, 2023
3045863
Generate JMP for default transitions, fix linker, and apply spotless
lsk567 Aug 9, 2023
19ee103
Allow conditional branching between phases. Support shutdown triggers…
lsk567 Aug 10, 2023
e4253e6
Merge pull request #1937 from lf-lang/static-schedule-phase-jump
lsk567 Aug 10, 2023
7d3ac59
Merge branch 'master' into static-schedule
lsk567 Aug 10, 2023
df0142d
Update the dot files paths and names in EGS scheduler to align with t…
ChadliaJerad Aug 11, 2023
74c3b6c
Fix dag update from file
ChadliaJerad Aug 12, 2023
86ddc27
EGS scheduler: get, check and set workers, add colors and set partitions
ChadliaJerad Aug 12, 2023
727fa4b
Apply formatter
ChadliaJerad Aug 12, 2023
ddf34b4
Remove the static scheduler when compiling for Arduino
lsk567 Aug 13, 2023
ec43abd
Rename BASELINE to LOAD_BALANCED
lsk567 Aug 13, 2023
d5d7e45
Enable passing static scheduler on the command line
lsk567 Aug 14, 2023
0a2609d
Fix explorer bug when exploring scenario SHUTDOWN_TIMEOUT
lsk567 Aug 14, 2023
0ae9257
Remove cycle checking, as the condition might be wrong
ChadliaJerad Aug 14, 2023
0d25d90
Adjust workers number and usage when calling the EGS scheduler
ChadliaJerad Aug 14, 2023
f5d5586
Adjust formatting unit test and apply spotless
lsk567 Aug 15, 2023
6ca1e73
Merge branch 'master' into static-schedule
lsk567 Aug 15, 2023
4ef921c
Add proper union types to SchedulerDictOption
lsk567 Aug 20, 2023
44b8b2c
Check if a DAG is well-formed.
lsk567 Aug 20, 2023
b500c85
Deprecate SAC and fix race condition by using SYNC_BLOCK for synchron…
lsk567 Aug 22, 2023
5a4a2df
Bump reactor-c
lsk567 Aug 22, 2023
7406bc6
Merge branch 'master' into static-schedule
lsk567 Aug 22, 2023
5a8f228
Update to new PRET VM instruction format for C target
erlingrj Sep 23, 2023
c7b9443
Add WIP for mocasin
lsk567 Sep 25, 2023
b3d0600
Bump reactor-c
lsk567 Sep 25, 2023
cd71f4b
Merge branch 'master' into static-schedule
lsk567 Sep 25, 2023
e25f967
Merge branch 'static-schedule' into static-update-instr
erlingrj Sep 25, 2023
d155bc1
Bump reactor-C
erlingrj Sep 25, 2023
7052656
Merge pull request #2022 from lf-lang/static-update-instr
erlingrj Sep 25, 2023
73b9c7e
Support mocasin
lsk567 Oct 2, 2023
c96a9f0
Update mocasin note
lsk567 Oct 2, 2023
f7a4c66
Add copy methods and use copies when inserting guards to fix the labe…
lsk567 Oct 2, 2023
1025d70
Merge branch 'static-schedule' into static-schedule-mocasin
lsk567 Oct 3, 2023
905893d
Fix buffer overflow, remove unused instructions, apply spotless
lsk567 Oct 5, 2023
6b4daa6
Merge branch 'master' into static-schedule
lsk567 Oct 5, 2023
b29a208
Start to work on physical actions
lsk567 Oct 6, 2023
b04aa57
Support basic polling interpretation of physical actions
lsk567 Oct 9, 2023
038b4b2
Fix bug about missing dependencies across priorities
lsk567 Oct 10, 2023
20a1555
Set hyperperiod in the merged DAG.
lsk567 Oct 10, 2023
73f6c29
Make triggers explicit in the schedule
lsk567 Oct 12, 2023
295b7a6
Finish generating BEQ guards and JAL instructions when guards are not…
lsk567 Oct 12, 2023
3b1df57
Make sure state space explorer does not involve physical actions duri…
lsk567 Oct 12, 2023
ff8c54d
Use the environment struct to pass necessary information to check the…
lsk567 Oct 16, 2023
9474535
Get a simple test to work
lsk567 Oct 16, 2023
502f83b
Add a test case for connections
lsk567 Oct 18, 2023
5c553d7
Fix of the partioned dag partitions
ChadliaJerad Oct 26, 2023
0513c6e
Add WIP
lsk567 Oct 27, 2023
cb6f754
Make code generator accept canonical DAGs
lsk567 Oct 27, 2023
314c5c6
Redirect EGS outputs to stdout and stderr
lsk567 Oct 28, 2023
f2d8429
Add completion deadline inference logic. Need major refactoring later.
lsk567 Oct 29, 2023
21a91cf
Make the shutdown phase's hyperperiod max long
lsk567 Oct 29, 2023
45d6318
Make the last SYNC node in acyclic dag have max long time
lsk567 Oct 29, 2023
3ebc728
FiX to the reverse edge generation in the EGS scheduler
ChadliaJerad Oct 29, 2023
492db67
Revert "Add completion deadline inference logic. Need major refactori…
lsk567 Oct 29, 2023
3d650e3
Turn wcet annotation into a comma separated list
lsk567 Oct 30, 2023
407e1a9
Let Mocasin accept a list of wcets, the first is A7, the second is A15
lsk567 Oct 30, 2023
c7aa5ca
Merge branch 'static-schedule-wcets' into static-schedule
lsk567 Oct 30, 2023
7e18dd5
Assume EGS installed. Fix upstream sync node bug.
lsk567 Nov 12, 2023
48b3819
Apply spotless
lsk567 Nov 12, 2023
649bccf
Add wcet to ThreePhases
lsk567 Nov 15, 2023
323ed2a
Bump reactor-c
lsk567 Nov 15, 2023
a4a858c
Merge branch 'master' into static-schedule
lsk567 Nov 15, 2023
f83daa7
Apply spotless
lsk567 Nov 16, 2023
1e236c9
Update integration test
lsk567 Nov 16, 2023
bc915fb
Parsing nested dictionary
lsk567 Nov 16, 2023
f7595ba
Merge branch 'master' into static-schedule
lsk567 Nov 20, 2023
222ad8c
Merge branch 'scheduler-and-worker-fix' into static-schedule
lsk567 Nov 20, 2023
5912b90
Update lf_assert to LF_ASSERT
lsk567 Nov 20, 2023
967f46b
Bump reactor-c, fix CTriggerObjectsGenerator, update ScheduleTest
lsk567 Nov 20, 2023
74a1536
Fix mocasin property check
lsk567 Nov 20, 2023
e6dee1f
Set default static scheduler to LOAD_BALANCED
lsk567 Nov 24, 2023
e7e941b
Fix the phantom dependency problem
lsk567 Dec 4, 2023
dbf8db1
Merge branch 'master' into static-schedule
lsk567 Dec 6, 2023
d9f2407
Merge branch 'static-schedule' into static-schedule-explicit-triggers
lsk567 Dec 7, 2023
b6a01cb
Add WIP
lsk567 Dec 14, 2023
eba161a
Fix the issue of duplicating ADVIs and DUs for each reaction in the s…
lsk567 Jan 6, 2024
f4e728f
Start to generate connection management functions
lsk567 Jan 7, 2024
5fc726c
Add WIP
lsk567 Jan 7, 2024
0f6ff2b
Unify DAG generation logic for both cyclic and acyclic diagrams. Use …
lsk567 Jan 20, 2024
7020e75
Commit TODOs for record keeping
lsk567 Jan 20, 2024
8239515
Add WIP. SimpleConnection kind of works.
lsk567 Jan 20, 2024
c7be414
Make SimpleConnection test case work
lsk567 Jan 25, 2024
5445262
Update helper function names, update unit tests
lsk567 Feb 1, 2024
7ce303f
Fix excessive invocations of post connection helpers
lsk567 Feb 4, 2024
2db00e3
Use a standard helper function to add instructions, which fixes Sched…
lsk567 Feb 4, 2024
0e19505
Prune and improve comments
lsk567 Feb 11, 2024
15cece9
Organize static tests
lsk567 Feb 11, 2024
06edf6c
Bump reactor-c
lsk567 Feb 11, 2024
e9160ca
Merge branch 'master' into static-schedule
lsk567 Feb 11, 2024
212a149
Refactor static tests
lsk567 Feb 12, 2024
2cf886c
Refactor test framework, temporarily comment out the connection skipp…
lsk567 Feb 12, 2024
c8c7309
Merge branch 'master' into static-schedule
lsk567 Feb 12, 2024
fbe022e
Prune EIT from InstructionGenerator, fix the misplacement issue of pr…
lsk567 Feb 14, 2024
4e8c7e5
Perform NULL and timestamp check when getting events from the pqueue
lsk567 Feb 14, 2024
b3e210b
Use the static flag for StaticAlignment.lf
lsk567 Feb 15, 2024
28f8c24
Add WIP for attributing instructions to DAG nodes
lsk567 Feb 15, 2024
4f3f81b
Attribute connection helper EXEs to DAG nodes
lsk567 Feb 15, 2024
0b55e97
Show instructions in DOT
lsk567 Feb 15, 2024
6318f83
Technical debt: disabling cycle check in LFValidator for now since de…
lsk567 Feb 23, 2024
c94d656
Disable cycle checks, check for null token, add unsupported tests
lsk567 Feb 25, 2024
38c2038
Merge branch 'master' into static-schedule
lsk567 Feb 25, 2024
3228700
Pass reaction numbers in InstructionEXE for tracing
lsk567 Feb 29, 2024
234d856
Bump reactor-c
lsk567 Mar 4, 2024
75c694b
Fix crash by reporting warning from nowhere()
lsk567 Mar 4, 2024
2307d36
Update time fields in post-connection helpers
lsk567 Mar 6, 2024
dbda73c
Bump reactor-c
lsk567 Mar 6, 2024
6f8f4e2
Bump reactor-c
lsk567 Mar 7, 2024
d90e497
Add WIP
lsk567 Mar 10, 2024
ad9533e
Bump reactor-c
lsk567 Mar 10, 2024
08fff06
Add DAG edges based on connections, including those with delays. Coop…
lsk567 Mar 13, 2024
f05a2a0
Revert to using eventualDestinationsOrig() in dependentReactions()
lsk567 Mar 13, 2024
ca786d4
Fix connection edge generation in DAGs
lsk567 Mar 14, 2024
e29725d
Bump reactor-c
lsk567 Mar 14, 2024
3bd1022
Generate a pre-connection helper when the last port-modifying reactio…
lsk567 Mar 15, 2024
3042b78
Use a faster algorithm to remove redundant edges
lsk567 Mar 16, 2024
7ea014d
Fix pre-connection helper generation
lsk567 Mar 16, 2024
3527f02
Fix dangling pointers which can lead to undefined behaviors
lsk567 Mar 17, 2024
2feb5c7
Move connection management out of the jump-pass region
lsk567 Mar 17, 2024
f927b49
Redo 'Move connection management out of the jump-pass region' while n…
lsk567 Mar 18, 2024
7dd27f3
Bump reactor-c: Increase spin wait threshold to 100 msec
lsk567 Mar 19, 2024
23a1c50
Bump reactor-c: Use spin wait for NP for fairness
lsk567 Mar 19, 2024
c73e8d7
Bump reactor-c again: Use spin wait for NP for fairness
lsk567 Mar 19, 2024
286206f
Support dash mode
lsk567 Mar 20, 2024
35e67d7
Merge branch 'static-schedule' into static-schedule-circular-buffer
lsk567 Mar 22, 2024
8ae4b5f
Use circular buffers
lsk567 Mar 22, 2024
ca43a52
Get optimized circular buffer to work
lsk567 Mar 22, 2024
09e1344
Use function pointers to execute virtual instructions. Stop tracing a…
lsk567 Mar 23, 2024
e868224
Remove tracepoints except reaction starts and stops
lsk567 Mar 23, 2024
b1cf1a0
Optimize away zero-delay connection buffer management
lsk567 Mar 23, 2024
7beaa39
Clear is_present fields in post-connection helpers
lsk567 Mar 24, 2024
1fc56f6
Use pure spin wait in DU for evaluation
lsk567 Mar 24, 2024
cd6ec81
Disable cycle checks for now
lsk567 Mar 26, 2024
2045d6e
Allow dangling output ports
lsk567 Mar 26, 2024
c1d1be5
Add WU when the same reaction is mapped to different workers, fixing …
lsk567 Mar 29, 2024
31c01a9
Generate WUs for nodes linked by a connection but mapped to different…
lsk567 Mar 30, 2024
0758301
Use memcpy to handle more data types
lsk567 Apr 7, 2024
7929b9b
Partially support token type
lsk567 Apr 8, 2024
9399218
Add FIXME
lsk567 Apr 15, 2024
9b23a86
Refactor registers
lsk567 Apr 21, 2024
596cb7e
Fix concurrency bug after the register refactoring
lsk567 Apr 26, 2024
1a125b0
Make ScheduleTest symmetric
lsk567 Apr 26, 2024
9fa4695
Add PeepholeOptimizer and an opt that removes redundant WUs
lsk567 Apr 27, 2024
d124242
Add a test case for the WU optimization
lsk567 Apr 27, 2024
c0fa10c
Remove unused files
lsk567 Apr 27, 2024
5b5b492
Minor name change
lsk567 Apr 27, 2024
e2512de
Set up infrastructure for factoring out procedures
lsk567 Apr 29, 2024
df34fbe
Various comments and a README on optimizers
lsk567 May 1, 2024
400c561
Support multiple labels for a location, make sure a phase label is be…
lsk567 May 31, 2024
3e86b31
Fix lf_set issue and turn SimpleConnection into a proper test case
lsk567 Jun 1, 2024
d5edde5
Merge branch 'static-schedule' into static-schedule-opt
lsk567 Jun 2, 2024
c678511
Add WIP
lsk567 Jun 6, 2024
2103db5
DataTypes.lf no longer works after reverting the reactor-c commit abo…
lsk567 Jun 7, 2024
a21ef78
Linearize partitions in the load balanced scheduler
lsk567 Jun 7, 2024
fe63e9c
Check for empty behavior
lsk567 Jun 18, 2024
7228b35
Fix the incompatible conversion warning/error
lsk567 Jul 3, 2024
cebebb7
Bump reactor-c
lsk567 Aug 4, 2024
1f5a6d3
Merge branch 'static-schedule' into static-schedule-opt
lsk567 Aug 4, 2024
8f1d030
Deprecate the brittle placeholder map mechanism for handling delayed …
lsk567 Aug 14, 2024
51185b0
Remove debug prints
lsk567 Aug 14, 2024
9c3aef7
Fix equivalence class grouping by enabling relative timing for ADVI a…
lsk567 Aug 31, 2024
e3ef195
Fix DU, udpate test case
lsk567 Sep 1, 2024
7733021
Remove debug prints and prevent PeepholeOptimizer from removing labels
lsk567 Sep 1, 2024
1afcecb
Stop storing instructions inside nodes, which caused inconsistent ord…
lsk567 Sep 5, 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
6 changes: 6 additions & 0 deletions cli/lfc/src/main/java/org/lflang/cli/Lfc.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public class Lfc extends CliBase {
description = "Specify the runtime scheduler (if supported).")
private String scheduler;

// FIXME: Add LfcCliTest for this.
@Option(
names = {"--static-scheduler"},
description = "Select a specific static scheduler if scheduler is set to FS (fully static).")
private String staticScheduler;

@Option(
names = {"-t", "--threading"},
paramLabel = "<true/false>",
Expand Down
36 changes: 36 additions & 0 deletions core/src/main/java/org/lflang/AttributeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.lflang.lf.Reaction;
import org.lflang.lf.Reactor;
import org.lflang.lf.StateVar;
import org.lflang.lf.Time;
import org.lflang.lf.Timer;
import org.lflang.util.StringUtil;

Expand Down Expand Up @@ -133,6 +134,33 @@ public static String getAttributeValue(EObject node, String attrName) {
return value;
}

/**
* Return the first argument, which has the type Time, specified for the attribute.
*
* <p>This should be used if the attribute is expected to have a single argument whose type is
* Time. If there is no argument, null is returned.
*/
public static Time getFirstArgumentTime(Attribute attr) {
if (attr == null || attr.getAttrParms().isEmpty()) {
return null;
}
return attr.getAttrParms().get(0).getTime();
}

/**
* Search for an attribute with the given name on the given AST node and return its first argument
* as Time.
*
* <p>This should only be used on attributes that are expected to have a single argument with type
* Time.
*
* <p>Returns null if the attribute is not found or if it does not have any arguments.
*/
public static Time getAttributeTime(EObject node, String attrName) {
final var attr = findAttributeByName(node, attrName);
return getFirstArgumentTime(attr);
}

/**
* Retrieve a specific annotation in a comment associated with the given model element in the AST.
*
Expand Down Expand Up @@ -223,6 +251,14 @@ public static boolean hasCBody(Reaction reaction) {
return findAttributeByName(reaction, "_c_body") != null;
}

/** Return a time value that represents the WCET of a reaction. */
public static TimeValue getWCET(Reaction reaction) {
Time t = getAttributeTime(reaction, "wcet");
if (t == null) return TimeValue.MAX_VALUE;
TimeUnit unit = TimeUnit.fromName(t.getUnit());
return new TimeValue(t.getInterval(), unit);
}

/** Return the declared label of the node, as given by the @label annotation. */
public static String getLabel(EObject node) {
return getAttributeValue(node, "label");
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/lflang/LinguaFranca.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Attribute:
;

AttrParm:
(name=ID '=')? value=Literal;
(name=ID '=')? (value=Literal | time=Time);

/////////// For target parameters

Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/org/lflang/TargetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.lflang.TargetProperty.LogLevel;
import org.lflang.TargetProperty.Platform;
import org.lflang.TargetProperty.SchedulerOption;
import org.lflang.TargetProperty.StaticSchedulerOption;
import org.lflang.TargetProperty.UnionType;
import org.lflang.generator.LFGeneratorContext.BuildParm;
import org.lflang.generator.rust.RustTargetConfig;
Expand Down Expand Up @@ -120,6 +121,10 @@ public TargetConfig(Properties cliArgs, TargetDecl target, ErrorReporter errorRe
this.schedulerType = SchedulerOption.valueOf(cliArgs.getProperty("scheduler"));
this.setByUser.add(TargetProperty.SCHEDULER);
}
if (cliArgs.containsKey("static-scheduler")) {
this.staticScheduler = StaticSchedulerOption.valueOf(cliArgs.getProperty("static-scheduler"));
this.setByUser.add(TargetProperty.STATIC_SCHEDULER);
}
if (cliArgs.containsKey("target-flags")) {
this.compilerFlags.clear();
if (!cliArgs.getProperty("target-flags").isEmpty()) {
Expand Down Expand Up @@ -262,6 +267,9 @@ public TargetConfig(Properties cliArgs, TargetDecl target, ErrorReporter errorRe
/** What runtime scheduler to use. */
public SchedulerOption schedulerType = SchedulerOption.getDefault();

/** What static schedule generator to use. */
public StaticSchedulerOption staticScheduler = StaticSchedulerOption.getDefault();

/**
* The number of worker threads to deploy. The default is zero, which indicates that the runtime
* is allowed to freely choose the number of workers.
Expand Down
31 changes: 30 additions & 1 deletion core/src/main/java/org/lflang/TargetProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,18 @@ public enum TargetProperty {
UnionType.SCHEDULER_UNION.forName(ASTUtils.elementToSingleString(value));
}),

/** Directive for specifying a specific runtime scheduler, if supported. */
STATIC_SCHEDULER(
"static-scheduler",
UnionType.STATIC_SCHEDULER_UNION,
Arrays.asList(Target.C),
(config) -> ASTUtils.toElement(config.staticScheduler.toString()),
(config, value, err) -> {
config.staticScheduler =
(StaticSchedulerOption)
UnionType.STATIC_SCHEDULER_UNION.forName(ASTUtils.elementToSingleString(value));
}),

/** Directive to specify that all code is generated in a single file. */
SINGLE_FILE_PROJECT(
"single-file-project",
Expand Down Expand Up @@ -1202,6 +1214,8 @@ public enum UnionType implements TargetPropertyType {
BUILD_TYPE_UNION(Arrays.asList(BuildType.values()), null),
COORDINATION_UNION(Arrays.asList(CoordinationType.values()), CoordinationType.CENTRALIZED),
SCHEDULER_UNION(Arrays.asList(SchedulerOption.values()), SchedulerOption.getDefault()),
STATIC_SCHEDULER_UNION(
Arrays.asList(StaticSchedulerOption.values()), StaticSchedulerOption.getDefault()),
LOGGING_UNION(Arrays.asList(LogLevel.values()), LogLevel.INFO),
PLATFORM_UNION(Arrays.asList(Platform.values()), Platform.AUTO),
CLOCK_SYNC_UNION(Arrays.asList(ClockSyncMode.values()), ClockSyncMode.INIT),
Expand Down Expand Up @@ -1769,7 +1783,8 @@ public enum SchedulerOption {
Path.of("worker_states.h"),
Path.of("data_collection.h"))),
GEDF_NP(true), // Global EDF non-preemptive
GEDF_NP_CI(true); // Global EDF non-preemptive with chain ID
GEDF_NP_CI(true), // Global EDF non-preemptive with chain ID
FS(true); // Fully static
// PEDF_NP(true); // Partitioned EDF non-preemptive (FIXME: To be re-added in a future PR)

/** Indicate whether or not the scheduler prioritizes reactions by deadline. */
Expand Down Expand Up @@ -1803,6 +1818,20 @@ public static SchedulerOption getDefault() {
}
}

/**
* Supported schedule generators.
*
* @author Shaokai Lin
*/
public enum StaticSchedulerOption {
BASELINE,
RL;

public static StaticSchedulerOption getDefault() {
return BASELINE;
}
}

/**
* Tracing options.
*
Expand Down
59 changes: 59 additions & 0 deletions core/src/main/java/org/lflang/TimeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,34 @@ public long toNanoSeconds() {
return makeNanosecs(time, unit);
}

/** Return a TimeValue based on a nanosecond value. */
public static TimeValue fromNanoSeconds(long ns) {
if (ns == 0) return ZERO;
long time;
if ((time = ns / 604_800_016_558_522L) > 0 && ns % 604_800_016_558_522L == 0) {
return new TimeValue(time, TimeUnit.WEEK);
}
if ((time = ns / 86_400_000_000_000L) > 0 && ns % 86_400_000_000_000L == 0) {
return new TimeValue(time, TimeUnit.DAY);
}
if ((time = ns / 3_600_000_000_000L) > 0 && ns % 3_600_000_000_000L == 0) {
return new TimeValue(time, TimeUnit.HOUR);
}
if ((time = ns / 60_000_000_000L) > 0 && ns % 60_000_000_000L == 0) {
return new TimeValue(time, TimeUnit.MINUTE);
}
if ((time = ns / 1_000_000_000) > 0 && ns % 1_000_000_000 == 0) {
return new TimeValue(time, TimeUnit.SECOND);
}
if ((time = ns / 1_000_000) > 0 && ns % 1_000_000 == 0) {
return new TimeValue(time, TimeUnit.MILLI);
}
if ((time = ns / 1000) > 0 && ns % 1000 == 0) {
return new TimeValue(time, TimeUnit.MICRO);
}
return new TimeValue(ns, TimeUnit.NANO);
}

/** Return a string representation of this time value. */
public String toString() {
return unit != null ? time + " " + unit.getCanonicalName() : Long.toString(time);
Expand Down Expand Up @@ -181,4 +209,35 @@ public TimeValue add(TimeValue b) {
var unitDivider = makeNanosecs(1, smallestUnit);
return new TimeValue(sumOfNumbers / unitDivider, smallestUnit);
}

/**
* Return the substraction of this duration from the one represented by b.
*
* <p>The unit of the returned TimeValue will be the minimum of the units of both operands except
* if only one of the units is TimeUnit.NONE. In that case, the unit of the other input is used.
*
* @param b The right operand
* @return A new TimeValue (the current value will not be affected)
*/
public TimeValue sub(TimeValue b) {
// Figure out the actual sub
final long subOfNumbers;
try {
subOfNumbers = Math.subtractExact(this.toNanoSeconds(), b.toNanoSeconds());
} catch (ArithmeticException overflow) {
return MAX_VALUE;
}

if (this.unit == null || b.unit == null) {
// A time value with no unit is necessarily zero. So
// if this is null, (this + b) == b, if b is none, (this+b) == this.
return b.unit == null ? this : b;
}
boolean isThisUnitSmallerThanBUnit = this.unit.compareTo(b.unit) <= 0;
TimeUnit smallestUnit = isThisUnitSmallerThanBUnit ? this.unit : b.unit;
// Find the appropriate divider to bring sumOfNumbers from nanoseconds to
// returnUnit
var unitDivider = makeNanosecs(1, smallestUnit);
return new TimeValue(subOfNumbers / unitDivider, smallestUnit);
}
}
Loading