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

Added support for modular scheduler in C runtime #743

Merged
merged 136 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
651f16b
First prototype of the scheduler
Soroosh129 Nov 10, 2021
5945c88
Updated reactor c submodule
Soroosh129 Nov 11, 2021
1423230
Updated reactor-c
Soroosh129 Nov 11, 2021
cfe3952
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Nov 11, 2021
449e34c
Updated reactor c
Soroosh129 Nov 11, 2021
b87e13f
Removed tracing from benchmark
Soroosh129 Nov 11, 2021
796d272
Updated reactor-c
Soroosh129 Nov 11, 2021
2978eb0
Updated reactor-c
Soroosh129 Nov 11, 2021
ee39e7c
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Nov 12, 2021
70d32d8
Updated reactor-c
Soroosh129 Nov 12, 2021
3ea5ded
Adjusted path to util files
Soroosh129 Nov 13, 2021
ddb6936
Updated reactor-c
Soroosh129 Nov 13, 2021
8fc8b8e
Updated reactor-c-py
Soroosh129 Nov 13, 2021
a651939
Updated reactor-c
Soroosh129 Nov 13, 2021
1875e75
Check that Python functions are loaded properly
Soroosh129 Nov 13, 2021
ebe8042
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Nov 13, 2021
427a2f2
Updated reactor-c
Soroosh129 Nov 13, 2021
ab2ae61
Updated reactor-c
Soroosh129 Nov 13, 2021
572c1e6
FIXME: The performance of TimeLimitThreaded is terrible with the new …
Soroosh129 Nov 14, 2021
5e5b70e
Updated reactor-c
Soroosh129 Nov 14, 2021
a63303d
Added a scheduler.h
Soroosh129 Nov 14, 2021
3029508
Updated reactor-c-py
Soroosh129 Nov 14, 2021
cdaa951
Updated test since port values are read-only
Soroosh129 Nov 14, 2021
6a74edf
Space in comment
Soroosh129 Nov 14, 2021
5c35c25
Updated reactor-c
Soroosh129 Nov 14, 2021
8ddb81f
Added a scheduler target property
Soroosh129 Dec 5, 2021
43ed890
Added support for swapping schedulers to the CGenerator
Soroosh129 Dec 5, 2021
56ad39f
Updated reactor-c
Soroosh129 Dec 5, 2021
31889bd
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Dec 5, 2021
ff098e9
Fixed compile error
Soroosh129 Dec 5, 2021
69386f4
Updated reactor-c module
Soroosh129 Dec 5, 2021
b648767
Updated reactor-c
Soroosh129 Dec 5, 2021
3e7fb1f
Updated reactor-c
Soroosh129 Dec 6, 2021
3adcafc
Updated reactor-c
Soroosh129 Dec 6, 2021
4f9fa73
Fixed an issue with Windows-style paths for the Python target
Soroosh129 Dec 7, 2021
bb8e967
Updated reactor-c
Soroosh129 Dec 7, 2021
515055a
Updated reactor-c
Soroosh129 Dec 8, 2021
03b9dea
Updated reactor-c
Soroosh129 Dec 8, 2021
0a230cb
Updated reactor-c
Soroosh129 Dec 8, 2021
26c4f9b
Updated reactor-c
Soroosh129 Dec 8, 2021
82e315d
Updated reactor-c
Soroosh129 Dec 9, 2021
2c00f0f
Added test for all non-default schedulers
Soroosh129 Dec 9, 2021
7d217b8
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Dec 9, 2021
bcc27e6
Updated reactor-c
Soroosh129 Dec 9, 2021
15ce710
Reverted test to its original form
Soroosh129 Dec 9, 2021
98a42e7
Added option to pass on scheduler to lfc
Soroosh129 Dec 9, 2021
3b784b8
Added LOG_LEVEL as a compile definition for the CMake build system so…
Soroosh129 Dec 9, 2021
6b4c358
Updated reactor-c
Soroosh129 Dec 9, 2021
4ec48ab
Fixed a bug with the log level
Soroosh129 Dec 9, 2021
cde0b98
Updated test
Soroosh129 Dec 9, 2021
16e8cb4
Cog scheduler in benchmarks.
petervdonovan Dec 9, 2021
83ad100
Updated reactor-c
Soroosh129 Dec 16, 2021
1bf6679
Added MAX_REACTION_LEVEL and compile definitions
Soroosh129 Dec 18, 2021
63af3a5
Disable testing non-default schedulers for now
Soroosh129 Dec 19, 2021
2d17485
Updated reactor-c
Soroosh129 Dec 19, 2021
deb246f
Added a unit test function
Soroosh129 Dec 20, 2021
bdc6983
Updated reactor-c
Soroosh129 Dec 20, 2021
eaf393a
Updated reactor-c
Soroosh129 Dec 20, 2021
b5c45f2
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Dec 20, 2021
a38fb65
Addressed apparent merge artifact
Soroosh129 Dec 20, 2021
977e3fe
Removed unnecessary import
Soroosh129 Dec 20, 2021
a46c9af
Switched to using NP as the default scheduler. GEDF_NP will be select…
Soroosh129 Dec 21, 2021
5f81b18
Updated reactor-c
Soroosh129 Dec 21, 2021
3401e22
Turned testing for runtime scheduler swapping back on, minus the PEDF…
Soroosh129 Dec 21, 2021
2969e6e
Typo
Soroosh129 Dec 21, 2021
3c2a672
Minor printing updates
Soroosh129 Dec 21, 2021
e76957c
Exclude the examples category
Soroosh129 Dec 21, 2021
2abec9c
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Jan 9, 2022
473b18f
Fixed issues with docker support
Soroosh129 Jan 9, 2022
062009b
Updated compile definitions
Soroosh129 Jan 10, 2022
78862c0
Updated comments
Soroosh129 Jan 10, 2022
085be46
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Jan 10, 2022
a1f061f
Updated the way scheduler tests are performed
Soroosh129 Jan 10, 2022
d786581
Missed renames
Soroosh129 Jan 10, 2022
af3cd77
Updated reactor-c
Soroosh129 Jan 10, 2022
08f8062
Added exclusions for serialization tests
Soroosh129 Jan 10, 2022
206f286
Updated reactor-c
Soroosh129 Jan 10, 2022
b461380
Updated reactor-c
Soroosh129 Jan 10, 2022
1f5b0d0
Minor tweaks to scheduler testings
Soroosh129 Jan 10, 2022
44f1e1d
Updated reactor-c
Soroosh129 Jan 10, 2022
ed4319f
Removed unnecessary function
Soroosh129 Jan 11, 2022
611607c
Updated reactor c
Soroosh129 Jan 11, 2022
43fc7f4
Added explicit return status to Python code
Soroosh129 Jan 11, 2022
68216eb
Revert "Added explicit return status to Python code"
Soroosh129 Jan 11, 2022
702ebdb
Added wheel as a requirement
Soroosh129 Jan 11, 2022
7c23be1
Fixed an issue with protobuff
Soroosh129 Jan 11, 2022
56bc05a
Removed wheel as a requirement
Soroosh129 Jan 11, 2022
dfe1f19
Added exit code and stack trace printouts for failed tests
Soroosh129 Jan 11, 2022
b943932
Fixed message format
Soroosh129 Jan 11, 2022
70e0149
Revert reactor-c-py to an earlier commit to try to pinpoint the cause…
Soroosh129 Jan 11, 2022
422619d
Revert reactor-c-py even further
Soroosh129 Jan 11, 2022
2dd89ce
Pointing back to the head of reactor-c-py
Soroosh129 Jan 11, 2022
60e87fe
Slightly streamlined test categories
Soroosh129 Jan 11, 2022
90c69c8
Benchmarks: Add scheduler parameter.
petervdonovan Jan 26, 2022
0eb2920
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Jan 29, 2022
0e6ea24
Fixed merge conflict
Soroosh129 Jan 29, 2022
f3fd387
Added back the scheduler option
Soroosh129 Jan 29, 2022
824b24a
Added back MAX_REACTION_LEVEL
Soroosh129 Jan 30, 2022
ed3a2d2
Made generated CMakeLists.txt a bit prettier
Soroosh129 Jan 30, 2022
433643b
Updated reactor-c-py
Soroosh129 Jan 30, 2022
8f375ef
Fixed merge artifact
Soroosh129 Jan 30, 2022
d57dead
Another merge artifact
Soroosh129 Jan 30, 2022
6d6463d
Updated reactor-c
Soroosh129 Jan 30, 2022
4355328
Added scheduler options and params during code generation
Soroosh129 Jan 31, 2022
f1804d4
Fixed taking address of temporary array error
Soroosh129 Jan 31, 2022
1ae914a
Format fixes and Cpp-related fixes
Soroosh129 Jan 31, 2022
6aaafab
More Cpp-related fixes
Soroosh129 Jan 31, 2022
97ba3a4
Renamed options to params
Soroosh129 Jan 31, 2022
9a9d640
Updated reactor-c
Soroosh129 Jan 31, 2022
4b77cd6
Updated reactor-c
Soroosh129 Jan 31, 2022
9fc26da
Updated reactor-c
Soroosh129 Jan 31, 2022
8672a6b
Logic fix
Soroosh129 Jan 31, 2022
09414ee
Updated reactor-c
Soroosh129 Feb 1, 2022
8142f4b
Fixed merge conflict
Soroosh129 Feb 2, 2022
8c5e753
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Feb 2, 2022
82adb16
Added a warning for the scheduler type. Updated tests slightly to tes…
Soroosh129 Feb 2, 2022
1ed3c79
Resolved merge conflict with master
lhstrh Feb 4, 2022
21bb6b7
Merge branch 'master' into c-new-scheduler
petervdonovan Feb 5, 2022
6a14473
Merge remote-tracking branch 'origin/master' into c-new-scheduler
Soroosh129 Feb 12, 2022
906b6fb
Created separate test for non-standard schedulers that listens to sys…
lhstrh Feb 13, 2022
dbb9017
Use 4 threads for scheduler tests
lhstrh Feb 13, 2022
bc08e64
Parameterized C tests workflow with scheduler option
lhstrh Feb 13, 2022
6363b45
Resolved merge conflict
lhstrh Feb 13, 2022
79b9bed
IntelliJ refactoring ignores Xtend files; provided manual fix
lhstrh Feb 13, 2022
6a9e4d9
Fix typo
lhstrh Feb 13, 2022
108b026
Fix compile error
lhstrh Feb 13, 2022
3e9d836
Echo specified scheduler
lhstrh Feb 13, 2022
dd64983
Attempt to resolve merge conflicts with master. Tests not passing
edwardalee Feb 26, 2022
b65274a
Attempt to fix merge artifact
Soroosh129 Feb 26, 2022
980097a
Moved check
Soroosh129 Feb 26, 2022
27e74f5
Revert incorrect tests
Soroosh129 Feb 26, 2022
2778331
Reverted continue_on_error
Soroosh129 Feb 26, 2022
61a5ed5
set to point to c-new-scheduler branch of reactor-c
edwardalee Feb 26, 2022
9af2f83
Renamed max levels to num levels
edwardalee Feb 26, 2022
34bb15a
Fixed suspicious methods for adjusting number of levels count.
edwardalee Feb 26, 2022
900c449
Point to reactor-c main branch, which now has c-new-scheduler merged in
edwardalee Feb 26, 2022
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
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/BoundedBuffer.lf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/CigaretteSmoker.lf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/Dictionary.lf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ target CCpp {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/LogisticMap.lf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
3 changes: 2 additions & 1 deletion benchmark/C/Savina/src/concurrency/Philosophers.lf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down Expand Up @@ -170,7 +171,7 @@ reactor Arbitrator(num_philosophers:int(20)) {
}

if (self->finished_philosophers == self->num_philosophers) {
printf("Arbitrator: All philosophers are sated. Number of denials to philosophers: %d", self->retries);
printf("Arbitrator: All philosophers are sated. Number of denials to philosophers: %d\n", self->retries);
request_stop();
}
=}
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/ProdCons.lf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/SleepingBarber.lf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/concurrency/SortedLinkList.lf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target CCpp {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/Big.lf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target C{
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/Chameneos.lf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/Counting.lf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/PingPong.lf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/micro/ThreadRing.lf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
3 changes: 2 additions & 1 deletion benchmark/C/Savina/src/micro/Throughput.lf
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
threads: 2,
/// [[[end]]]
flags: "-lm",
flags: "-lm"
};


Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/Apsp.lf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/FilterBank.lf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/GuidedSearch.lf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ target CCpp {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/MatMul.lf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/NQueens.lf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target C{
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/PiPrecision.lf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/RadixSort.lf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/C/Savina/src/parallelism/Trapezoidal.lf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target C {
/* [[[cog
if (threaded_runtime=="True"):
cog.outl(f"threads: {threads},")
cog.outl(f"scheduler: {scheduler},")
else:
cog.outl("threads: 0,")
]]] */
Expand Down
1 change: 1 addition & 0 deletions benchmark/runner/conf/default.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
iterations: 12
threads: null
scheduler: GEDF_NP
savina_path: "${oc.env:SAVINA_PATH}"
lf_path: "${oc.env:LF_PATH}"
continue_on_error: False
Expand Down
1 change: 1 addition & 0 deletions benchmark/runner/conf/target/lf-c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ prepare: ["mkdir", "src"]
copy: ["cp", "-r", "${benchmark.targets.lf-c.copy_sources}", "src"]
gen: ["cog", "-r", "${args:benchmark.targets.lf-c.gen_args}",
"-D", "threads=${threads}",
"-D", "scheduler=${scheduler}",
"-D", "threaded_runtime=True",
"src/${benchmark.targets.lf-c.lf_file}"]
compile: ["${lf_path}/bin/lfc", "src/${benchmark.targets.lf-c.lf_file}"]
Expand Down
1 change: 1 addition & 0 deletions org.lflang.lfc/src/org/lflang/lfc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ enum CLIOption {
NO_COMPILE("n", "no-compile", false, false, "Do not invoke target compiler.", true),
FEDERATED("f", "federated", false, false, "Treat main reactor as federated.", false),
THREADS("t", "threads", true, false, "Specify the default number of threads.", true),
SCHEDULER("s", "scheduler", true, false, "Specify the runtime scheduler (if supported).", true),
OUTPUT_PATH("o", "output-path", true, false, "Specify the root output directory.", false),
RUNTIME_VERSION(null, "runtime-version", true, false, "Specify the version of the runtime library used for compiling LF programs.", true),
EXTERNAL_RUNTIME_PATH(null, "external-runtime-path", true, false, "Specify an external runtime library to be used by the compiled binary.", true);
Expand Down
47 changes: 47 additions & 0 deletions org.lflang.tests/src/org/lflang/tests/AbstractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.jupiter.api.Test;
import org.lflang.ASTUtils;
import org.lflang.Target;
import org.lflang.TargetProperty.SchedulerOptions;
import org.lflang.tests.TestRegistry.TestCategory;

/**
Expand Down Expand Up @@ -63,6 +64,13 @@ protected boolean supportsDockerOption() {
return false;
}


/**
* Whether to test different {@link org.lflang.TargetProperty#SchedulerOptions}.
*/
protected boolean supportsSchedulerSwapping() {
return false;
}

@Test
public void runExampleTests() {
Expand Down Expand Up @@ -192,4 +200,43 @@ public void runWithFourThreads() {
true
);
}

/**
* Swap the default runtime scheduler with other supported versions and run all the supported tests.
*/
@Test
public void runWithNonDefaultSchedulers() {
Assumptions.assumeTrue(supportsSchedulerSwapping(), Message.NO_SCHED_SWAPPING_SUPPORT);

EnumSet<TestCategory> categories = EnumSet.of(TestCategory.CONCURRENT,
TestCategory.MULTIPORT);

// Add federated and docker tests if supported
if (!isWindows() && supportsFederatedExecution()) {
categories.add(TestCategory.FEDERATED);
if (isLinux() && supportsDockerOption()) {
categories.add(TestCategory.DOCKER_FEDERATED);
}
}

for (SchedulerOptions scheduler: EnumSet.allOf(SchedulerOptions.class)) {
if (scheduler == SchedulerOptions.getDefault()) continue;

this.runTestsForTargets(
Message.DESC_SCHED_SWAPPING + scheduler.toString() +".",
categories::contains,
test -> {
test.getContext()
.getArgs()
.setProperty(
"scheduler",
scheduler.toString()
);
return true;
petervdonovan marked this conversation as resolved.
Show resolved Hide resolved
},
TestLevel.EXECUTION,
true
);
}
}
}
6 changes: 5 additions & 1 deletion org.lflang.tests/src/org/lflang/tests/LFTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class LFTest implements Comparable<LFTest> {

/** The result of the test. */
public Result result = Result.UNKNOWN;

/** The exit code of the test. **/
public String exitValue = "?";

/** Object used to determine where the code generator puts files. */
public FileConfig fileConfig;
Expand Down Expand Up @@ -128,7 +131,7 @@ public String reportErrors() {
sb.append("+---------------------------------------------------------------------------+").append(System.lineSeparator());
sb.append("Failed: ").append(this.name).append(System.lineSeparator());
sb.append("-----------------------------------------------------------------------------").append(System.lineSeparator());
sb.append("Reason: ").append(this.result.message).append(System.lineSeparator());
sb.append("Reason: ").append(this.result.message).append(" Exit code: ").append(this.exitValue).append(System.lineSeparator());
appendIfNotEmpty("Reported issues", this.issues.toString(), sb);
appendIfNotEmpty("Compilation output", this.compilationLog.toString(), sb);
appendIfNotEmpty("Execution output", this.execLog.toString(), sb);
Expand Down Expand Up @@ -164,6 +167,7 @@ public enum Result {
CODE_GEN_FAIL("Error while generating code for test."),
NO_EXEC_FAIL("Did not execute test."),
TEST_FAIL("Test did not pass."),
TEST_EXCEPTION("Test exited with an exception."),
TEST_TIMEOUT("Test timed out."),
TEST_PASS("Test passed.");

Expand Down
12 changes: 11 additions & 1 deletion org.lflang.tests/src/org/lflang/tests/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
Expand Down Expand Up @@ -121,6 +123,7 @@ public static class Message {
public static final String NO_DOCKER_SUPPORT = "Target does not support the 'docker' property.";
public static final String NO_DOCKER_TEST_SUPPORT = "Docker tests are only supported on Linux.";
public static final String NO_GENERICS_SUPPORT = "Target does not support generic types.";
public static final String NO_SCHED_SWAPPING_SUPPORT = "Target does not support runtime scheduler swapping.";

/* Descriptions of collections of tests. */
public static final String DESC_SERIALIZATION = "Run serialization tests (threads = 0).";
Expand All @@ -137,6 +140,7 @@ public static class Message {
public static final String DESC_TARGET_SPECIFIC = "Run target-specific tests (threads = 0)";
public static final String DESC_AS_CCPP = "Running C tests as CCpp.";
public static final String DESC_FOUR_THREADS = "Run non-concurrent and non-federated tests (threads = 4).";
public static final String DESC_SCHED_SWAPPING = "Running with non-default runtime scheduler ";

/* Missing dependency messages */
public static final String MISSING_DOCKER = "Executable 'docker' not found or 'docker' daemon thread not running";
Expand Down Expand Up @@ -466,12 +470,18 @@ private void execute(LFTest test) {
} else {
if (p.exitValue() != 0) {
test.result = Result.TEST_FAIL;
test.exitValue = Integer.toString(p.exitValue());
return;
}
}
}
} catch (Exception e) {
test.result = Result.TEST_FAIL;
test.result = Result.TEST_EXCEPTION;
// Add the stack trace to the test output
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
test.execLog.buffer.append(sw.toString());
return;
}
test.result = Result.TEST_PASS;
Expand Down
11 changes: 11 additions & 0 deletions org.lflang.tests/src/org/lflang/tests/runtime/CTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ protected boolean supportsFederatedExecution() {
protected boolean supportsDockerOption() {
return true;
}

@Override
protected boolean supportsSchedulerSwapping() {
return true;
}

@Test
@Override
Expand Down Expand Up @@ -101,6 +106,12 @@ public void runWithFourThreads() {
super.runWithFourThreads();
}

@Test
@Override
public void runWithNonDefaultSchedulers() {
super.runWithNonDefaultSchedulers();
}

@Test
@Override
public void runSerializationTests() {
Expand Down
2 changes: 1 addition & 1 deletion org.lflang/src/lib/py/reactor-c-py
Loading