From 0a19027bca7c658285ba45bceaa68506ef32808d Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 08:21:26 +0100 Subject: [PATCH 01/39] add a new workers target property and deprecate threads --- org.lflang/src/org/lflang/TargetConfig.java | 7 +++++++ org.lflang/src/org/lflang/TargetProperty.java | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/org.lflang/src/org/lflang/TargetConfig.java b/org.lflang/src/org/lflang/TargetConfig.java index b1cba21600..777d7cca16 100644 --- a/org.lflang/src/org/lflang/TargetConfig.java +++ b/org.lflang/src/org/lflang/TargetConfig.java @@ -208,8 +208,15 @@ public class TargetConfig { * The number of worker threads to deploy. The default is zero (i.e., * all work is done in the main thread). */ + @Deprecated public int threads = 0; + /** + * 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. + */ + public int workers = 0; + /** * The timeout to be observed during execution of the program. */ diff --git a/org.lflang/src/org/lflang/TargetProperty.java b/org.lflang/src/org/lflang/TargetProperty.java index 06d5c1e89c..cb206b8352 100644 --- a/org.lflang/src/org/lflang/TargetProperty.java +++ b/org.lflang/src/org/lflang/TargetProperty.java @@ -334,7 +334,7 @@ public enum TargetProperty { * Directive to specify the number of threads. */ THREADS("threads", PrimitiveType.NON_NEGATIVE_INTEGER, - Arrays.asList(Target.C, Target.CPP, Target.CCPP, Target.Python), + Arrays.asList(Target.C, Target.CCPP, Target.Python), (config, value, err) -> { config.threads = ASTUtils.toInteger(value); }), @@ -346,6 +346,16 @@ public enum TargetProperty { (config, value, err) -> { config.timeout = ASTUtils.toTimeValue(value); }), + + + /** + * Directive to specify the number of worker threads used by the runtime. + */ + WORKERS("workers", PrimitiveType.NON_NEGATIVE_INTEGER, + List.of(Target.CPP), + (config, value, err) -> { + config.workers = ASTUtils.toInteger(value); + }), /** * Directive to generate a Dockerfile. This is either a boolean, From b8379fc1fe26384e3205ecf6c17b12698172c748 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 08:37:23 +0100 Subject: [PATCH 02/39] use workers in C++ code generation --- org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt b/org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt index 4774c1eefb..e737fdf6ee 100644 --- a/org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt +++ b/org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt @@ -77,7 +77,7 @@ class CppMainGenerator( |int main(int argc, char **argv) { | cxxopts::Options options("${fileConfig.name}", "Reactor Program"); | - | unsigned threads = ${if (targetConfig.threads != 0) targetConfig.threads else "std::thread::hardware_concurrency()"}; + | unsigned workers = ${if (targetConfig.workers != 0) targetConfig.workers else "std::thread::hardware_concurrency()"}; | bool fast{${targetConfig.fastMode}}; | bool keepalive{${targetConfig.keepalive}}; | reactor::Duration timeout = ${targetConfig.timeout?.toCppCode() ?: "reactor::Duration::zero()"}; @@ -86,7 +86,7 @@ class CppMainGenerator( | options | .set_width(120) | .add_options() - | ("t,threads", "the number of worker threads used by the scheduler", cxxopts::value(threads)->default_value(std::to_string(threads)), "'unsigned'") + | ("w,workers", "the number of worker threads used by the scheduler", cxxopts::value(workers)->default_value(std::to_string(threads)), "'unsigned'") | ("o,timeout", "Time after which the execution is aborted.", cxxopts::value(timeout)->default_value(time_to_string(timeout)), "'FLOAT UNIT'") | ("k,keepalive", "Continue execution even when there are no events to process.", cxxopts::value(keepalive)->default_value("${targetConfig.keepalive}")) | ("f,fast", "Allow logical time to run faster than physical time.", cxxopts::value(fast)->default_value("${targetConfig.fastMode}")) @@ -105,7 +105,7 @@ class CppMainGenerator( | | // validate time parameters (inferredType.isTime) and the timeout parameter via the validate_time_string(val) function | - | reactor::Environment e{threads, keepalive, fast}; + | reactor::Environment e{workers, keepalive, fast}; | | // instantiate the main reactor | ${generateMainReactorInstantiation()} From 52084c33cdd9a222fa08e6566ba772eaa5c78d03 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 08:37:56 +0100 Subject: [PATCH 03/39] use workers in Rust code generation --- org.lflang/src/org/lflang/TargetProperty.java | 2 +- .../org/lflang/generator/rust/RustMainFileEmitter.kt | 11 +++++------ org.lflang/src/org/lflang/generator/rust/RustModel.kt | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/org.lflang/src/org/lflang/TargetProperty.java b/org.lflang/src/org/lflang/TargetProperty.java index cb206b8352..f1fdd930aa 100644 --- a/org.lflang/src/org/lflang/TargetProperty.java +++ b/org.lflang/src/org/lflang/TargetProperty.java @@ -352,7 +352,7 @@ public enum TargetProperty { * Directive to specify the number of worker threads used by the runtime. */ WORKERS("workers", PrimitiveType.NON_NEGATIVE_INTEGER, - List.of(Target.CPP), + List.of(Target.CPP, Target.Rust), (config, value, err) -> { config.workers = ASTUtils.toInteger(value); }), diff --git a/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt b/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt index 1171aaed93..de3ebb4e61 100644 --- a/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt +++ b/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt @@ -29,7 +29,6 @@ import org.lflang.escapeStringLiteral import org.lflang.generator.PrependOperator import org.lflang.generator.PrependOperator.rangeTo import org.lflang.generator.UnsupportedGeneratorFeatureException -import org.lflang.generator.rust.RustEmitter.generateRustProject import org.lflang.joinWithCommasLn @@ -129,7 +128,7 @@ ${" |"..gen.crate.modulesToIncludeInMain.joinToString("\n") { "mod ${it. | let mut options = SchedulerOptions::default(); | options.timeout = $defaultTimeOutAsRust; | options.keep_alive = ${gen.properties.keepAlive}; - | options.threads = ${gen.properties.threads}; // note: zero means "1 per core" + | options.workers = ${gen.properties.workers}; // note: zero means "1 per core" | options.dump_graph = ${gen.properties.dumpDependencyGraph}; | // main params are entirely defaulted @@ -174,13 +173,13 @@ ${" | "..mainReactor.ctorParams.joinWithCommasLn { (it.default | #[clap(long, default_value="$defaultTimeOutAsStr", parse(try_from_str = try_parse_duration), help_heading=Some("RUNTIME OPTIONS"), value_name("time"),)] | timeout: OptionAlias, | - | /// Number of threads to use to execute reactions in parallel. A value + | /// Number of workers to use to execute reactions in parallel. A value | /// of zero means that the runtime will select a value depending on the | /// number of cores available on the machine. | /// This option is **ignored** unless the runtime crate has been built | /// with the feature `parallel-runtime`. - | #[clap(long, default_value="${gen.properties.threads}", help_heading=Some("RUNTIME OPTIONS"), value_name("usize"),)] - | threads: usize, + | #[clap(long, default_value="${gen.properties.workers}", help_heading=Some("RUNTIME OPTIONS"), value_name("usize"),)] + | workers: usize, | | /// Export the dependency graph in DOT format before starting execution. | #[clap(long, help_heading=Some("RUNTIME OPTIONS"),)] @@ -209,7 +208,7 @@ ${" | "..mainReactor.ctorParams.joinWithCommasLn { it.toCliParam( | let mut options = SchedulerOptions::default(); | options.timeout = opts.timeout; | options.keep_alive = opts.keep_alive; - | options.threads = opts.threads; + | options.workers = opts.workers; | options.dump_graph = opts.export_graph; | | let main_args = __MainParams::new( diff --git a/org.lflang/src/org/lflang/generator/rust/RustModel.kt b/org.lflang/src/org/lflang/generator/rust/RustModel.kt index 39ad1304d8..19fff0ea95 100644 --- a/org.lflang/src/org/lflang/generator/rust/RustModel.kt +++ b/org.lflang/src/org/lflang/generator/rust/RustModel.kt @@ -58,7 +58,7 @@ data class RustTargetProperties( val timeoutLf: TimeValue? = null, val singleFile: Boolean = false, /** note: zero means "1 per core" */ - val threads: Int = 0, + val workers: Int = 0, val dumpDependencyGraph: Boolean = false, ) @@ -491,7 +491,7 @@ object RustModelBuilder { timeout = this.timeout?.toRustTimeExpr(), timeoutLf = this.timeout, singleFile = this.singleFileProject, - threads = this.threads, + workers = this.workers, dumpDependencyGraph = this.exportDependencyGraph, ) From ad8150b6566ebdd43bd8eff5a69f359843af4c8c Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 08:48:38 +0100 Subject: [PATCH 04/39] bugfix --- org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt b/org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt index e737fdf6ee..694e491dfa 100644 --- a/org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt +++ b/org.lflang/src/org/lflang/generator/cpp/CppMainGenerator.kt @@ -86,7 +86,7 @@ class CppMainGenerator( | options | .set_width(120) | .add_options() - | ("w,workers", "the number of worker threads used by the scheduler", cxxopts::value(workers)->default_value(std::to_string(threads)), "'unsigned'") + | ("w,workers", "the number of worker threads used by the scheduler", cxxopts::value(workers)->default_value(std::to_string(workers)), "'unsigned'") | ("o,timeout", "Time after which the execution is aborted.", cxxopts::value(timeout)->default_value(time_to_string(timeout)), "'FLOAT UNIT'") | ("k,keepalive", "Continue execution even when there are no events to process.", cxxopts::value(keepalive)->default_value("${targetConfig.keepalive}")) | ("f,fast", "Allow logical time to run faster than physical time.", cxxopts::value(fast)->default_value("${targetConfig.fastMode}")) From a3abdc9a44071678a33e352c1a07d770b6a39197 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 08:48:54 +0100 Subject: [PATCH 05/39] rename threads -> workers in C++ tests --- test/Cpp/src/Composition.lf | 2 +- test/Cpp/src/CompositionAfter.lf | 2 +- test/Cpp/src/Deadline.lf | 2 +- test/Cpp/src/DeadlineHandledAbove.lf | 2 +- test/Cpp/src/DelayInt.lf | 2 +- test/Cpp/src/Determinism.lf | 2 +- test/Cpp/src/DoubleReaction.lf | 2 +- test/Cpp/src/Gain.lf | 2 +- test/Cpp/src/Hello.lf | 2 +- test/Cpp/src/Import.lf | 2 +- test/Cpp/src/Minimal.lf | 2 +- test/Cpp/src/SendingInside.lf | 2 +- test/Cpp/src/TimeLimit.lf | 2 +- test/Cpp/src/concurrent/Threaded.lf | 2 +- test/Cpp/src/multiport/BankToBankMultiportAfter.lf | 2 +- test/Cpp/src/multiport/FullyConnected.lf | 2 +- test/Cpp/src/multiport/FullyConnectedAddressable.lf | 2 +- test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf | 2 +- test/Cpp/src/multiport/MultiportFromBankHierarchy.lf | 2 +- test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf | 2 +- test/Cpp/src/multiport/MultiportFromHierarchy.lf | 2 +- test/Cpp/src/multiport/MultiportOut.lf | 2 +- test/Cpp/src/multiport/MultiportToBankHierarchy.lf | 2 +- test/Cpp/src/multiport/MultiportToHierarchy.lf | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/Cpp/src/Composition.lf b/test/Cpp/src/Composition.lf index af9813fd3f..b1bd3cdf39 100644 --- a/test/Cpp/src/Composition.lf +++ b/test/Cpp/src/Composition.lf @@ -1,7 +1,7 @@ // This test connects a simple counting source to tester // that checks against its own count. target Cpp { - threads: 1, + workers: 1, fast: true, timeout: 10 sec }; diff --git a/test/Cpp/src/CompositionAfter.lf b/test/Cpp/src/CompositionAfter.lf index ef8fab48ff..d92ec2b738 100644 --- a/test/Cpp/src/CompositionAfter.lf +++ b/test/Cpp/src/CompositionAfter.lf @@ -1,7 +1,7 @@ // This test connects a simple counting source to tester // that checks against its own count. target Cpp { - threads: 1, + workers: 1, fast: true, timeout: 10 sec }; diff --git a/test/Cpp/src/Deadline.lf b/test/Cpp/src/Deadline.lf index 48511151b5..c38c3b05bc 100644 --- a/test/Cpp/src/Deadline.lf +++ b/test/Cpp/src/Deadline.lf @@ -2,7 +2,7 @@ // Even numbers are sent by the Source immediately, whereas odd numbers // are sent after a big enough delay to violate the deadline. target Cpp { - threads: 1, + workers: 1, timeout: 4 sec }; reactor Source(period:time(2 sec)) { diff --git a/test/Cpp/src/DeadlineHandledAbove.lf b/test/Cpp/src/DeadlineHandledAbove.lf index 5a850c8b6c..d83c9dfcd1 100644 --- a/test/Cpp/src/DeadlineHandledAbove.lf +++ b/test/Cpp/src/DeadlineHandledAbove.lf @@ -1,7 +1,7 @@ // Test a deadline where the deadline violation produces // an output and the container reacts to that output. target Cpp{ - threads: 1 + workers: 1 }; reactor Deadline(threshold:time(100 msec)) { input x:int; diff --git a/test/Cpp/src/DelayInt.lf b/test/Cpp/src/DelayInt.lf index 7a31909742..de5b317fe2 100644 --- a/test/Cpp/src/DelayInt.lf +++ b/test/Cpp/src/DelayInt.lf @@ -1,6 +1,6 @@ // This tests actions with payloads by delaying an input by a fixed amount. target Cpp{ - threads: 1 + workers: 1 }; reactor Delay(delay:time(100 msec)) { input in:int; diff --git a/test/Cpp/src/Determinism.lf b/test/Cpp/src/Determinism.lf index 66f9e16624..9d46bba88a 100644 --- a/test/Cpp/src/Determinism.lf +++ b/test/Cpp/src/Determinism.lf @@ -1,5 +1,5 @@ target Cpp{ - threads: 1 + workers: 1 }; reactor Source { output y:int; diff --git a/test/Cpp/src/DoubleReaction.lf b/test/Cpp/src/DoubleReaction.lf index 125d073263..59ec1bdb03 100644 --- a/test/Cpp/src/DoubleReaction.lf +++ b/test/Cpp/src/DoubleReaction.lf @@ -2,7 +2,7 @@ // trigger it only once. // Correct output for this 2, 4, 6, 8, etc. target Cpp { - threads: 1, + workers: 1, timeout: 10 sec, fast: true }; diff --git a/test/Cpp/src/Gain.lf b/test/Cpp/src/Gain.lf index 5975281f12..ac52bc55a9 100644 --- a/test/Cpp/src/Gain.lf +++ b/test/Cpp/src/Gain.lf @@ -1,6 +1,6 @@ // Example in the Wiki. target Cpp{ - threads: 1 + workers: 1 }; reactor Scale(scale:int(2)) { input x:int; diff --git a/test/Cpp/src/Hello.lf b/test/Cpp/src/Hello.lf index ea66c81b3e..52c8812cb9 100644 --- a/test/Cpp/src/Hello.lf +++ b/test/Cpp/src/Hello.lf @@ -5,7 +5,7 @@ // of 2 seconds, and the third (composite) or 1 second. target Cpp { timeout: 10 sec, - threads: 1, + workers: 1, fast: true }; reactor HelloCpp(period:time(2 secs), message:{=std::string=}("Hello C++")) { diff --git a/test/Cpp/src/Import.lf b/test/Cpp/src/Import.lf index ffc748569c..c875e4bb66 100644 --- a/test/Cpp/src/Import.lf +++ b/test/Cpp/src/Import.lf @@ -1,7 +1,7 @@ // This tests the ability to import a reactor definition // that itself imports a reactor definition. target Cpp{ - threads: 1 + workers: 1 }; import Imported from "lib/Imported.lf"; diff --git a/test/Cpp/src/Minimal.lf b/test/Cpp/src/Minimal.lf index d853a763b8..b2e0ec0fe1 100644 --- a/test/Cpp/src/Minimal.lf +++ b/test/Cpp/src/Minimal.lf @@ -1,6 +1,6 @@ // This is a smoke test of a minimal reactor. target Cpp { - threads: 1 + workers: 1 }; main reactor Minimal { diff --git a/test/Cpp/src/SendingInside.lf b/test/Cpp/src/SendingInside.lf index 70fc936f20..055dd6806a 100644 --- a/test/Cpp/src/SendingInside.lf +++ b/test/Cpp/src/SendingInside.lf @@ -2,7 +2,7 @@ // has its own reaction that routes inputs to the contained reactor. target Cpp { timeout: 10 sec, - threads: 1, + workers: 1, fast: true }; reactor Printer { diff --git a/test/Cpp/src/TimeLimit.lf b/test/Cpp/src/TimeLimit.lf index fe13b97fec..3f1e6e4fc4 100644 --- a/test/Cpp/src/TimeLimit.lf +++ b/test/Cpp/src/TimeLimit.lf @@ -5,7 +5,7 @@ // Failure for this test is failing to halt or getting the wrong data. target Cpp { fast: true, - threads: 1 + workers: 1 }; reactor Clock(offset:time(0), period:time(1 sec)) { output y:int; diff --git a/test/Cpp/src/concurrent/Threaded.lf b/test/Cpp/src/concurrent/Threaded.lf index ad5e5349b9..b0f043f7f6 100644 --- a/test/Cpp/src/concurrent/Threaded.lf +++ b/test/Cpp/src/concurrent/Threaded.lf @@ -9,7 +9,7 @@ // than 800 msec to complete 200 msec of logical time. target Cpp { timeout: 2 sec, - threads: 1 + workers: 1 }; reactor Source { diff --git a/test/Cpp/src/multiport/BankToBankMultiportAfter.lf b/test/Cpp/src/multiport/BankToBankMultiportAfter.lf index 0a74e8f8d7..91d46dfcf6 100644 --- a/test/Cpp/src/multiport/BankToBankMultiportAfter.lf +++ b/test/Cpp/src/multiport/BankToBankMultiportAfter.lf @@ -2,7 +2,7 @@ target Cpp { timeout: 2 sec, fast: true, - threads: 4 + workers: 4 }; reactor Source(width:size_t(1)) { timer t(0, 200 msec); diff --git a/test/Cpp/src/multiport/FullyConnected.lf b/test/Cpp/src/multiport/FullyConnected.lf index eb10cc528b..af213a2d61 100644 --- a/test/Cpp/src/multiport/FullyConnected.lf +++ b/test/Cpp/src/multiport/FullyConnected.lf @@ -1,5 +1,5 @@ target Cpp { - threads: 1 + workers: 1 } reactor Node(bank_index: size_t(0), num_nodes: size_t(4)) { diff --git a/test/Cpp/src/multiport/FullyConnectedAddressable.lf b/test/Cpp/src/multiport/FullyConnectedAddressable.lf index b27a1eccc8..5849fdd1de 100644 --- a/test/Cpp/src/multiport/FullyConnectedAddressable.lf +++ b/test/Cpp/src/multiport/FullyConnectedAddressable.lf @@ -1,7 +1,7 @@ // In this pattern, each node can send direct messages to individual other nodes target Cpp { - threads: 1 + workers: 1 } reactor Node(bank_index: size_t(0), num_nodes: size_t(4)) { diff --git a/test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf b/test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf index f6816042d2..0bea058135 100644 --- a/test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf +++ b/test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf @@ -1,7 +1,7 @@ // In this pattern, each node can send direct messages to individual other nodes target Cpp { - threads: 1 + workers: 1 } import Node from "FullyConnectedAddressable.lf" diff --git a/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf b/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf index ada038de7a..36601d14dd 100644 --- a/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf +++ b/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf @@ -2,7 +2,7 @@ // Here, the bank is smaller than the width of the sending port. target Cpp { timeout: 2 sec, - threads: 1, + workers: 1, fast: true }; reactor Source(bank_index:size_t(0)) { diff --git a/test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf b/test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf index 3deba9e7a2..1250a6a5a6 100644 --- a/test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf +++ b/test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf @@ -2,7 +2,7 @@ // Here, the bank is smaller than the width of the sending port. target Cpp { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source(bank_index:int(0)) { diff --git a/test/Cpp/src/multiport/MultiportFromHierarchy.lf b/test/Cpp/src/multiport/MultiportFromHierarchy.lf index a98870a26e..0ec126215f 100644 --- a/test/Cpp/src/multiport/MultiportFromHierarchy.lf +++ b/test/Cpp/src/multiport/MultiportFromHierarchy.lf @@ -1,7 +1,7 @@ // Check multiport output to multiport input, where the former is a hierarchical reactor. target Cpp { timeout: 2 sec, - threads: 1, + workers: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportOut.lf b/test/Cpp/src/multiport/MultiportOut.lf index 1ace1876bb..0994a2ec43 100644 --- a/test/Cpp/src/multiport/MultiportOut.lf +++ b/test/Cpp/src/multiport/MultiportOut.lf @@ -1,7 +1,7 @@ // Check multiport capabilities on Outputs. target Cpp { timeout: 2 sec, - threads: 1, + workers: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportToBankHierarchy.lf b/test/Cpp/src/multiport/MultiportToBankHierarchy.lf index 84d619ea4e..bf115e2aca 100644 --- a/test/Cpp/src/multiport/MultiportToBankHierarchy.lf +++ b/test/Cpp/src/multiport/MultiportToBankHierarchy.lf @@ -2,7 +2,7 @@ // Here, the bank is smaller than the width of the sending port. target Cpp { timeout: 2 sec, - threads: 1, + workers: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportToHierarchy.lf b/test/Cpp/src/multiport/MultiportToHierarchy.lf index 06cc6d037c..dc0cca46b7 100644 --- a/test/Cpp/src/multiport/MultiportToHierarchy.lf +++ b/test/Cpp/src/multiport/MultiportToHierarchy.lf @@ -2,7 +2,7 @@ // Note that the destination reactor has width wider than the sender, so one input is dangling. target Cpp { timeout: 2 sec, - threads: 1, + workers: 1, fast: true }; reactor Source(width:size_t(4)) { From 501ba424536376bbaee1e16230d7629361a10e15 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 08:53:26 +0100 Subject: [PATCH 06/39] update lfc and the test runner --- org.lflang.lfc/src/org/lflang/lfc/Main.java | 4 ++-- .../src/org/lflang/tests/Configurators.java | 10 ++++++---- .../src/org/lflang/generator/JavaGeneratorUtils.java | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/org.lflang.lfc/src/org/lflang/lfc/Main.java b/org.lflang.lfc/src/org/lflang/lfc/Main.java index 829a854204..2538987889 100644 --- a/org.lflang.lfc/src/org/lflang/lfc/Main.java +++ b/org.lflang.lfc/src/org/lflang/lfc/Main.java @@ -118,8 +118,8 @@ enum CLIOption { RTI("r", "rti", true, false, "Specify the location of the RTI.", true), RUNTIME_VERSION(null, "runtime-version", true, false, "Specify the version of the runtime library used for compiling LF programs.", true), SCHEDULER("s", "scheduler", true, false, "Specify the runtime scheduler (if supported).", true), - THREADS("t", "threads", true, false, "Specify the default number of threads.", true), - VERSION(null, "version", false, false, "Print version inforomation.", false); + VERSION(null, "version", false, false, "Print version information.", false), + WORKERS("w", "workers", true, false, "Specify the default number of worker threads.", true); /** * The corresponding Apache CLI Option object. diff --git a/org.lflang.tests/src/org/lflang/tests/Configurators.java b/org.lflang.tests/src/org/lflang/tests/Configurators.java index 1e64dc5f5e..7793a6c9cf 100644 --- a/org.lflang.tests/src/org/lflang/tests/Configurators.java +++ b/org.lflang.tests/src/org/lflang/tests/Configurators.java @@ -46,24 +46,26 @@ public interface Configurator { } /** - * Configure the given test by setting its `threads` target property to 0. + * Configure the given test by setting its `workers` target property to 1. * * @param test The test to configure. * @return True if successful, false otherwise. */ public static boolean useSingleThread(LFTest test) { - test.getContext().getArgs().setProperty("threads", "0"); + // FIXME: also need to set 'threading' to false here + test.getContext().getArgs().setProperty("workers", "1"); return true; } /** - * Configure the given test by setting its `threads` target property to 4. + * Configure the given test by setting its `workers` target property to 4. * * @param test The test to configure * @return True if successful, false otherwise. */ public static boolean useFourThreads(LFTest test) { - test.getContext().getArgs().setProperty("threads", "4"); + // FIXME: also need to set 'threading' to true here + test.getContext().getArgs().setProperty("workers", "4"); return true; } diff --git a/org.lflang/src/org/lflang/generator/JavaGeneratorUtils.java b/org.lflang/src/org/lflang/generator/JavaGeneratorUtils.java index 87bb2393eb..d7fcf1acb1 100644 --- a/org.lflang/src/org/lflang/generator/JavaGeneratorUtils.java +++ b/org.lflang/src/org/lflang/generator/JavaGeneratorUtils.java @@ -91,7 +91,7 @@ public static void setTargetConfig( targetConfig.noCompile = true; } if (context.getArgs().containsKey("threads")) { - targetConfig.threads = Integer.parseInt(context.getArgs().getProperty("threads")); + targetConfig.workers = Integer.parseInt(context.getArgs().getProperty("workers")); } if (context.getArgs().containsKey("target-compiler")) { targetConfig.compiler = context.getArgs().getProperty("target-compiler"); From 4a7cca6926f26d77b72397f8c636a83c61e10e63 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 08:58:49 +0100 Subject: [PATCH 07/39] adjust the C++ benchmark runner configuration --- benchmark/runner/conf/target/lf-cpp.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/runner/conf/target/lf-cpp.yaml b/benchmark/runner/conf/target/lf-cpp.yaml index 2eb864a4c8..a2d2778297 100644 --- a/benchmark/runner/conf/target/lf-cpp.yaml +++ b/benchmark/runner/conf/target/lf-cpp.yaml @@ -7,7 +7,7 @@ compile: ["${lf_path}/bin/lfc", "${target.params.extra_args}", "src/${benchmark.targets.lf-cpp.lf_file}"] run: ["bin/${benchmark.targets.lf-cpp.binary}", - "--threads", "${threads}", + "--workers", "${threads}", "--numIterations", "${iterations}", "${args:benchmark.targets.lf-cpp.run_args}"] parser: From d64a875422fbe06599715dde52ffe67d281df82d Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 09:14:56 +0100 Subject: [PATCH 08/39] fix C++ examples --- example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf | 2 +- example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf | 2 +- example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf b/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf index 65a9f4b03f..da581c7871 100644 --- a/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf +++ b/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf @@ -8,7 +8,7 @@ */ target Cpp { - threads: 1 + workers: 1 } reactor Node(bank_index: size_t(0), num_nodes: size_t(4)) { diff --git a/example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf b/example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf index 86900a0fef..02543f814a 100644 --- a/example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf +++ b/example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf @@ -10,7 +10,7 @@ */ target Cpp { - threads: 1 + workers: 1 } reactor Node(bank_index: size_t(0), num_nodes: size_t(4)) { diff --git a/example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf b/example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf index 5f34ee9987..c5fb30d98d 100644 --- a/example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf +++ b/example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf @@ -4,7 +4,7 @@ // dimension. Nodes are organized in Rows which are grouped to form the matrix. target Cpp { - threads: 1 + workers: 1 }; public preamble {= From 2a5b2e32eec33839d4278af01568476186823c45 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 09:24:11 +0100 Subject: [PATCH 09/39] update lfc test script --- .github/scripts/test-lfc.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/scripts/test-lfc.sh b/.github/scripts/test-lfc.sh index 2f82c01964..f9ebbb46a6 100755 --- a/.github/scripts/test-lfc.sh +++ b/.github/scripts/test-lfc.sh @@ -65,9 +65,9 @@ bin/lfc --output-path . test/C/src/Minimal.lf # programs. bin/lfc --runtime-version ca216ccc3da5ecff0e8013f75e275d7acac099de test/Cpp/src/Minimal.lf -# -t,--threads Specify the default number of threads. -bin/lfc -t 2 test/C/src/Minimal.lf -bin/lfc -threads 2 test/C/src/Minimal.lf +# -w,--workers Specify the default number of worker threads. +bin/lfc -w 2 test/C/src/Minimal.lf +bin/lfc -workers 2 test/C/src/Minimal.lf # --target-compiler Target compiler to invoke. # (Added no-compile to avoid adding dependency.) From c5260b8e558e9634198d85b6e9ae35f7b2926f21 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 09:31:44 +0100 Subject: [PATCH 10/39] fix typo after merge --- org.lflang.tests/src/org/lflang/tests/Configurators.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang.tests/src/org/lflang/tests/Configurators.java b/org.lflang.tests/src/org/lflang/tests/Configurators.java index 672a5a1caf..d0912457be 100644 --- a/org.lflang.tests/src/org/lflang/tests/Configurators.java +++ b/org.lflang.tests/src/org/lflang/tests/Configurators.java @@ -65,7 +65,7 @@ public static boolean useSingleThread(LFTest test) { */ public static boolean useFourThreads(LFTest test) { // FIXME: also need to set 'threading' to true here - test.context().getArgs().setProperty("workers", "4"); + test.context.getArgs().setProperty("workers", "4"); return true; } From dcc328dfa2fb498b8d70b000fd3b3521df778cf8 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 09:46:34 +0100 Subject: [PATCH 11/39] fix rust code generation --- .../src/org/lflang/generator/rust/RustMainFileEmitter.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt b/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt index de3ebb4e61..0a28891fac 100644 --- a/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt +++ b/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt @@ -128,7 +128,7 @@ ${" |"..gen.crate.modulesToIncludeInMain.joinToString("\n") { "mod ${it. | let mut options = SchedulerOptions::default(); | options.timeout = $defaultTimeOutAsRust; | options.keep_alive = ${gen.properties.keepAlive}; - | options.workers = ${gen.properties.workers}; // note: zero means "1 per core" + | options.threads = ${gen.properties.workers}; // note: zero means "1 per core" | options.dump_graph = ${gen.properties.dumpDependencyGraph}; | // main params are entirely defaulted @@ -208,7 +208,7 @@ ${" | "..mainReactor.ctorParams.joinWithCommasLn { it.toCliParam( | let mut options = SchedulerOptions::default(); | options.timeout = opts.timeout; | options.keep_alive = opts.keep_alive; - | options.workers = opts.workers; + | options.threads = opts.workers; | options.dump_graph = opts.export_graph; | | let main_args = __MainParams::new( From bff9583c43f49044cbebdb2055915c85992b0c60 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 11:01:32 +0100 Subject: [PATCH 12/39] update the rust benchmark runner configuration --- benchmark/runner/conf/target/lf-rust.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/runner/conf/target/lf-rust.yaml b/benchmark/runner/conf/target/lf-rust.yaml index 699d89faf9..e72f5d6881 100644 --- a/benchmark/runner/conf/target/lf-rust.yaml +++ b/benchmark/runner/conf/target/lf-rust.yaml @@ -6,7 +6,7 @@ compile: ["${lf_path}/bin/lfc", "src/${benchmark.targets.lf-rust.lf_file}"] run: [ "bin/${benchmark.targets.lf-rust.binary}", "--main-num-iterations", "${iterations}", - "--threads", "${threads}", + "--workers", "${threads}", "${args:benchmark.targets.lf-rust.run_args}" ] parser: From 8069bf8f90403971160fc2c79989a319a05422e7 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 14:09:40 +0100 Subject: [PATCH 13/39] add threading target property --- org.lflang/src/org/lflang/TargetConfig.java | 5 +++++ org.lflang/src/org/lflang/TargetProperty.java | 22 +++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/org.lflang/src/org/lflang/TargetConfig.java b/org.lflang/src/org/lflang/TargetConfig.java index 067ab2c906..f89407fed8 100644 --- a/org.lflang/src/org/lflang/TargetConfig.java +++ b/org.lflang/src/org/lflang/TargetConfig.java @@ -217,6 +217,11 @@ public class TargetConfig { */ public int workers = 0; + /** + * Indicate whether the runtime should use multithreaded execution. + */ + public boolean threading = true; + /** * The timeout to be observed during execution of the program. */ diff --git a/org.lflang/src/org/lflang/TargetProperty.java b/org.lflang/src/org/lflang/TargetProperty.java index 18ff57af06..cba8a6e440 100644 --- a/org.lflang/src/org/lflang/TargetProperty.java +++ b/org.lflang/src/org/lflang/TargetProperty.java @@ -339,15 +339,15 @@ public enum TargetProperty { (config, value, err) -> { config.threads = ASTUtils.toInteger(value); }), - + /** - * Directive to specify the execution timeout. + * Directive to indicate whether the runtime should use multi-threading. */ - TIMEOUT("timeout", PrimitiveType.TIME_VALUE, Target.ALL, - (config, value, err) -> { - config.timeout = ASTUtils.toTimeValue(value); - }), - + THREADING("threading", PrimitiveType.BOOLEAN, + List.of(Target.C, Target.CCPP, Target.Python), + (config, value, err) -> { + config.threading = ASTUtils.toBoolean(value); + }), /** * Directive to specify the number of worker threads used by the runtime. @@ -358,6 +358,14 @@ public enum TargetProperty { config.workers = ASTUtils.toInteger(value); }), + /** + * Directive to specify the execution timeout. + */ + TIMEOUT("timeout", PrimitiveType.TIME_VALUE, Target.ALL, + (config, value, err) -> { + config.timeout = ASTUtils.toTimeValue(value); + }), + /** * Directive to generate a Dockerfile. This is either a boolean, * true or false, or a dictionary of options. From 6b1cd9ef49e33243a650d9c987f7632307960515 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 14:19:16 +0100 Subject: [PATCH 14/39] use threading and workers in the C generator --- .../org/lflang/generator/c/CGenerator.xtend | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index be989cecb7..b3a513ab60 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -378,8 +378,8 @@ class CGenerator extends GeneratorBase { if (action.origin == ActionOrigin.PHYSICAL) { // If the unthreaded runtime is requested, use the threaded runtime instead // because it is the only one currently capable of handling asynchronous events. - if (targetConfig.threads < 1) { - targetConfig.threads = 1 + if (!targetConfig.threading) { + targetConfig.threading = true errorReporter.reportWarning( action, '''Using the threaded C runtime to allow for asynchronous handling of« @@ -484,11 +484,11 @@ class CGenerator extends GeneratorBase { "mixed_radix.c", "mixed_radix.h" ); - if (targetConfig.threads === 0) { - coreFiles.add("reactor.c") - } else { + if (targetConfig.threading) { addSchedulerFiles(coreFiles); coreFiles.add("threaded/reactor_threaded.c") + } else { + coreFiles.add("reactor.c") } addPlatformFiles(coreFiles); @@ -1041,12 +1041,12 @@ class CGenerator extends GeneratorBase { ''') code.indent() - if (targetConfig.threads > 0) { + if (targetConfig.threading && targetConfig.workers > 0) { // Set this as the default in the generated code, // but only if it has not been overridden on the command line. code.pr(''' if (_lf_number_of_threads == 0u) { - _lf_number_of_threads = «targetConfig.threads»u; + _lf_number_of_threads = «targetConfig.workers»u; } ''') } @@ -1630,10 +1630,10 @@ class CGenerator extends GeneratorBase { } /** - * Generate code to initialize the scheduler foer the threaded C runtime. + * Generate code to initialize the scheduler for the threaded C runtime. */ protected def initializeScheduler() { - if (targetConfig.threads > 0) { + if (targetConfig.threading) { val numReactionsPerLevel = this.main.assignLevels.getNumReactionsPerLevel(); code.pr(''' @@ -1644,7 +1644,7 @@ class CGenerator extends GeneratorBase { .num_reactions_per_level = &num_reactions_per_level[0], .num_reactions_per_level_size = (size_t) «numReactionsPerLevel.size»}; lf_sched_init( - «targetConfig.threads», + «targetConfig.workers», &sched_params ); ''') @@ -4152,7 +4152,8 @@ class CGenerator extends GeneratorBase { code.pr(CPreambleGenerator.generateFederatedDirective(targetConfig.coordination)) // Handle target parameters. // First, if there are federates, then ensure that threading is enabled. - targetConfig.threads = CUtil.minThreadsToHandleInputPorts(federates) + targetConfig.threading = true + targetConfig.workers = CUtil.minThreadsToHandleInputPorts(federates) } if (hasModalReactors) { @@ -4255,7 +4256,7 @@ class CGenerator extends GeneratorBase { /** Add necessary source files specific to the target language. */ protected def includeTargetLanguageSourceFiles() { - if (targetConfig.threads > 0) { + if (targetConfig.threading) { code.pr("#include \"core/threaded/reactor_threaded.c\"") code.pr("#include \"core/threaded/scheduler.h\"") } else { From 8de7fd043047913cbd967b55d51591a8e6d54b02 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 14:28:57 +0100 Subject: [PATCH 15/39] remove the threads property --- org.lflang/src/org/lflang/TargetConfig.java | 7 ------- org.lflang/src/org/lflang/TargetProperty.java | 9 --------- .../src/org/lflang/generator/c/CCmakeGenerator.java | 4 ++-- org.lflang/src/org/lflang/generator/c/CCompiler.java | 4 ++-- .../org/lflang/generator/python/PythonGenerator.java | 12 +++++++----- 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/org.lflang/src/org/lflang/TargetConfig.java b/org.lflang/src/org/lflang/TargetConfig.java index f89407fed8..ca26861bfd 100644 --- a/org.lflang/src/org/lflang/TargetConfig.java +++ b/org.lflang/src/org/lflang/TargetConfig.java @@ -204,13 +204,6 @@ public class TargetConfig { /** What runtime scheduler to use. */ public SchedulerOption schedulerType = SchedulerOption.getDefault(); - /** - * The number of worker threads to deploy. The default is zero (i.e., - * all work is done in the main thread). - */ - @Deprecated - public int threads = 0; - /** * 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. diff --git a/org.lflang/src/org/lflang/TargetProperty.java b/org.lflang/src/org/lflang/TargetProperty.java index cba8a6e440..946249c5ff 100644 --- a/org.lflang/src/org/lflang/TargetProperty.java +++ b/org.lflang/src/org/lflang/TargetProperty.java @@ -331,15 +331,6 @@ public enum TargetProperty { config.singleFileProject = ASTUtils.toBoolean(value); }), - /** - * Directive to specify the number of threads. - */ - THREADS("threads", PrimitiveType.NON_NEGATIVE_INTEGER, - Arrays.asList(Target.C, Target.CCPP, Target.Python), - (config, value, err) -> { - config.threads = ASTUtils.toInteger(value); - }), - /** * Directive to indicate whether the runtime should use multi-threading. */ diff --git a/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java b/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java index 4faabfa2af..2e29eb48fc 100644 --- a/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java +++ b/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java @@ -150,7 +150,7 @@ CodeBuilder generateCMakeCode( cMakeCode.pr(")"); cMakeCode.newLine(); - if (targetConfig.threads != 0 || targetConfig.tracing != null) { + if (targetConfig.threading || targetConfig.tracing != null) { // If threaded computation is requested, add a the threads option. cMakeCode.pr("# Find threads and link to it"); cMakeCode.pr("find_package(Threads REQUIRED)"); @@ -160,7 +160,7 @@ CodeBuilder generateCMakeCode( // If the LF program itself is threaded or if tracing is enabled, we need to define // NUMBER_OF_WORKERS so that platform-specific C files will contain the appropriate functions cMakeCode.pr("# Set the number of workers to enable threading"); - cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC NUMBER_OF_WORKERS="+targetConfig.threads+")"); + cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC NUMBER_OF_WORKERS="+targetConfig.workers+")"); cMakeCode.newLine(); } diff --git a/org.lflang/src/org/lflang/generator/c/CCompiler.java b/org.lflang/src/org/lflang/generator/c/CCompiler.java index c3296ea6b4..19c2c700ae 100644 --- a/org.lflang/src/org/lflang/generator/c/CCompiler.java +++ b/org.lflang/src/org/lflang/generator/c/CCompiler.java @@ -191,11 +191,11 @@ public LFCommand compileCCommand( }); // If threaded computation is requested, add a -pthread option. - if (targetConfig.threads != 0 || targetConfig.tracing != null) { + if (targetConfig.threading || targetConfig.tracing != null) { compileArgs.add("-pthread"); // If the LF program itself is threaded or if tracing is enabled, we need to define // NUMBER_OF_WORKERS so that platform-specific C files will contain the appropriate functions - compileArgs.add("-DNUMBER_OF_WORKERS="+targetConfig.threads); + compileArgs.add("-DNUMBER_OF_WORKERS="+targetConfig.workers); } // Finally, add the compiler flags in target parameters (if any) diff --git a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java index e52db93876..d0ce0e1a2f 100644 --- a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java +++ b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java @@ -265,8 +265,8 @@ public String generatePythonSetupFile() { macros.add(generateMacroEntry(entry.getKey(), entry.getValue())); } - if (targetConfig.threads != 0 || targetConfig.tracing != null) { - macros.add(generateMacroEntry("NUMBER_OF_WORKERS", String.valueOf(targetConfig.threads))); + if (targetConfig.threading || targetConfig.tracing != null) { + macros.add(generateMacroEntry("NUMBER_OF_WORKERS", String.valueOf(targetConfig.workers))); } List installRequires = new ArrayList<>(pythonRequiredModules); @@ -370,7 +370,8 @@ public boolean generatePreamble() { code.pr(CPreambleGenerator.generateFederatedDirective(targetConfig.coordination)); // Handle target parameters. // First, if there are federates, then ensure that threading is enabled. - targetConfig.threads = CUtil.minThreadsToHandleInputPorts(federates); + targetConfig.threading = true; + targetConfig.workers = CUtil.minThreadsToHandleInputPorts(federates); } includeTargetLanguageHeaders(); code.pr(CPreambleGenerator.generateNumFederatesDirective(federates.size())); @@ -651,9 +652,10 @@ public boolean isOSCompatible() { */ @Override public void doGenerate(Resource resource, LFGeneratorContext context) { - // If there are federates, assign the number of threads in the CGenerator to 1 + // If there are federates, assign the number of worker threads in the CGenerator to 1 if (isFederated) { - targetConfig.threads = 1; + targetConfig.threading = true; + targetConfig.workers = 1; } // Prevent the CGenerator from compiling the C code. From e8e1b1ce3fde0c4dd972a7325dd3c0dc29de5a3b Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 14:34:15 +0100 Subject: [PATCH 16/39] rename threads -> workers in examples and tests --- example/C/src/Deadline.lf | 2 +- example/C/src/MQTT/MQTTDistributed.lf | 2 +- example/C/src/MQTT/MQTTPhysical.lf | 2 +- example/C/src/MQTT/MQTTPublisher.lf | 2 +- example/C/src/MQTT/MQTTSubscriber.lf | 2 +- example/C/src/Patterns/Chain_02_Pipeline.lf | 2 +- example/C/src/ROS/ROSBuiltInSerialization.lf | 2 +- example/C/src/ReflexGame.lf | 2 +- example/C/src/ReflexGame/ReflexGameTest.lf | 2 +- example/C/src/Rhythm/Rhythm.lf | 2 +- example/C/src/Rhythm/SensorSimulator.lf | 2 +- example/C/src/SleepingBarber.lf | 4 ++-- example/C/src/TrainDoor/TrainDoor.lf | 2 +- test/C/src/concurrent/AsyncCallback.lf | 2 +- test/C/src/concurrent/AsyncCallbackDrop.lf | 2 +- test/C/src/concurrent/AsyncCallbackReplace.lf | 2 +- test/C/src/concurrent/CompositionThreaded.lf | 2 +- test/C/src/concurrent/DeadlineHandledAboveThreaded.lf | 2 +- test/C/src/concurrent/DeadlineThreaded.lf | 2 +- test/C/src/concurrent/DelayIntThreaded.lf | 2 +- test/C/src/concurrent/DeterminismThreaded.lf | 2 +- test/C/src/concurrent/DoubleReactionThreaded.lf | 2 +- test/C/src/concurrent/GainThreaded.lf | 2 +- test/C/src/concurrent/HelloThreaded.lf | 2 +- test/C/src/concurrent/ImportThreaded.lf | 2 +- test/C/src/concurrent/MinimalThreaded.lf | 2 +- test/C/src/concurrent/PingPongThreaded.lf | 2 +- test/C/src/concurrent/ScheduleAt.lf | 2 +- test/C/src/concurrent/ScheduleTwice.lf | 2 +- test/C/src/concurrent/ScheduleTwiceThreaded.lf | 2 +- test/C/src/concurrent/SendingInsideThreaded.lf | 2 +- test/C/src/concurrent/StarvationThreaded.lf | 2 +- test/C/src/concurrent/StopThreaded.lf | 2 +- test/C/src/concurrent/StopZeroThreaded.lf | 2 +- test/C/src/concurrent/ThreadedMultiport.lf | 2 +- test/C/src/concurrent/ThreadedThreaded.lf | 2 +- test/C/src/concurrent/TimeLimitThreaded.lf | 2 +- test/C/src/concurrent/TimeoutThreaded.lf | 2 +- test/C/src/concurrent/TimeoutZeroThreaded.lf | 2 +- test/C/src/concurrent/Tracing.lf | 2 +- test/C/src/federated/LoopDistributedCentralized.lf | 2 +- test/C/src/federated/LoopDistributedCentralizedPrecedence.lf | 2 +- .../LoopDistributedCentralizedPrecedenceHierarchy.lf | 2 +- test/C/src/federated/LoopDistributedDecentralized.lf | 2 +- test/C/src/federated/LoopDistributedDouble.lf | 2 +- .../failing/LoopDistributedDecentralizedPrecedence.lf | 2 +- .../LoopDistributedDecentralizedPrecedenceHierarchy.lf | 2 +- test/C/src/multiport/BankToBank.lf | 2 +- test/C/src/multiport/BankToBankMultiport.lf | 2 +- test/C/src/multiport/BankToBankMultiportAfter.lf | 2 +- test/C/src/multiport/MultiportFromBank.lf | 2 +- test/C/src/multiport/MultiportFromBankHierarchy.lf | 2 +- test/C/src/multiport/MultiportFromBankHierarchyAfter.lf | 2 +- test/C/src/multiport/MultiportFromHierarchy.lf | 2 +- test/C/src/multiport/MultiportFromReaction.lf | 2 +- test/C/src/multiport/MultiportOut.lf | 2 +- test/C/src/multiport/MultiportToBankHierarchy.lf | 2 +- test/C/src/multiport/MultiportToHierarchy.lf | 2 +- test/C/src/multiport/MultiportToMultiport.lf | 2 +- test/C/src/multiport/MultiportToMultiportParameter.lf | 2 +- test/C/src/multiport/MultiportToReaction.lf | 2 +- test/C/src/target/HelloWorldThreadedCPP.lf | 2 +- .../src/federated/failing/LoopDistributedCentralized.lf | 2 +- .../federated/failing/LoopDistributedCentralizedPrecedence.lf | 2 +- .../failing/LoopDistributedCentralizedPrecedenceHierarchy.lf | 2 +- .../src/federated/failing/LoopDistributedDecentralized.lf | 2 +- test/Python/src/federated/failing/LoopDistributedDouble.lf | 2 +- 67 files changed, 68 insertions(+), 68 deletions(-) diff --git a/example/C/src/Deadline.lf b/example/C/src/Deadline.lf index 91eb37b237..4fbbeb5869 100644 --- a/example/C/src/Deadline.lf +++ b/example/C/src/Deadline.lf @@ -10,7 +10,7 @@ * @author Edward A. Lee */ target C { - threads: 1, + workers: 1, keepalive: true }; preamble {= diff --git a/example/C/src/MQTT/MQTTDistributed.lf b/example/C/src/MQTT/MQTTDistributed.lf index 92ea8504bd..5093af80a4 100644 --- a/example/C/src/MQTT/MQTTDistributed.lf +++ b/example/C/src/MQTT/MQTTDistributed.lf @@ -62,7 +62,7 @@ * @author Edward A. Lee */ target C { - threads: 1, // Must use threaded implementation so schedule is thread safe. + workers: 1, // Must use threaded implementation so schedule is thread safe. cmake-include: [ "include/paho-extension.cmake", "include/mosquitto-extension.cmake"], diff --git a/example/C/src/MQTT/MQTTPhysical.lf b/example/C/src/MQTT/MQTTPhysical.lf index dd5753d340..d25e402346 100644 --- a/example/C/src/MQTT/MQTTPhysical.lf +++ b/example/C/src/MQTT/MQTTPhysical.lf @@ -61,7 +61,7 @@ */ target C { // Must use threaded implementation so schedule is thread safe. - threads: 1, + workers: 1, cmake-include: [ "include/paho-extension.cmake", "include/mosquitto-extension.cmake", diff --git a/example/C/src/MQTT/MQTTPublisher.lf b/example/C/src/MQTT/MQTTPublisher.lf index 163e8b0d88..9f37e1a89b 100644 --- a/example/C/src/MQTT/MQTTPublisher.lf +++ b/example/C/src/MQTT/MQTTPublisher.lf @@ -6,7 +6,7 @@ * @author Edward A. Lee */ target C { - threads: 1 // This makes sure the threaded runtime is used, giving access to the mutex. + workers: 1 // This makes sure the threaded runtime is used, giving access to the mutex. }; /** diff --git a/example/C/src/MQTT/MQTTSubscriber.lf b/example/C/src/MQTT/MQTTSubscriber.lf index 3e6bb169ef..da0cac618a 100644 --- a/example/C/src/MQTT/MQTTSubscriber.lf +++ b/example/C/src/MQTT/MQTTSubscriber.lf @@ -7,7 +7,7 @@ * @author Edward A. Lee */ target C { - threads: 1 // This makes sure the threaded runtime is used, giving access to the mutex. + workers: 1 // This makes sure the threaded runtime is used, giving access to the mutex. }; /** diff --git a/example/C/src/Patterns/Chain_02_Pipeline.lf b/example/C/src/Patterns/Chain_02_Pipeline.lf index ad3347aef5..8b9656ed31 100644 --- a/example/C/src/Patterns/Chain_02_Pipeline.lf +++ b/example/C/src/Patterns/Chain_02_Pipeline.lf @@ -15,7 +15,7 @@ * @author Edward A. Lee */ target C { - threads: 4, + workers: 4, timeout: 1 sec } diff --git a/example/C/src/ROS/ROSBuiltInSerialization.lf b/example/C/src/ROS/ROSBuiltInSerialization.lf index 5a2c2ab29c..b07284e75a 100644 --- a/example/C/src/ROS/ROSBuiltInSerialization.lf +++ b/example/C/src/ROS/ROSBuiltInSerialization.lf @@ -24,7 +24,7 @@ target CCpp { cmake: true, // Only CMake is supported cmake-include: "include/CMakeListsExtension.txt", - threads: 1, + workers: 1, }; preamble {= diff --git a/example/C/src/ReflexGame.lf b/example/C/src/ReflexGame.lf index a342da1d58..9c225439c8 100644 --- a/example/C/src/ReflexGame.lf +++ b/example/C/src/ReflexGame.lf @@ -12,7 +12,7 @@ * @author Marten Lohstroh */ target C { - threads: 1, + workers: 1, keepalive: true }; /** diff --git a/example/C/src/ReflexGame/ReflexGameTest.lf b/example/C/src/ReflexGame/ReflexGameTest.lf index 2c0a090abf..f41a5686ab 100644 --- a/example/C/src/ReflexGame/ReflexGameTest.lf +++ b/example/C/src/ReflexGame/ReflexGameTest.lf @@ -1,5 +1,5 @@ target C { - threads: 1, + workers: 1, keepalive: true, timeout: 5 sec }; diff --git a/example/C/src/Rhythm/Rhythm.lf b/example/C/src/Rhythm/Rhythm.lf index 59d3deff0f..e659dd7a08 100644 --- a/example/C/src/Rhythm/Rhythm.lf +++ b/example/C/src/Rhythm/Rhythm.lf @@ -29,7 +29,7 @@ * @see RhythmDistributedNoUI.lf */ target C { - threads: 2, + workers: 2, tracing: true, files: [ "/lib/c/reactor-c/util/sensor_simulator.c", "/lib/c/reactor-c/util/sensor_simulator.h", diff --git a/example/C/src/Rhythm/SensorSimulator.lf b/example/C/src/Rhythm/SensorSimulator.lf index 194a1f0c97..81dac4f608 100644 --- a/example/C/src/Rhythm/SensorSimulator.lf +++ b/example/C/src/Rhythm/SensorSimulator.lf @@ -3,7 +3,7 @@ * This has no audio output, but just tests the ncurses interface. */ target C { - threads: 2, + workers: 2, files: [ "/lib/c/reactor-c/util/sensor_simulator.c", "/lib/c/reactor-c/util/sensor_simulator.h", diff --git a/example/C/src/SleepingBarber.lf b/example/C/src/SleepingBarber.lf index 6abb4ac2bb..db6849658b 100644 --- a/example/C/src/SleepingBarber.lf +++ b/example/C/src/SleepingBarber.lf @@ -33,7 +33,7 @@ target C { fast: true, - threads: 0, + threading: false, cmake-include: "/lib/c/reactor-c/util/deque.cmake", files: ["/lib/c/reactor-c/util/deque.h", "/lib/c/reactor-c/util/deque.c"] }; @@ -312,4 +312,4 @@ main reactor ( customers.done -> factory.customer_done; customers.returned -> factory.customer_returned; -} \ No newline at end of file +} diff --git a/example/C/src/TrainDoor/TrainDoor.lf b/example/C/src/TrainDoor/TrainDoor.lf index d1aa7501d9..38cb841d54 100644 --- a/example/C/src/TrainDoor/TrainDoor.lf +++ b/example/C/src/TrainDoor/TrainDoor.lf @@ -1,4 +1,4 @@ -target C {threads: 1, keepalive: true}; +target C {workers: 1, keepalive: true}; preamble {= #include diff --git a/test/C/src/concurrent/AsyncCallback.lf b/test/C/src/concurrent/AsyncCallback.lf index e9c160282f..36a8ee4844 100644 --- a/test/C/src/concurrent/AsyncCallback.lf +++ b/test/C/src/concurrent/AsyncCallback.lf @@ -9,7 +9,7 @@ */ target C { - threads: 2, + workers: 2, tracing: true, timeout: 2 sec }; diff --git a/test/C/src/concurrent/AsyncCallbackDrop.lf b/test/C/src/concurrent/AsyncCallbackDrop.lf index 36d5d45d23..c78c484cb4 100644 --- a/test/C/src/concurrent/AsyncCallbackDrop.lf +++ b/test/C/src/concurrent/AsyncCallbackDrop.lf @@ -3,7 +3,7 @@ // This test will not work with the unthreaded C target because that target // does not implement any mutex protecting the event queue. target C { - threads: 1, + workers: 1, timeout: 2 sec }; diff --git a/test/C/src/concurrent/AsyncCallbackReplace.lf b/test/C/src/concurrent/AsyncCallbackReplace.lf index d771143bca..00408712e7 100644 --- a/test/C/src/concurrent/AsyncCallbackReplace.lf +++ b/test/C/src/concurrent/AsyncCallbackReplace.lf @@ -3,7 +3,7 @@ // This test will not work with the unthreaded C target because that target // does not implement any mutex protecting the event queue. target C { - threads: 1, + workers: 1, timeout: 2 sec }; diff --git a/test/C/src/concurrent/CompositionThreaded.lf b/test/C/src/concurrent/CompositionThreaded.lf index dc281bf0f0..385c4fab8e 100644 --- a/test/C/src/concurrent/CompositionThreaded.lf +++ b/test/C/src/concurrent/CompositionThreaded.lf @@ -1,7 +1,7 @@ // This test connects a simple counting source to tester // that checks against its own count. target C { - threads: 1, + workers: 1, fast: true, timeout: 10 sec }; diff --git a/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf b/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf index 77fe936f74..4cf598d9ca 100644 --- a/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf +++ b/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf @@ -1,6 +1,6 @@ // Test a deadline where the deadline violation produces // an output and the container reacts to that output. -target C {threads: 1}; +target C {workers: 1}; reactor Deadline(threshold:time(100 msec)) { input x:int; output deadline_violation:bool; diff --git a/test/C/src/concurrent/DeadlineThreaded.lf b/test/C/src/concurrent/DeadlineThreaded.lf index a1fbca4b4f..fb4d1624d9 100644 --- a/test/C/src/concurrent/DeadlineThreaded.lf +++ b/test/C/src/concurrent/DeadlineThreaded.lf @@ -3,7 +3,7 @@ // are sent after a big enough delay to violate the deadline. target C { timeout: 3 sec, - threads: 1 + workers: 1 }; reactor Source(period:time(1500 msec)) { diff --git a/test/C/src/concurrent/DelayIntThreaded.lf b/test/C/src/concurrent/DelayIntThreaded.lf index e36a814161..9144547ab4 100644 --- a/test/C/src/concurrent/DelayIntThreaded.lf +++ b/test/C/src/concurrent/DelayIntThreaded.lf @@ -1,6 +1,6 @@ // This tests actions with payloads by delaying an input by a fixed amount. target C { - threads: 1 + workers: 1 }; reactor Delay(delay:time(100 msec)) { input in:int; diff --git a/test/C/src/concurrent/DeterminismThreaded.lf b/test/C/src/concurrent/DeterminismThreaded.lf index 5229f9e59e..7d5bc666fa 100644 --- a/test/C/src/concurrent/DeterminismThreaded.lf +++ b/test/C/src/concurrent/DeterminismThreaded.lf @@ -1,5 +1,5 @@ target C { - threads: 1 + workers: 1 }; reactor Source { output y:int; diff --git a/test/C/src/concurrent/DoubleReactionThreaded.lf b/test/C/src/concurrent/DoubleReactionThreaded.lf index 9c8d434d4f..81813b8612 100644 --- a/test/C/src/concurrent/DoubleReactionThreaded.lf +++ b/test/C/src/concurrent/DoubleReactionThreaded.lf @@ -4,7 +4,7 @@ target C { timeout: 10 sec, fast: true, - threads: 1 + workers: 1 }; reactor Clock(offset:time(0), period:time(1 sec)) { output y:int; diff --git a/test/C/src/concurrent/GainThreaded.lf b/test/C/src/concurrent/GainThreaded.lf index 36c0860d94..8ef1f35174 100644 --- a/test/C/src/concurrent/GainThreaded.lf +++ b/test/C/src/concurrent/GainThreaded.lf @@ -1,5 +1,5 @@ // Example in the Wiki. - target C {threads: 1}; + target C {workers: 1}; reactor Scale(scale:int(2)) { input x:int; output y:int; diff --git a/test/C/src/concurrent/HelloThreaded.lf b/test/C/src/concurrent/HelloThreaded.lf index 5fd80207a3..dd708b7aa2 100644 --- a/test/C/src/concurrent/HelloThreaded.lf +++ b/test/C/src/concurrent/HelloThreaded.lf @@ -6,7 +6,7 @@ target C { timeout: 10 sec, fast: true, - threads: 1 + workers: 1 }; reactor Reschedule(period:time(2 secs), message:string("Hello C")) { state count:int(0); diff --git a/test/C/src/concurrent/ImportThreaded.lf b/test/C/src/concurrent/ImportThreaded.lf index f7910ddae6..5b637085b7 100644 --- a/test/C/src/concurrent/ImportThreaded.lf +++ b/test/C/src/concurrent/ImportThreaded.lf @@ -1,7 +1,7 @@ // This tests the ability to import a reactor definition // that itself imports a reactor definition. target C { - threads: 2 + workers: 2 }; import Imported from "../lib/Imported.lf"; diff --git a/test/C/src/concurrent/MinimalThreaded.lf b/test/C/src/concurrent/MinimalThreaded.lf index 6e7f7b26c9..87587234ab 100644 --- a/test/C/src/concurrent/MinimalThreaded.lf +++ b/test/C/src/concurrent/MinimalThreaded.lf @@ -1,6 +1,6 @@ // This is a smoke test of a minimal reactor. target C { - threads: 1 + workers: 1 }; main reactor MinimalThreaded { timer t; diff --git a/test/C/src/concurrent/PingPongThreaded.lf b/test/C/src/concurrent/PingPongThreaded.lf index e7f17417a3..c15b1ed72d 100644 --- a/test/C/src/concurrent/PingPongThreaded.lf +++ b/test/C/src/concurrent/PingPongThreaded.lf @@ -23,7 +23,7 @@ */ target C { fast: true, - threads: 8 + workers: 8 }; reactor Ping(count:int(10)) { input receive:int; diff --git a/test/C/src/concurrent/ScheduleAt.lf b/test/C/src/concurrent/ScheduleAt.lf index 8cd469a710..13ac9ef4bd 100644 --- a/test/C/src/concurrent/ScheduleAt.lf +++ b/test/C/src/concurrent/ScheduleAt.lf @@ -8,7 +8,7 @@ target C { timeout: 1 sec, keepalive: true, - threads: 1 + workers: 1 }; reactor Scheduler { diff --git a/test/C/src/concurrent/ScheduleTwice.lf b/test/C/src/concurrent/ScheduleTwice.lf index b06e682cdb..7e0f7269c2 100644 --- a/test/C/src/concurrent/ScheduleTwice.lf +++ b/test/C/src/concurrent/ScheduleTwice.lf @@ -1,4 +1,4 @@ -target C {threads: 1}; +target C {workers: 1}; main reactor ScheduleTwice { logical action a:int; state rc_count:int(0); diff --git a/test/C/src/concurrent/ScheduleTwiceThreaded.lf b/test/C/src/concurrent/ScheduleTwiceThreaded.lf index 1df61adab3..185c21c238 100644 --- a/test/C/src/concurrent/ScheduleTwiceThreaded.lf +++ b/test/C/src/concurrent/ScheduleTwiceThreaded.lf @@ -1,4 +1,4 @@ -target C {threads: 1}; +target C {workers: 1}; main reactor { logical action a:int; state rc_count:int(0); diff --git a/test/C/src/concurrent/SendingInsideThreaded.lf b/test/C/src/concurrent/SendingInsideThreaded.lf index 749768657e..42de2ddec3 100644 --- a/test/C/src/concurrent/SendingInsideThreaded.lf +++ b/test/C/src/concurrent/SendingInsideThreaded.lf @@ -1,7 +1,7 @@ // This tests a reactor that contains another reactor and also // has its own reaction that routes inputs to the contained reactor. target C { - threads: 3, + workers: 3, timeout: 10 sec, fast: true }; diff --git a/test/C/src/concurrent/StarvationThreaded.lf b/test/C/src/concurrent/StarvationThreaded.lf index fcd18715c1..863f4f8317 100644 --- a/test/C/src/concurrent/StarvationThreaded.lf +++ b/test/C/src/concurrent/StarvationThreaded.lf @@ -6,7 +6,7 @@ * @author Soroush Bateni */ target C { - threads: 8 + workers: 8 }; reactor SuperDenseSender(number_of_iterations:int(10)){ logical action loop; diff --git a/test/C/src/concurrent/StopThreaded.lf b/test/C/src/concurrent/StopThreaded.lf index 8a8f8ca911..3ea0e6d552 100644 --- a/test/C/src/concurrent/StopThreaded.lf +++ b/test/C/src/concurrent/StopThreaded.lf @@ -6,7 +6,7 @@ */ target C { timeout: 11 msec, - threads: 4, + workers: 4, build-type: RelWithDebInfo, // logging: DEBUG }; diff --git a/test/C/src/concurrent/StopZeroThreaded.lf b/test/C/src/concurrent/StopZeroThreaded.lf index e3db1f9663..0c2beb924f 100644 --- a/test/C/src/concurrent/StopZeroThreaded.lf +++ b/test/C/src/concurrent/StopZeroThreaded.lf @@ -5,7 +5,7 @@ * @author Soroush Bateni */ target C { - threads: 4 + workers: 4 }; reactor Sender { diff --git a/test/C/src/concurrent/ThreadedMultiport.lf b/test/C/src/concurrent/ThreadedMultiport.lf index ee3837d7bf..5f8d2109bd 100644 --- a/test/C/src/concurrent/ThreadedMultiport.lf +++ b/test/C/src/concurrent/ThreadedMultiport.lf @@ -2,7 +2,7 @@ target C { timeout: 2 sec, flags: "", // Disable compiler optimization so that TakeTime actually takes time. - threads: 4 + workers: 4 }; reactor Source(width:int(4)) { timer t(0, 200 msec); diff --git a/test/C/src/concurrent/ThreadedThreaded.lf b/test/C/src/concurrent/ThreadedThreaded.lf index 4b582acee4..5be9b6c1e5 100644 --- a/test/C/src/concurrent/ThreadedThreaded.lf +++ b/test/C/src/concurrent/ThreadedThreaded.lf @@ -10,7 +10,7 @@ target C { timeout: 2 sec, tracing: true, flags: "", // Disable compiler optimization so that TakeTime actually takes time. - threads: 4 + workers: 4 }; reactor Source { timer t(0, 200 msec); diff --git a/test/C/src/concurrent/TimeLimitThreaded.lf b/test/C/src/concurrent/TimeLimitThreaded.lf index b667c6ca4c..c1880a03ca 100644 --- a/test/C/src/concurrent/TimeLimitThreaded.lf +++ b/test/C/src/concurrent/TimeLimitThreaded.lf @@ -6,7 +6,7 @@ target C { flags: "-O2", fast: true, - threads: 8 + workers: 8 }; reactor Clock(offset:time(0), period:time(1 sec)) { output y:int; diff --git a/test/C/src/concurrent/TimeoutThreaded.lf b/test/C/src/concurrent/TimeoutThreaded.lf index 8424468ea3..3f03cf2bbd 100644 --- a/test/C/src/concurrent/TimeoutThreaded.lf +++ b/test/C/src/concurrent/TimeoutThreaded.lf @@ -6,7 +6,7 @@ */ target C { timeout: 11 msec, - threads: 4 + workers: 4 }; import Sender from "../lib/LoopedActionSender.lf" diff --git a/test/C/src/concurrent/TimeoutZeroThreaded.lf b/test/C/src/concurrent/TimeoutZeroThreaded.lf index 94d556364b..4422686a57 100644 --- a/test/C/src/concurrent/TimeoutZeroThreaded.lf +++ b/test/C/src/concurrent/TimeoutZeroThreaded.lf @@ -7,7 +7,7 @@ */ target C { timeout: 0 sec, - threads: 4 + workers: 4 }; import Sender from "../lib/LoopedActionSender.lf" diff --git a/test/C/src/concurrent/Tracing.lf b/test/C/src/concurrent/Tracing.lf index 71abfd914f..a9d0aa887a 100644 --- a/test/C/src/concurrent/Tracing.lf +++ b/test/C/src/concurrent/Tracing.lf @@ -3,7 +3,7 @@ target C { timeout: 2 sec, tracing: true, flags: "", // Disable compiler optimization so that TakeTime actually takes time. - threads: 4, + workers: 4, logging: DEBUG }; reactor Source { diff --git a/test/C/src/federated/LoopDistributedCentralized.lf b/test/C/src/federated/LoopDistributedCentralized.lf index ff4e60333f..3ba15a62c8 100644 --- a/test/C/src/federated/LoopDistributedCentralized.lf +++ b/test/C/src/federated/LoopDistributedCentralized.lf @@ -8,7 +8,7 @@ target C { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - threads: 2, + workers: 2, timeout: 5 sec } preamble {= diff --git a/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf b/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf index 3c3a3ac0a8..7ac196b7af 100644 --- a/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf +++ b/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf @@ -9,7 +9,7 @@ target C { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - threads: 2, + workers: 2, timeout: 5 sec } diff --git a/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf b/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf index 690733e2a3..36a8e70112 100644 --- a/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf +++ b/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf @@ -9,7 +9,7 @@ target C { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - threads: 2, + workers: 2, timeout: 5 sec } diff --git a/test/C/src/federated/LoopDistributedDecentralized.lf b/test/C/src/federated/LoopDistributedDecentralized.lf index 5382ffdf6e..611f87b3dd 100644 --- a/test/C/src/federated/LoopDistributedDecentralized.lf +++ b/test/C/src/federated/LoopDistributedDecentralized.lf @@ -6,7 +6,7 @@ */ target C { coordination: decentralized, - threads: 3, + workers: 3, timeout: 5 sec } preamble {= diff --git a/test/C/src/federated/LoopDistributedDouble.lf b/test/C/src/federated/LoopDistributedDouble.lf index e4959476a6..103c30c68b 100644 --- a/test/C/src/federated/LoopDistributedDouble.lf +++ b/test/C/src/federated/LoopDistributedDouble.lf @@ -8,7 +8,7 @@ target C { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - threads: 2, + workers: 2, timeout: 5 sec } preamble {= diff --git a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedence.lf b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedence.lf index 9f6be0df79..45167ac702 100644 --- a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedence.lf +++ b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedence.lf @@ -8,7 +8,7 @@ target C { flags: "-Wall", coordination: decentralized, - threads: 2, + workers: 2, timeout: 4900 msec } diff --git a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf index ec63a26f48..66dddd79ae 100644 --- a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf +++ b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf @@ -8,7 +8,7 @@ target C { flags: "-Wall", coordination: decentralized, - threads: 2, + workers: 2, timeout: 4900 msec } diff --git a/test/C/src/multiport/BankToBank.lf b/test/C/src/multiport/BankToBank.lf index f01df5bf0e..fa9f89987a 100644 --- a/test/C/src/multiport/BankToBank.lf +++ b/test/C/src/multiport/BankToBank.lf @@ -2,7 +2,7 @@ target C { timeout: 2 sec, fast: true, - threads: 4 + workers: 4 }; reactor Source( bank_index:int(0) diff --git a/test/C/src/multiport/BankToBankMultiport.lf b/test/C/src/multiport/BankToBankMultiport.lf index 13a4d8ee3f..01be54b5ad 100644 --- a/test/C/src/multiport/BankToBankMultiport.lf +++ b/test/C/src/multiport/BankToBankMultiport.lf @@ -2,7 +2,7 @@ target C { timeout: 2 sec, fast: true, - threads: 4 + workers: 4 }; reactor Source(width:int(1)) { timer t(0, 200 msec); diff --git a/test/C/src/multiport/BankToBankMultiportAfter.lf b/test/C/src/multiport/BankToBankMultiportAfter.lf index 5c41e9a6f4..5f494fc882 100644 --- a/test/C/src/multiport/BankToBankMultiportAfter.lf +++ b/test/C/src/multiport/BankToBankMultiportAfter.lf @@ -2,7 +2,7 @@ target C { timeout: 2 sec, fast: true, - threads: 4 + workers: 4 }; reactor Source(width:int(1)) { timer t(0, 200 msec); diff --git a/test/C/src/multiport/MultiportFromBank.lf b/test/C/src/multiport/MultiportFromBank.lf index af3cd860da..176521c31e 100644 --- a/test/C/src/multiport/MultiportFromBank.lf +++ b/test/C/src/multiport/MultiportFromBank.lf @@ -2,7 +2,7 @@ // Here, the bank is smaller than the width of the sending port. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source( diff --git a/test/C/src/multiport/MultiportFromBankHierarchy.lf b/test/C/src/multiport/MultiportFromBankHierarchy.lf index 26106bfe3f..2c48280050 100644 --- a/test/C/src/multiport/MultiportFromBankHierarchy.lf +++ b/test/C/src/multiport/MultiportFromBankHierarchy.lf @@ -2,7 +2,7 @@ // Here, the bank is smaller than the width of the sending port. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; import Source, Destination from "MultiportFromBank.lf" diff --git a/test/C/src/multiport/MultiportFromBankHierarchyAfter.lf b/test/C/src/multiport/MultiportFromBankHierarchyAfter.lf index c5f8e461d1..d983d43b1e 100644 --- a/test/C/src/multiport/MultiportFromBankHierarchyAfter.lf +++ b/test/C/src/multiport/MultiportFromBankHierarchyAfter.lf @@ -2,7 +2,7 @@ // Here, the bank is smaller than the width of the sending port. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; import Destination from "MultiportFromBank.lf" diff --git a/test/C/src/multiport/MultiportFromHierarchy.lf b/test/C/src/multiport/MultiportFromHierarchy.lf index 3e1b4954b2..648fb240ed 100644 --- a/test/C/src/multiport/MultiportFromHierarchy.lf +++ b/test/C/src/multiport/MultiportFromHierarchy.lf @@ -1,7 +1,7 @@ // Check multiport output to multiport input, where the former is a hierarchical reactor. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source(width:int(3)) { diff --git a/test/C/src/multiport/MultiportFromReaction.lf b/test/C/src/multiport/MultiportFromReaction.lf index 04ef8cd0ab..418f5656f8 100644 --- a/test/C/src/multiport/MultiportFromReaction.lf +++ b/test/C/src/multiport/MultiportFromReaction.lf @@ -1,7 +1,7 @@ // Check reaction to multiport input of a contained reactor. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Destination(width:int(1)) { diff --git a/test/C/src/multiport/MultiportOut.lf b/test/C/src/multiport/MultiportOut.lf index a6014c0e38..7f85f23918 100644 --- a/test/C/src/multiport/MultiportOut.lf +++ b/test/C/src/multiport/MultiportOut.lf @@ -1,7 +1,7 @@ // Check multiport capabilities on Outputs. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source { diff --git a/test/C/src/multiport/MultiportToBankHierarchy.lf b/test/C/src/multiport/MultiportToBankHierarchy.lf index 9b9cffbaea..6468e2dddc 100644 --- a/test/C/src/multiport/MultiportToBankHierarchy.lf +++ b/test/C/src/multiport/MultiportToBankHierarchy.lf @@ -2,7 +2,7 @@ // Here, the bank is smaller than the width of the sending port. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source(width:int(2)) { diff --git a/test/C/src/multiport/MultiportToHierarchy.lf b/test/C/src/multiport/MultiportToHierarchy.lf index 5d69da9787..b2c3777e52 100644 --- a/test/C/src/multiport/MultiportToHierarchy.lf +++ b/test/C/src/multiport/MultiportToHierarchy.lf @@ -2,7 +2,7 @@ // Note that the destination reactor has width wider than the sender, so one input is dangling. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source(width:int(2)) { diff --git a/test/C/src/multiport/MultiportToMultiport.lf b/test/C/src/multiport/MultiportToMultiport.lf index 0a7d8fa53c..4c5346057b 100644 --- a/test/C/src/multiport/MultiportToMultiport.lf +++ b/test/C/src/multiport/MultiportToMultiport.lf @@ -1,7 +1,7 @@ // Check multiport output to multiport input. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source(width:int(1)) { diff --git a/test/C/src/multiport/MultiportToMultiportParameter.lf b/test/C/src/multiport/MultiportToMultiportParameter.lf index 38be3297fe..1f0e60c99c 100644 --- a/test/C/src/multiport/MultiportToMultiportParameter.lf +++ b/test/C/src/multiport/MultiportToMultiportParameter.lf @@ -1,7 +1,7 @@ // Check multiport output to multiport input. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source(width:int(1)) { diff --git a/test/C/src/multiport/MultiportToReaction.lf b/test/C/src/multiport/MultiportToReaction.lf index c5670cafae..d50eb2fb8d 100644 --- a/test/C/src/multiport/MultiportToReaction.lf +++ b/test/C/src/multiport/MultiportToReaction.lf @@ -1,7 +1,7 @@ // Check reaction to multiport output of a contained reactor. target C { timeout: 2 sec, - threads: 4, + workers: 4, fast: true }; reactor Source(width:int(1)) { diff --git a/test/C/src/target/HelloWorldThreadedCPP.lf b/test/C/src/target/HelloWorldThreadedCPP.lf index 6f89c6b626..3ba7a87d50 100644 --- a/test/C/src/target/HelloWorldThreadedCPP.lf +++ b/test/C/src/target/HelloWorldThreadedCPP.lf @@ -5,7 +5,7 @@ */ target CCpp { tracing: true, - threads: 1, + workers: 1, logging: DEBUG }; import HelloWorld from "HelloWorldCCPP.lf"; diff --git a/test/Python/src/federated/failing/LoopDistributedCentralized.lf b/test/Python/src/federated/failing/LoopDistributedCentralized.lf index 9b1a665d33..f496975929 100644 --- a/test/Python/src/federated/failing/LoopDistributedCentralized.lf +++ b/test/Python/src/federated/failing/LoopDistributedCentralized.lf @@ -11,7 +11,7 @@ target Python { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - threads: 2, + workers: 2, timeout: 5 sec } preamble {= diff --git a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedence.lf b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedence.lf index 80fe08dcee..f087e75360 100644 --- a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedence.lf +++ b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedence.lf @@ -12,7 +12,7 @@ target Python { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - threads: 2, + workers: 2, timeout: 5 sec } diff --git a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf index e435c658fe..d48606d896 100644 --- a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf +++ b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf @@ -13,7 +13,7 @@ target Python { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - threads: 2, + workers: 2, timeout: 5 sec } diff --git a/test/Python/src/federated/failing/LoopDistributedDecentralized.lf b/test/Python/src/federated/failing/LoopDistributedDecentralized.lf index 0900857866..4f4a5d1d2a 100644 --- a/test/Python/src/federated/failing/LoopDistributedDecentralized.lf +++ b/test/Python/src/federated/failing/LoopDistributedDecentralized.lf @@ -9,7 +9,7 @@ target Python { coordination: decentralized, - threads: 3, + workers: 3, timeout: 5 sec } preamble {= diff --git a/test/Python/src/federated/failing/LoopDistributedDouble.lf b/test/Python/src/federated/failing/LoopDistributedDouble.lf index 85cb55ccba..d76806789f 100644 --- a/test/Python/src/federated/failing/LoopDistributedDouble.lf +++ b/test/Python/src/federated/failing/LoopDistributedDouble.lf @@ -9,7 +9,7 @@ target Python { coordination: centralized, - threads: 2, + workers: 2, timeout: 5 sec } preamble {= From 30fa3ee545bafedfc4b8cecf6b8d365d6ff2fcb1 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 14:47:53 +0100 Subject: [PATCH 17/39] update all the c benchmarks --- benchmark/C/Savina/src/concurrency/Banking.lf | 10 ++++++---- benchmark/C/Savina/src/concurrency/BoundedBuffer.lf | 9 +++++---- .../C/Savina/src/concurrency/CigaretteSmoker.lf | 9 +++++---- benchmark/C/Savina/src/concurrency/Dictionary.lf | 9 +++++---- benchmark/C/Savina/src/concurrency/LogisticMap.lf | 11 ++++++----- benchmark/C/Savina/src/concurrency/Philosophers.lf | 9 +++++---- benchmark/C/Savina/src/concurrency/SleepingBarber.lf | 9 +++++---- benchmark/C/Savina/src/concurrency/SortedList.lf | 9 +++++---- benchmark/C/Savina/src/micro/Big.lf | 12 ++++++------ benchmark/C/Savina/src/micro/Chameneos.lf | 9 +++++---- benchmark/C/Savina/src/micro/Counting.lf | 9 +++++---- benchmark/C/Savina/src/micro/PingPong.lf | 9 +++++---- benchmark/C/Savina/src/micro/ThreadRing.lf | 9 +++++---- benchmark/C/Savina/src/micro/Throughput.lf | 9 +++++---- benchmark/C/Savina/src/parallelism/Apsp.lf | 9 +++++---- benchmark/C/Savina/src/parallelism/FilterBank.lf | 9 +++++---- benchmark/C/Savina/src/parallelism/GuidedSearch.lf | 9 +++++---- benchmark/C/Savina/src/parallelism/MatMul.lf | 9 +++++---- benchmark/C/Savina/src/parallelism/NQueens.lf | 8 +++++--- benchmark/C/Savina/src/parallelism/PiPrecision.lf | 9 +++++---- benchmark/C/Savina/src/parallelism/RadixSort.lf | 9 +++++---- benchmark/C/Savina/src/parallelism/Trapezoidal.lf | 9 +++++---- benchmark/runner/conf/target/lf-c-unthreaded.yaml | 3 +-- benchmark/runner/conf/target/lf-c.yaml | 4 ++-- 24 files changed, 116 insertions(+), 94 deletions(-) diff --git a/benchmark/C/Savina/src/concurrency/Banking.lf b/benchmark/C/Savina/src/concurrency/Banking.lf index 3f9e94d7d2..6331c78cf3 100644 --- a/benchmark/C/Savina/src/concurrency/Banking.lf +++ b/benchmark/C/Savina/src/concurrency/Banking.lf @@ -51,12 +51,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") + cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] files: ["../include/PseudoRandom.h", "/lib/c/reactor-c/util/deque.h", diff --git a/benchmark/C/Savina/src/concurrency/BoundedBuffer.lf b/benchmark/C/Savina/src/concurrency/BoundedBuffer.lf index 539822b3a6..f6d3de032b 100644 --- a/benchmark/C/Savina/src/concurrency/BoundedBuffer.lf +++ b/benchmark/C/Savina/src/concurrency/BoundedBuffer.lf @@ -22,13 +22,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] files: ["/lib/c/reactor-c/util/deque.h", "/lib/c/reactor-c/util/deque.c", diff --git a/benchmark/C/Savina/src/concurrency/CigaretteSmoker.lf b/benchmark/C/Savina/src/concurrency/CigaretteSmoker.lf index 17f034c65d..67b5a255f3 100644 --- a/benchmark/C/Savina/src/concurrency/CigaretteSmoker.lf +++ b/benchmark/C/Savina/src/concurrency/CigaretteSmoker.lf @@ -61,13 +61,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] files: "../include/PseudoRandom.h" }; diff --git a/benchmark/C/Savina/src/concurrency/Dictionary.lf b/benchmark/C/Savina/src/concurrency/Dictionary.lf index c795b4164b..e3c8873ea8 100644 --- a/benchmark/C/Savina/src/concurrency/Dictionary.lf +++ b/benchmark/C/Savina/src/concurrency/Dictionary.lf @@ -26,13 +26,14 @@ target CCpp { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] build-type : RelWithDebInfo, logging: "warn" diff --git a/benchmark/C/Savina/src/concurrency/LogisticMap.lf b/benchmark/C/Savina/src/concurrency/LogisticMap.lf index 7577a60f58..d69c5c2081 100644 --- a/benchmark/C/Savina/src/concurrency/LogisticMap.lf +++ b/benchmark/C/Savina/src/concurrency/LogisticMap.lf @@ -9,14 +9,15 @@ */ target C { - /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + /* [[[cog + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] } diff --git a/benchmark/C/Savina/src/concurrency/Philosophers.lf b/benchmark/C/Savina/src/concurrency/Philosophers.lf index ac68f95ad4..85e43a39b6 100644 --- a/benchmark/C/Savina/src/concurrency/Philosophers.lf +++ b/benchmark/C/Savina/src/concurrency/Philosophers.lf @@ -9,13 +9,14 @@ */ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] logging: warn }; diff --git a/benchmark/C/Savina/src/concurrency/SleepingBarber.lf b/benchmark/C/Savina/src/concurrency/SleepingBarber.lf index 412536ccb6..66dbb34386 100644 --- a/benchmark/C/Savina/src/concurrency/SleepingBarber.lf +++ b/benchmark/C/Savina/src/concurrency/SleepingBarber.lf @@ -44,13 +44,14 @@ target C { keepalive: true, // To silence warnings; because of the physical action. /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] files: ["/lib/c/reactor-c/util/deque.h", "/lib/c/reactor-c/util/deque.c", "../include/PseudoRandom.h"] }; diff --git a/benchmark/C/Savina/src/concurrency/SortedList.lf b/benchmark/C/Savina/src/concurrency/SortedList.lf index 9519de8c05..241ee3dcbe 100644 --- a/benchmark/C/Savina/src/concurrency/SortedList.lf +++ b/benchmark/C/Savina/src/concurrency/SortedList.lf @@ -16,13 +16,14 @@ target CCpp { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] files: "../include/PseudoRandom.h" }; diff --git a/benchmark/C/Savina/src/micro/Big.lf b/benchmark/C/Savina/src/micro/Big.lf index 9e0b543239..89f0916553 100644 --- a/benchmark/C/Savina/src/micro/Big.lf +++ b/benchmark/C/Savina/src/micro/Big.lf @@ -23,16 +23,16 @@ * @author Arthur Deng */ - - target C{ /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") - ]]] */ + cog.outl("threading: false,") + ]]] */ + threading: false, /// [[[end]]] files: "../include/PseudoRandom.h" }; diff --git a/benchmark/C/Savina/src/micro/Chameneos.lf b/benchmark/C/Savina/src/micro/Chameneos.lf index 279f29080e..88ba0d79c6 100644 --- a/benchmark/C/Savina/src/micro/Chameneos.lf +++ b/benchmark/C/Savina/src/micro/Chameneos.lf @@ -39,13 +39,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] logging: warn } diff --git a/benchmark/C/Savina/src/micro/Counting.lf b/benchmark/C/Savina/src/micro/Counting.lf index ebe4764ce0..a6fb221b90 100644 --- a/benchmark/C/Savina/src/micro/Counting.lf +++ b/benchmark/C/Savina/src/micro/Counting.lf @@ -40,13 +40,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] } diff --git a/benchmark/C/Savina/src/micro/PingPong.lf b/benchmark/C/Savina/src/micro/PingPong.lf index 917c1a38e8..66a771d4e3 100644 --- a/benchmark/C/Savina/src/micro/PingPong.lf +++ b/benchmark/C/Savina/src/micro/PingPong.lf @@ -24,13 +24,14 @@ */ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] fast: true }; diff --git a/benchmark/C/Savina/src/micro/ThreadRing.lf b/benchmark/C/Savina/src/micro/ThreadRing.lf index 2f0019ba33..585275e466 100644 --- a/benchmark/C/Savina/src/micro/ThreadRing.lf +++ b/benchmark/C/Savina/src/micro/ThreadRing.lf @@ -53,13 +53,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] }; diff --git a/benchmark/C/Savina/src/micro/Throughput.lf b/benchmark/C/Savina/src/micro/Throughput.lf index 38b417a1cf..15b89a88d0 100644 --- a/benchmark/C/Savina/src/micro/Throughput.lf +++ b/benchmark/C/Savina/src/micro/Throughput.lf @@ -54,13 +54,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 2, + threading: false, /// [[[end]]] flags: "-lm" }; diff --git a/benchmark/C/Savina/src/parallelism/Apsp.lf b/benchmark/C/Savina/src/parallelism/Apsp.lf index 4b9f03394f..7790f8b70f 100644 --- a/benchmark/C/Savina/src/parallelism/Apsp.lf +++ b/benchmark/C/Savina/src/parallelism/Apsp.lf @@ -19,13 +19,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] build-type : RelWithDebInfo, cmake-include: ["../lib/matrix.cmake"], diff --git a/benchmark/C/Savina/src/parallelism/FilterBank.lf b/benchmark/C/Savina/src/parallelism/FilterBank.lf index 5b1e09f0dd..55e834e874 100644 --- a/benchmark/C/Savina/src/parallelism/FilterBank.lf +++ b/benchmark/C/Savina/src/parallelism/FilterBank.lf @@ -31,13 +31,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] fast: true }; diff --git a/benchmark/C/Savina/src/parallelism/GuidedSearch.lf b/benchmark/C/Savina/src/parallelism/GuidedSearch.lf index a8a2425325..70f3fac988 100644 --- a/benchmark/C/Savina/src/parallelism/GuidedSearch.lf +++ b/benchmark/C/Savina/src/parallelism/GuidedSearch.lf @@ -60,13 +60,14 @@ target CCpp { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] build-type : RelWithDebInfo, cmake-include: "GuidedSearch/GuidedSearch.cmake", diff --git a/benchmark/C/Savina/src/parallelism/MatMul.lf b/benchmark/C/Savina/src/parallelism/MatMul.lf index fb6190f8f4..f8d61fe8e7 100644 --- a/benchmark/C/Savina/src/parallelism/MatMul.lf +++ b/benchmark/C/Savina/src/parallelism/MatMul.lf @@ -8,13 +8,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] cmake-include: "../lib/matrix.cmake", files: ["../lib/matrix.c", "../include/matrix.h"], diff --git a/benchmark/C/Savina/src/parallelism/NQueens.lf b/benchmark/C/Savina/src/parallelism/NQueens.lf index 7da826d0c4..83aed4ac0b 100644 --- a/benchmark/C/Savina/src/parallelism/NQueens.lf +++ b/benchmark/C/Savina/src/parallelism/NQueens.lf @@ -39,12 +39,14 @@ target C{ /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ + threading: false, /// [[[end]]] logging: warn, cmake-include: "/lib/c/reactor-c/util/deque.cmake", diff --git a/benchmark/C/Savina/src/parallelism/PiPrecision.lf b/benchmark/C/Savina/src/parallelism/PiPrecision.lf index c0f0d79bb5..01f19e23a6 100644 --- a/benchmark/C/Savina/src/parallelism/PiPrecision.lf +++ b/benchmark/C/Savina/src/parallelism/PiPrecision.lf @@ -15,13 +15,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] cmake-include: "PiPrecision.cmake" }; diff --git a/benchmark/C/Savina/src/parallelism/RadixSort.lf b/benchmark/C/Savina/src/parallelism/RadixSort.lf index b5141a0d16..c5e3579176 100644 --- a/benchmark/C/Savina/src/parallelism/RadixSort.lf +++ b/benchmark/C/Savina/src/parallelism/RadixSort.lf @@ -13,13 +13,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] files: "../include/PseudoRandom.h" }; diff --git a/benchmark/C/Savina/src/parallelism/Trapezoidal.lf b/benchmark/C/Savina/src/parallelism/Trapezoidal.lf index 5c0455d697..453330ec40 100644 --- a/benchmark/C/Savina/src/parallelism/Trapezoidal.lf +++ b/benchmark/C/Savina/src/parallelism/Trapezoidal.lf @@ -15,13 +15,14 @@ target C { /* [[[cog - if (threaded_runtime=="True"): - cog.outl(f"threads: {threads},") + if (threading=="True"): + cog.outl("threading: true,") + cog.outl(f"workers: {workers},") cog.outl(f"scheduler: {scheduler},") else: - cog.outl("threads: 0,") + cog.outl("threading: false,") ]]] */ - threads: 0, + threading: false, /// [[[end]]] flags: "-lm" }; diff --git a/benchmark/runner/conf/target/lf-c-unthreaded.yaml b/benchmark/runner/conf/target/lf-c-unthreaded.yaml index e142d459a5..a9cd0645b4 100644 --- a/benchmark/runner/conf/target/lf-c-unthreaded.yaml +++ b/benchmark/runner/conf/target/lf-c-unthreaded.yaml @@ -3,9 +3,8 @@ validation_alias: "lf-c" 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", "numIterations=${iterations}", - "-D", "threaded_runtime=False", + "-D", "threading=False", "src/${benchmark.targets.lf-c.lf_file}"] compile: ["${lf_path}/bin/lfc", "src/${benchmark.targets.lf-c.lf_file}"] run: ["bin/${benchmark.targets.lf-c.binary}"] diff --git a/benchmark/runner/conf/target/lf-c.yaml b/benchmark/runner/conf/target/lf-c.yaml index 5422ede6cd..21ed179cbf 100644 --- a/benchmark/runner/conf/target/lf-c.yaml +++ b/benchmark/runner/conf/target/lf-c.yaml @@ -2,10 +2,10 @@ name: lf-c 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", "workers=${threads}", "-D", "scheduler=${target.params.scheduler}", "-D", "numIterations=${iterations}", - "-D", "threaded_runtime=True", + "-D", "threading=True", "src/${benchmark.targets.lf-c.lf_file}"] compile: ["${lf_path}/bin/lfc", "src/${benchmark.targets.lf-c.lf_file}"] run: ["bin/${benchmark.targets.lf-c.binary}"] From 8d130a785cc6a818048cfb3a67e7fe1352785508 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 14:56:29 +0100 Subject: [PATCH 18/39] add --no-threading cli option and fix tests --- .github/scripts/test-lfc.sh | 3 ++- org.lflang.lfc/src/org/lflang/lfc/Main.java | 1 + org.lflang.tests/src/org/lflang/tests/Configurators.java | 4 ++-- org.lflang/src/org/lflang/generator/GeneratorUtils.java | 5 ++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/scripts/test-lfc.sh b/.github/scripts/test-lfc.sh index f9ebbb46a6..1028a239ad 100755 --- a/.github/scripts/test-lfc.sh +++ b/.github/scripts/test-lfc.sh @@ -67,7 +67,8 @@ bin/lfc --runtime-version ca216ccc3da5ecff0e8013f75e275d7acac099de test/Cpp/src/ # -w,--workers Specify the default number of worker threads. bin/lfc -w 2 test/C/src/Minimal.lf -bin/lfc -workers 2 test/C/src/Minimal.lf +bin/lfc --workers 2 test/C/src/Minimal.lf +bin/lfc --no-threading test/C/src/Minimal.lf # --target-compiler Target compiler to invoke. # (Added no-compile to avoid adding dependency.) diff --git a/org.lflang.lfc/src/org/lflang/lfc/Main.java b/org.lflang.lfc/src/org/lflang/lfc/Main.java index cf1c0d4a45..35f8794e99 100644 --- a/org.lflang.lfc/src/org/lflang/lfc/Main.java +++ b/org.lflang.lfc/src/org/lflang/lfc/Main.java @@ -113,6 +113,7 @@ enum CLIOption { HELP("h", "help", false, false, "Display this information.", true), LINT("l", "lint", false, false, "Enable or disable linting of generated code.", true), NO_COMPILE("n", "no-compile", false, false, "Do not invoke target compiler.", true), + NO_THREADING(null, "no-threading", false, false, "Disable multi-threading in the runtime.", true), OUTPUT_PATH("o", "output-path", true, false, "Specify the root output directory.", false), QUIET("q", "quiet", false, false, "Suppress output of the target compiler and other commands", true), RTI("r", "rti", true, false, "Specify the location of the RTI.", true), diff --git a/org.lflang.tests/src/org/lflang/tests/Configurators.java b/org.lflang.tests/src/org/lflang/tests/Configurators.java index d0912457be..2603104c50 100644 --- a/org.lflang.tests/src/org/lflang/tests/Configurators.java +++ b/org.lflang.tests/src/org/lflang/tests/Configurators.java @@ -52,7 +52,7 @@ public interface Configurator { * @return True if successful, false otherwise. */ public static boolean useSingleThread(LFTest test) { - // FIXME: also need to set 'threading' to false here + test.context.getArgs().setProperty("no-threading", null); test.context.getArgs().setProperty("workers", "1"); return true; } @@ -64,7 +64,7 @@ public static boolean useSingleThread(LFTest test) { * @return True if successful, false otherwise. */ public static boolean useFourThreads(LFTest test) { - // FIXME: also need to set 'threading' to true here + // FIXME: What if threading is set to false in the test target properties? Should we force enable it here? test.context.getArgs().setProperty("workers", "4"); return true; } diff --git a/org.lflang/src/org/lflang/generator/GeneratorUtils.java b/org.lflang/src/org/lflang/generator/GeneratorUtils.java index 7e5870ce46..453dff181b 100644 --- a/org.lflang/src/org/lflang/generator/GeneratorUtils.java +++ b/org.lflang/src/org/lflang/generator/GeneratorUtils.java @@ -89,9 +89,12 @@ public static void setTargetConfig( if (context.getArgs().containsKey("no-compile")) { targetConfig.noCompile = true; } - if (context.getArgs().containsKey("threads")) { + if (context.getArgs().containsKey("workers")) { targetConfig.workers = Integer.parseInt(context.getArgs().getProperty("workers")); } + if (context.getArgs().containsKey("no-threading")) { + targetConfig.threading = false; + } if (context.getArgs().containsKey("target-compiler")) { targetConfig.compiler = context.getArgs().getProperty("target-compiler"); } From 2752bd3dc7c43147332abbcc11a3c981d649d1f2 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 15:02:37 +0100 Subject: [PATCH 19/39] enable the workers property for all targets with multithreading --- org.lflang/src/org/lflang/TargetProperty.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/org/lflang/TargetProperty.java b/org.lflang/src/org/lflang/TargetProperty.java index 946249c5ff..71dfd4cc35 100644 --- a/org.lflang/src/org/lflang/TargetProperty.java +++ b/org.lflang/src/org/lflang/TargetProperty.java @@ -344,7 +344,7 @@ public enum TargetProperty { * Directive to specify the number of worker threads used by the runtime. */ WORKERS("workers", PrimitiveType.NON_NEGATIVE_INTEGER, - List.of(Target.CPP, Target.Rust), + List.of(Target.C, Target.CCPP, Target.Python, Target.CPP, Target.Rust), (config, value, err) -> { config.workers = ASTUtils.toInteger(value); }), From ee8fe04ef1a16c2fe7d41c64ae5822a6e533a86c Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 2 Mar 2022 15:19:25 +0100 Subject: [PATCH 20/39] fix tests --- org.lflang.tests/src/org/lflang/tests/Configurators.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang.tests/src/org/lflang/tests/Configurators.java b/org.lflang.tests/src/org/lflang/tests/Configurators.java index 2603104c50..021a6064d3 100644 --- a/org.lflang.tests/src/org/lflang/tests/Configurators.java +++ b/org.lflang.tests/src/org/lflang/tests/Configurators.java @@ -52,7 +52,7 @@ public interface Configurator { * @return True if successful, false otherwise. */ public static boolean useSingleThread(LFTest test) { - test.context.getArgs().setProperty("no-threading", null); + test.context.getArgs().setProperty("no-threading", ""); test.context.getArgs().setProperty("workers", "1"); return true; } From bee3ce6e0c2871bdf320da3d8de542df9eaaf290 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Thu, 3 Mar 2022 14:55:12 +0100 Subject: [PATCH 21/39] rename no-threading cli option to threading and add boolean argument Also adjust the tests to use the correct configuration --- .github/scripts/test-lfc.sh | 3 ++- org.lflang.lfc/src/org/lflang/lfc/Main.java | 2 +- .../src/org/lflang/tests/Configurators.java | 17 +++++++++++++---- .../org/lflang/generator/GeneratorUtils.java | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/scripts/test-lfc.sh b/.github/scripts/test-lfc.sh index 1028a239ad..6f557f8600 100755 --- a/.github/scripts/test-lfc.sh +++ b/.github/scripts/test-lfc.sh @@ -68,7 +68,8 @@ bin/lfc --runtime-version ca216ccc3da5ecff0e8013f75e275d7acac099de test/Cpp/src/ # -w,--workers Specify the default number of worker threads. bin/lfc -w 2 test/C/src/Minimal.lf bin/lfc --workers 2 test/C/src/Minimal.lf -bin/lfc --no-threading test/C/src/Minimal.lf +bin/lfc --threading true test/C/src/Minimal.lf +bin/lfc --threading false test/C/src/Minimal.lf # --target-compiler Target compiler to invoke. # (Added no-compile to avoid adding dependency.) diff --git a/org.lflang.lfc/src/org/lflang/lfc/Main.java b/org.lflang.lfc/src/org/lflang/lfc/Main.java index 35f8794e99..63661ed7e3 100644 --- a/org.lflang.lfc/src/org/lflang/lfc/Main.java +++ b/org.lflang.lfc/src/org/lflang/lfc/Main.java @@ -113,12 +113,12 @@ enum CLIOption { HELP("h", "help", false, false, "Display this information.", true), LINT("l", "lint", false, false, "Enable or disable linting of generated code.", true), NO_COMPILE("n", "no-compile", false, false, "Do not invoke target compiler.", true), - NO_THREADING(null, "no-threading", false, false, "Disable multi-threading in the runtime.", true), OUTPUT_PATH("o", "output-path", true, false, "Specify the root output directory.", false), QUIET("q", "quiet", false, false, "Suppress output of the target compiler and other commands", true), RTI("r", "rti", true, false, "Specify the location of the RTI.", true), RUNTIME_VERSION(null, "runtime-version", true, false, "Specify the version of the runtime library used for compiling LF programs.", true), SCHEDULER("s", "scheduler", true, false, "Specify the runtime scheduler (if supported).", true), + THREADING("t", "threading", true, false, "Specify whether the runtime should use multi-threading (true/false).", true), VERSION(null, "version", false, false, "Print version information.", false), WORKERS("w", "workers", true, false, "Specify the default number of worker threads.", true); diff --git a/org.lflang.tests/src/org/lflang/tests/Configurators.java b/org.lflang.tests/src/org/lflang/tests/Configurators.java index 021a6064d3..dd3e4363a9 100644 --- a/org.lflang.tests/src/org/lflang/tests/Configurators.java +++ b/org.lflang.tests/src/org/lflang/tests/Configurators.java @@ -46,25 +46,34 @@ public interface Configurator { } /** - * Configure the given test by setting its `workers` target property to 1. + * Configure the given test to use single-threaded execution. + * + * For targets that provide a threaded and an unthreaded runtime, + * this configures using the unthreaded runtime. For targets that + * do not distinguish threaded and unthreaded runtime, the number + * of workers is set to 1. * * @param test The test to configure. * @return True if successful, false otherwise. */ public static boolean useSingleThread(LFTest test) { - test.context.getArgs().setProperty("no-threading", ""); + test.context.getArgs().setProperty("threading", "false"); test.context.getArgs().setProperty("workers", "1"); return true; } /** - * Configure the given test by setting its `workers` target property to 4. + * Configure the given test to use multi-threaded with 4 workers. + * + * For targets that provide a threaded and an unthreaded runtime, + * this configures using the threaded runtime. For all targets, + * the number of workers is set to 4. * * @param test The test to configure * @return True if successful, false otherwise. */ public static boolean useFourThreads(LFTest test) { - // FIXME: What if threading is set to false in the test target properties? Should we force enable it here? + test.context.getArgs().setProperty("threading", "true"); test.context.getArgs().setProperty("workers", "4"); return true; } diff --git a/org.lflang/src/org/lflang/generator/GeneratorUtils.java b/org.lflang/src/org/lflang/generator/GeneratorUtils.java index 453dff181b..98ee21f994 100644 --- a/org.lflang/src/org/lflang/generator/GeneratorUtils.java +++ b/org.lflang/src/org/lflang/generator/GeneratorUtils.java @@ -92,8 +92,8 @@ public static void setTargetConfig( if (context.getArgs().containsKey("workers")) { targetConfig.workers = Integer.parseInt(context.getArgs().getProperty("workers")); } - if (context.getArgs().containsKey("no-threading")) { - targetConfig.threading = false; + if (context.getArgs().containsKey("threading")) { + targetConfig.threading = Boolean.parseBoolean(context.getArgs().getProperty("threading")); } if (context.getArgs().containsKey("target-compiler")) { targetConfig.compiler = context.getArgs().getProperty("target-compiler"); From 666bcfd0211aff85f3407ad957c5004dd2434fc6 Mon Sep 17 00:00:00 2001 From: Soroush Bateni Date: Tue, 8 Mar 2022 22:16:59 -0600 Subject: [PATCH 22/39] Slightly adjusted how number of workers are adjusted in the C and Python target (based on @edwardalee's suggestion) --- .../src/org/lflang/generator/c/CGenerator.xtend | 6 +++--- .../org/lflang/generator/python/PythonGenerator.java | 12 +++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index 8690b350a5..b39077b760 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -4149,10 +4149,10 @@ class CGenerator extends GeneratorBase { if (isFederated) { code.pr(CPreambleGenerator.generateFederatedDirective(targetConfig.coordination)) - // Handle target parameters. - // First, if there are federates, then ensure that threading is enabled. + // If the program is federated, then ensure that threading is enabled. targetConfig.threading = true - targetConfig.workers = CUtil.minThreadsToHandleInputPorts(federates) + // Ensure that there are enough worker threads to handle network input control reactions. + targetConfig.workers += CUtil.minThreadsToHandleInputPorts(federates) } if (hasModalReactors) { diff --git a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java index d0ce0e1a2f..3ed40d989c 100644 --- a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java +++ b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java @@ -368,10 +368,10 @@ public boolean generatePreamble() { code.pr(CGenerator.defineLogLevel(this)); if (isFederated) { code.pr(CPreambleGenerator.generateFederatedDirective(targetConfig.coordination)); - // Handle target parameters. - // First, if there are federates, then ensure that threading is enabled. + // If the program is federated, then ensure that threading is enabled. targetConfig.threading = true; - targetConfig.workers = CUtil.minThreadsToHandleInputPorts(federates); + // Ensure that there are enough worker threads to handle network input control reactions. + targetConfig.workers += CUtil.minThreadsToHandleInputPorts(federates); } includeTargetLanguageHeaders(); code.pr(CPreambleGenerator.generateNumFederatesDirective(federates.size())); @@ -652,12 +652,6 @@ public boolean isOSCompatible() { */ @Override public void doGenerate(Resource resource, LFGeneratorContext context) { - // If there are federates, assign the number of worker threads in the CGenerator to 1 - if (isFederated) { - targetConfig.threading = true; - targetConfig.workers = 1; - } - // Prevent the CGenerator from compiling the C code. // The PythonGenerator will compiler it. boolean compileStatus = targetConfig.noCompile; From c2906468a29bd2bd62cbac755310e099d7c50193 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 9 Mar 2022 09:31:04 +0100 Subject: [PATCH 23/39] fix compile errors --- .../src/org/lflang/generator/cpp/CppRos2NodeGenerator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/cpp/CppRos2NodeGenerator.kt b/org.lflang/src/org/lflang/generator/cpp/CppRos2NodeGenerator.kt index f39a00963e..9c83b1bb5b 100644 --- a/org.lflang/src/org/lflang/generator/cpp/CppRos2NodeGenerator.kt +++ b/org.lflang/src/org/lflang/generator/cpp/CppRos2NodeGenerator.kt @@ -59,7 +59,7 @@ class CppRos2NodeGenerator( | |$nodeName::$nodeName(const rclcpp::NodeOptions& node_options) | : Node("$nodeName", node_options) { - | unsigned threads = ${if (targetConfig.threads != 0) targetConfig.threads else "std::thread::hardware_concurrency()"}; + | unsigned workers = ${if (targetConfig.workers != 0) targetConfig.workers else "std::thread::hardware_concurrency()"}; | bool fast{${targetConfig.fastMode}}; | bool keepalive{${targetConfig.keepalive}}; | reactor::Duration lf_timeout{${targetConfig.timeout?.toCppCode() ?: "reactor::Duration::zero()"}}; @@ -68,7 +68,7 @@ class CppRos2NodeGenerator( | // FIXME: this is pretty hacky... | lf_node = this; | - | lf_env = std::make_unique(threads, keepalive, fast); + | lf_env = std::make_unique(workers, keepalive, fast); | | // instantiate the main reactor | lf_main_reactor = std::make_unique<${main.name}> ("${main.name}", lf_env.get()); From 32af38df1abc6bba5abc5cd8cc7cdb0efaa8dba7 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 9 Mar 2022 09:31:44 +0100 Subject: [PATCH 24/39] remove workers from all C++ tests --- test/Cpp/src/Composition.lf | 1 - test/Cpp/src/CompositionAfter.lf | 1 - test/Cpp/src/Deadline.lf | 1 - test/Cpp/src/DeadlineHandledAbove.lf | 1 - test/Cpp/src/DelayInt.lf | 1 - test/Cpp/src/Determinism.lf | 1 - test/Cpp/src/DoubleReaction.lf | 1 - test/Cpp/src/Gain.lf | 1 - test/Cpp/src/Hello.lf | 1 - test/Cpp/src/Import.lf | 1 - test/Cpp/src/Minimal.lf | 1 - test/Cpp/src/SendingInside.lf | 1 - test/Cpp/src/TimeLimit.lf | 1 - test/Cpp/src/concurrent/Threaded.lf | 1 - test/Cpp/src/multiport/BankToBankMultiportAfter.lf | 1 - test/Cpp/src/multiport/FullyConnected.lf | 1 - test/Cpp/src/multiport/FullyConnectedAddressable.lf | 1 - test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf | 1 - test/Cpp/src/multiport/MultiportFromBankHierarchy.lf | 1 - test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf | 1 - test/Cpp/src/multiport/MultiportFromHierarchy.lf | 1 - test/Cpp/src/multiport/MultiportOut.lf | 1 - test/Cpp/src/multiport/MultiportToBankHierarchy.lf | 1 - test/Cpp/src/multiport/MultiportToHierarchy.lf | 1 - 24 files changed, 24 deletions(-) diff --git a/test/Cpp/src/Composition.lf b/test/Cpp/src/Composition.lf index b1bd3cdf39..4b72250cb3 100644 --- a/test/Cpp/src/Composition.lf +++ b/test/Cpp/src/Composition.lf @@ -1,7 +1,6 @@ // This test connects a simple counting source to tester // that checks against its own count. target Cpp { - workers: 1, fast: true, timeout: 10 sec }; diff --git a/test/Cpp/src/CompositionAfter.lf b/test/Cpp/src/CompositionAfter.lf index d92ec2b738..f4998565cc 100644 --- a/test/Cpp/src/CompositionAfter.lf +++ b/test/Cpp/src/CompositionAfter.lf @@ -1,7 +1,6 @@ // This test connects a simple counting source to tester // that checks against its own count. target Cpp { - workers: 1, fast: true, timeout: 10 sec }; diff --git a/test/Cpp/src/Deadline.lf b/test/Cpp/src/Deadline.lf index c38c3b05bc..88479822b9 100644 --- a/test/Cpp/src/Deadline.lf +++ b/test/Cpp/src/Deadline.lf @@ -2,7 +2,6 @@ // Even numbers are sent by the Source immediately, whereas odd numbers // are sent after a big enough delay to violate the deadline. target Cpp { - workers: 1, timeout: 4 sec }; reactor Source(period:time(2 sec)) { diff --git a/test/Cpp/src/DeadlineHandledAbove.lf b/test/Cpp/src/DeadlineHandledAbove.lf index d83c9dfcd1..9b5000c5b1 100644 --- a/test/Cpp/src/DeadlineHandledAbove.lf +++ b/test/Cpp/src/DeadlineHandledAbove.lf @@ -1,7 +1,6 @@ // Test a deadline where the deadline violation produces // an output and the container reacts to that output. target Cpp{ - workers: 1 }; reactor Deadline(threshold:time(100 msec)) { input x:int; diff --git a/test/Cpp/src/DelayInt.lf b/test/Cpp/src/DelayInt.lf index de5b317fe2..ae0c3eac57 100644 --- a/test/Cpp/src/DelayInt.lf +++ b/test/Cpp/src/DelayInt.lf @@ -1,6 +1,5 @@ // This tests actions with payloads by delaying an input by a fixed amount. target Cpp{ - workers: 1 }; reactor Delay(delay:time(100 msec)) { input in:int; diff --git a/test/Cpp/src/Determinism.lf b/test/Cpp/src/Determinism.lf index 9d46bba88a..a37c102e92 100644 --- a/test/Cpp/src/Determinism.lf +++ b/test/Cpp/src/Determinism.lf @@ -1,5 +1,4 @@ target Cpp{ - workers: 1 }; reactor Source { output y:int; diff --git a/test/Cpp/src/DoubleReaction.lf b/test/Cpp/src/DoubleReaction.lf index 59ec1bdb03..887fc35de6 100644 --- a/test/Cpp/src/DoubleReaction.lf +++ b/test/Cpp/src/DoubleReaction.lf @@ -2,7 +2,6 @@ // trigger it only once. // Correct output for this 2, 4, 6, 8, etc. target Cpp { - workers: 1, timeout: 10 sec, fast: true }; diff --git a/test/Cpp/src/Gain.lf b/test/Cpp/src/Gain.lf index ac52bc55a9..69492856f0 100644 --- a/test/Cpp/src/Gain.lf +++ b/test/Cpp/src/Gain.lf @@ -1,6 +1,5 @@ // Example in the Wiki. target Cpp{ - workers: 1 }; reactor Scale(scale:int(2)) { input x:int; diff --git a/test/Cpp/src/Hello.lf b/test/Cpp/src/Hello.lf index 52c8812cb9..d9e25bc89b 100644 --- a/test/Cpp/src/Hello.lf +++ b/test/Cpp/src/Hello.lf @@ -5,7 +5,6 @@ // of 2 seconds, and the third (composite) or 1 second. target Cpp { timeout: 10 sec, - workers: 1, fast: true }; reactor HelloCpp(period:time(2 secs), message:{=std::string=}("Hello C++")) { diff --git a/test/Cpp/src/Import.lf b/test/Cpp/src/Import.lf index c875e4bb66..8cbb6ca29f 100644 --- a/test/Cpp/src/Import.lf +++ b/test/Cpp/src/Import.lf @@ -1,7 +1,6 @@ // This tests the ability to import a reactor definition // that itself imports a reactor definition. target Cpp{ - workers: 1 }; import Imported from "lib/Imported.lf"; diff --git a/test/Cpp/src/Minimal.lf b/test/Cpp/src/Minimal.lf index b2e0ec0fe1..777463a887 100644 --- a/test/Cpp/src/Minimal.lf +++ b/test/Cpp/src/Minimal.lf @@ -1,6 +1,5 @@ // This is a smoke test of a minimal reactor. target Cpp { - workers: 1 }; main reactor Minimal { diff --git a/test/Cpp/src/SendingInside.lf b/test/Cpp/src/SendingInside.lf index 055dd6806a..83bddff60b 100644 --- a/test/Cpp/src/SendingInside.lf +++ b/test/Cpp/src/SendingInside.lf @@ -2,7 +2,6 @@ // has its own reaction that routes inputs to the contained reactor. target Cpp { timeout: 10 sec, - workers: 1, fast: true }; reactor Printer { diff --git a/test/Cpp/src/TimeLimit.lf b/test/Cpp/src/TimeLimit.lf index 3f1e6e4fc4..ccf388a1bf 100644 --- a/test/Cpp/src/TimeLimit.lf +++ b/test/Cpp/src/TimeLimit.lf @@ -5,7 +5,6 @@ // Failure for this test is failing to halt or getting the wrong data. target Cpp { fast: true, - workers: 1 }; reactor Clock(offset:time(0), period:time(1 sec)) { output y:int; diff --git a/test/Cpp/src/concurrent/Threaded.lf b/test/Cpp/src/concurrent/Threaded.lf index b0f043f7f6..4d1cb80183 100644 --- a/test/Cpp/src/concurrent/Threaded.lf +++ b/test/Cpp/src/concurrent/Threaded.lf @@ -9,7 +9,6 @@ // than 800 msec to complete 200 msec of logical time. target Cpp { timeout: 2 sec, - workers: 1 }; reactor Source { diff --git a/test/Cpp/src/multiport/BankToBankMultiportAfter.lf b/test/Cpp/src/multiport/BankToBankMultiportAfter.lf index 91d46dfcf6..cb3ff849df 100644 --- a/test/Cpp/src/multiport/BankToBankMultiportAfter.lf +++ b/test/Cpp/src/multiport/BankToBankMultiportAfter.lf @@ -2,7 +2,6 @@ target Cpp { timeout: 2 sec, fast: true, - workers: 4 }; reactor Source(width:size_t(1)) { timer t(0, 200 msec); diff --git a/test/Cpp/src/multiport/FullyConnected.lf b/test/Cpp/src/multiport/FullyConnected.lf index af213a2d61..a235d6a29f 100644 --- a/test/Cpp/src/multiport/FullyConnected.lf +++ b/test/Cpp/src/multiport/FullyConnected.lf @@ -1,5 +1,4 @@ target Cpp { - workers: 1 } reactor Node(bank_index: size_t(0), num_nodes: size_t(4)) { diff --git a/test/Cpp/src/multiport/FullyConnectedAddressable.lf b/test/Cpp/src/multiport/FullyConnectedAddressable.lf index 5849fdd1de..43ed3e2a3b 100644 --- a/test/Cpp/src/multiport/FullyConnectedAddressable.lf +++ b/test/Cpp/src/multiport/FullyConnectedAddressable.lf @@ -1,7 +1,6 @@ // In this pattern, each node can send direct messages to individual other nodes target Cpp { - workers: 1 } reactor Node(bank_index: size_t(0), num_nodes: size_t(4)) { diff --git a/test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf b/test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf index 0bea058135..2691cb40a5 100644 --- a/test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf +++ b/test/Cpp/src/multiport/FullyConnectedAddressableAfter.lf @@ -1,7 +1,6 @@ // In this pattern, each node can send direct messages to individual other nodes target Cpp { - workers: 1 } import Node from "FullyConnectedAddressable.lf" diff --git a/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf b/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf index 36601d14dd..112703dc1c 100644 --- a/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf +++ b/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf @@ -2,7 +2,6 @@ // Here, the bank is smaller than the width of the sending port. target Cpp { timeout: 2 sec, - workers: 1, fast: true }; reactor Source(bank_index:size_t(0)) { diff --git a/test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf b/test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf index 1250a6a5a6..0bf162191d 100644 --- a/test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf +++ b/test/Cpp/src/multiport/MultiportFromBankHierarchyAfter.lf @@ -2,7 +2,6 @@ // Here, the bank is smaller than the width of the sending port. target Cpp { timeout: 2 sec, - workers: 4, fast: true }; reactor Source(bank_index:int(0)) { diff --git a/test/Cpp/src/multiport/MultiportFromHierarchy.lf b/test/Cpp/src/multiport/MultiportFromHierarchy.lf index 0ec126215f..495799e2b3 100644 --- a/test/Cpp/src/multiport/MultiportFromHierarchy.lf +++ b/test/Cpp/src/multiport/MultiportFromHierarchy.lf @@ -1,7 +1,6 @@ // Check multiport output to multiport input, where the former is a hierarchical reactor. target Cpp { timeout: 2 sec, - workers: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportOut.lf b/test/Cpp/src/multiport/MultiportOut.lf index 0994a2ec43..9db502973d 100644 --- a/test/Cpp/src/multiport/MultiportOut.lf +++ b/test/Cpp/src/multiport/MultiportOut.lf @@ -1,7 +1,6 @@ // Check multiport capabilities on Outputs. target Cpp { timeout: 2 sec, - workers: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportToBankHierarchy.lf b/test/Cpp/src/multiport/MultiportToBankHierarchy.lf index bf115e2aca..30d1a36fee 100644 --- a/test/Cpp/src/multiport/MultiportToBankHierarchy.lf +++ b/test/Cpp/src/multiport/MultiportToBankHierarchy.lf @@ -2,7 +2,6 @@ // Here, the bank is smaller than the width of the sending port. target Cpp { timeout: 2 sec, - workers: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportToHierarchy.lf b/test/Cpp/src/multiport/MultiportToHierarchy.lf index dc0cca46b7..17dca6304f 100644 --- a/test/Cpp/src/multiport/MultiportToHierarchy.lf +++ b/test/Cpp/src/multiport/MultiportToHierarchy.lf @@ -2,7 +2,6 @@ // Note that the destination reactor has width wider than the sender, so one input is dangling. target Cpp { timeout: 2 sec, - workers: 1, fast: true }; reactor Source(width:size_t(4)) { From d9057014b055f9a03e4ec682450af0f14c69ccb9 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 9 Mar 2022 09:38:29 +0100 Subject: [PATCH 25/39] remove 'workers' from all the tests and some examples --- example/C/src/MQTT/MQTTDistributed.lf | 1 - example/C/src/MQTT/MQTTPhysical.lf | 4 +--- example/C/src/MQTT/MQTTPublisher.lf | 6 ++---- example/C/src/MQTT/MQTTSubscriber.lf | 6 ++---- example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf | 1 - example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf | 1 - example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf | 1 - test/C/src/concurrent/AsyncCallback.lf | 1 - test/C/src/concurrent/AsyncCallbackDrop.lf | 1 - test/C/src/concurrent/AsyncCallbackReplace.lf | 1 - test/C/src/concurrent/CompositionThreaded.lf | 1 - test/C/src/concurrent/DeadlineHandledAboveThreaded.lf | 4 ++-- test/C/src/concurrent/DeadlineThreaded.lf | 1 - test/C/src/concurrent/DelayIntThreaded.lf | 1 - test/C/src/concurrent/DeterminismThreaded.lf | 1 - test/C/src/concurrent/DoubleReactionThreaded.lf | 1 - test/C/src/concurrent/GainThreaded.lf | 4 ++-- test/C/src/concurrent/HelloThreaded.lf | 1 - test/C/src/concurrent/ImportThreaded.lf | 1 - test/C/src/concurrent/MinimalThreaded.lf | 1 - test/C/src/concurrent/PingPongThreaded.lf | 1 - test/C/src/concurrent/ScheduleAt.lf | 1 - test/C/src/concurrent/ScheduleTwice.lf | 4 ++-- test/C/src/concurrent/ScheduleTwiceThreaded.lf | 4 ++-- test/C/src/concurrent/SendingInsideThreaded.lf | 1 - test/C/src/concurrent/StarvationThreaded.lf | 1 - test/C/src/concurrent/StopThreaded.lf | 1 - test/C/src/concurrent/StopZeroThreaded.lf | 1 - test/C/src/concurrent/ThreadedMultiport.lf | 1 - test/C/src/concurrent/ThreadedThreaded.lf | 1 - test/C/src/concurrent/TimeLimitThreaded.lf | 1 - test/C/src/concurrent/TimeoutThreaded.lf | 1 - test/C/src/concurrent/TimeoutZeroThreaded.lf | 1 - test/C/src/concurrent/Tracing.lf | 1 - test/C/src/federated/LoopDistributedCentralized.lf | 1 - .../C/src/federated/LoopDistributedCentralizedPrecedence.lf | 1 - .../LoopDistributedCentralizedPrecedenceHierarchy.lf | 1 - test/C/src/federated/LoopDistributedDecentralized.lf | 1 - test/C/src/federated/LoopDistributedDouble.lf | 1 - .../failing/LoopDistributedDecentralizedPrecedence.lf | 1 - .../LoopDistributedDecentralizedPrecedenceHierarchy.lf | 1 - test/C/src/multiport/BankToBank.lf | 1 - test/C/src/multiport/BankToBankMultiport.lf | 1 - test/C/src/multiport/BankToBankMultiportAfter.lf | 1 - test/C/src/multiport/MultiportFromBank.lf | 1 - test/C/src/multiport/MultiportFromBankHierarchy.lf | 1 - test/C/src/multiport/MultiportFromBankHierarchyAfter.lf | 1 - test/C/src/multiport/MultiportFromHierarchy.lf | 1 - test/C/src/multiport/MultiportFromReaction.lf | 1 - test/C/src/multiport/MultiportOut.lf | 1 - test/C/src/multiport/MultiportToBankHierarchy.lf | 1 - test/C/src/multiport/MultiportToHierarchy.lf | 1 - test/C/src/multiport/MultiportToMultiport.lf | 1 - test/C/src/multiport/MultiportToMultiportParameter.lf | 1 - test/C/src/multiport/MultiportToReaction.lf | 1 - test/C/src/target/HelloWorldThreadedCPP.lf | 1 - .../src/federated/failing/LoopDistributedCentralized.lf | 1 - .../failing/LoopDistributedCentralizedPrecedence.lf | 1 - .../LoopDistributedCentralizedPrecedenceHierarchy.lf | 1 - .../src/federated/failing/LoopDistributedDecentralized.lf | 1 - test/Python/src/federated/failing/LoopDistributedDouble.lf | 1 - 61 files changed, 13 insertions(+), 73 deletions(-) diff --git a/example/C/src/MQTT/MQTTDistributed.lf b/example/C/src/MQTT/MQTTDistributed.lf index 5093af80a4..b3eff1df68 100644 --- a/example/C/src/MQTT/MQTTDistributed.lf +++ b/example/C/src/MQTT/MQTTDistributed.lf @@ -62,7 +62,6 @@ * @author Edward A. Lee */ target C { - workers: 1, // Must use threaded implementation so schedule is thread safe. cmake-include: [ "include/paho-extension.cmake", "include/mosquitto-extension.cmake"], diff --git a/example/C/src/MQTT/MQTTPhysical.lf b/example/C/src/MQTT/MQTTPhysical.lf index d25e402346..3112f39236 100644 --- a/example/C/src/MQTT/MQTTPhysical.lf +++ b/example/C/src/MQTT/MQTTPhysical.lf @@ -60,8 +60,6 @@ * @author Edward A. Lee */ target C { - // Must use threaded implementation so schedule is thread safe. - workers: 1, cmake-include: [ "include/paho-extension.cmake", "include/mosquitto-extension.cmake", @@ -135,4 +133,4 @@ main reactor MQTTPhysical { ); dsp = new PrintMessage(); sub.message->dsp.message; -} \ No newline at end of file +} diff --git a/example/C/src/MQTT/MQTTPublisher.lf b/example/C/src/MQTT/MQTTPublisher.lf index 9f37e1a89b..b0eb7aef82 100644 --- a/example/C/src/MQTT/MQTTPublisher.lf +++ b/example/C/src/MQTT/MQTTPublisher.lf @@ -5,9 +5,7 @@ * @author Ravi Akella * @author Edward A. Lee */ -target C { - workers: 1 // This makes sure the threaded runtime is used, giving access to the mutex. -}; +target C; /** * Reactor that publishes strings to a specified MQTT topic. @@ -178,4 +176,4 @@ reactor MQTTPublisher ( MQTTClient_disconnect(self->client, 10000); MQTTClient_destroy(&self->client); =} -} \ No newline at end of file +} diff --git a/example/C/src/MQTT/MQTTSubscriber.lf b/example/C/src/MQTT/MQTTSubscriber.lf index da0cac618a..efb9d9dc8e 100644 --- a/example/C/src/MQTT/MQTTSubscriber.lf +++ b/example/C/src/MQTT/MQTTSubscriber.lf @@ -6,9 +6,7 @@ * @author Ravi Akella * @author Edward A. Lee */ -target C { - workers: 1 // This makes sure the threaded runtime is used, giving access to the mutex. -}; +target C; /** * Reactor that subscribes to a specified MQTT topic on which @@ -252,4 +250,4 @@ reactor MQTTSubscriber ( MQTTClient_disconnect(self->client, 10000); MQTTClient_destroy(&self->client); =} -} \ No newline at end of file +} diff --git a/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf b/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf index da581c7871..d273f82cf5 100644 --- a/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf +++ b/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf @@ -8,7 +8,6 @@ */ target Cpp { - workers: 1 } reactor Node(bank_index: size_t(0), num_nodes: size_t(4)) { diff --git a/example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf b/example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf index 02543f814a..70b9537b95 100644 --- a/example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf +++ b/example/Cpp/src/Patterns/FullyConnected_01_Addressable.lf @@ -10,7 +10,6 @@ */ target Cpp { - workers: 1 } reactor Node(bank_index: size_t(0), num_nodes: size_t(4)) { diff --git a/example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf b/example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf index c5fb30d98d..42bee9c95c 100644 --- a/example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf +++ b/example/Cpp/src/Patterns/MatrixConnectedRowsAndColumns.lf @@ -4,7 +4,6 @@ // dimension. Nodes are organized in Rows which are grouped to form the matrix. target Cpp { - workers: 1 }; public preamble {= diff --git a/test/C/src/concurrent/AsyncCallback.lf b/test/C/src/concurrent/AsyncCallback.lf index 36a8ee4844..5ce8b7c013 100644 --- a/test/C/src/concurrent/AsyncCallback.lf +++ b/test/C/src/concurrent/AsyncCallback.lf @@ -9,7 +9,6 @@ */ target C { - workers: 2, tracing: true, timeout: 2 sec }; diff --git a/test/C/src/concurrent/AsyncCallbackDrop.lf b/test/C/src/concurrent/AsyncCallbackDrop.lf index c78c484cb4..00f035f10d 100644 --- a/test/C/src/concurrent/AsyncCallbackDrop.lf +++ b/test/C/src/concurrent/AsyncCallbackDrop.lf @@ -3,7 +3,6 @@ // This test will not work with the unthreaded C target because that target // does not implement any mutex protecting the event queue. target C { - workers: 1, timeout: 2 sec }; diff --git a/test/C/src/concurrent/AsyncCallbackReplace.lf b/test/C/src/concurrent/AsyncCallbackReplace.lf index 00408712e7..74ac079de9 100644 --- a/test/C/src/concurrent/AsyncCallbackReplace.lf +++ b/test/C/src/concurrent/AsyncCallbackReplace.lf @@ -3,7 +3,6 @@ // This test will not work with the unthreaded C target because that target // does not implement any mutex protecting the event queue. target C { - workers: 1, timeout: 2 sec }; diff --git a/test/C/src/concurrent/CompositionThreaded.lf b/test/C/src/concurrent/CompositionThreaded.lf index 385c4fab8e..d11ee17b47 100644 --- a/test/C/src/concurrent/CompositionThreaded.lf +++ b/test/C/src/concurrent/CompositionThreaded.lf @@ -1,7 +1,6 @@ // This test connects a simple counting source to tester // that checks against its own count. target C { - workers: 1, fast: true, timeout: 10 sec }; diff --git a/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf b/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf index 4cf598d9ca..47bf7a261d 100644 --- a/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf +++ b/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf @@ -1,6 +1,6 @@ // Test a deadline where the deadline violation produces // an output and the container reacts to that output. -target C {workers: 1}; +target C; reactor Deadline(threshold:time(100 msec)) { input x:int; output deadline_violation:bool; @@ -37,4 +37,4 @@ main reactor { exit(2); } =} -} \ No newline at end of file +} diff --git a/test/C/src/concurrent/DeadlineThreaded.lf b/test/C/src/concurrent/DeadlineThreaded.lf index fb4d1624d9..b21ce0fdd9 100644 --- a/test/C/src/concurrent/DeadlineThreaded.lf +++ b/test/C/src/concurrent/DeadlineThreaded.lf @@ -3,7 +3,6 @@ // are sent after a big enough delay to violate the deadline. target C { timeout: 3 sec, - workers: 1 }; reactor Source(period:time(1500 msec)) { diff --git a/test/C/src/concurrent/DelayIntThreaded.lf b/test/C/src/concurrent/DelayIntThreaded.lf index 9144547ab4..cfcd1eca8b 100644 --- a/test/C/src/concurrent/DelayIntThreaded.lf +++ b/test/C/src/concurrent/DelayIntThreaded.lf @@ -1,6 +1,5 @@ // This tests actions with payloads by delaying an input by a fixed amount. target C { - workers: 1 }; reactor Delay(delay:time(100 msec)) { input in:int; diff --git a/test/C/src/concurrent/DeterminismThreaded.lf b/test/C/src/concurrent/DeterminismThreaded.lf index 7d5bc666fa..91c0231d2d 100644 --- a/test/C/src/concurrent/DeterminismThreaded.lf +++ b/test/C/src/concurrent/DeterminismThreaded.lf @@ -1,5 +1,4 @@ target C { - workers: 1 }; reactor Source { output y:int; diff --git a/test/C/src/concurrent/DoubleReactionThreaded.lf b/test/C/src/concurrent/DoubleReactionThreaded.lf index 81813b8612..15a7b4650c 100644 --- a/test/C/src/concurrent/DoubleReactionThreaded.lf +++ b/test/C/src/concurrent/DoubleReactionThreaded.lf @@ -4,7 +4,6 @@ target C { timeout: 10 sec, fast: true, - workers: 1 }; reactor Clock(offset:time(0), period:time(1 sec)) { output y:int; diff --git a/test/C/src/concurrent/GainThreaded.lf b/test/C/src/concurrent/GainThreaded.lf index 8ef1f35174..05a913911d 100644 --- a/test/C/src/concurrent/GainThreaded.lf +++ b/test/C/src/concurrent/GainThreaded.lf @@ -1,5 +1,5 @@ // Example in the Wiki. - target C {workers: 1}; + target C; reactor Scale(scale:int(2)) { input x:int; output y:int; @@ -33,4 +33,4 @@ reaction(startup) -> g.x {= SET(g.x, 1); =} - } \ No newline at end of file + } diff --git a/test/C/src/concurrent/HelloThreaded.lf b/test/C/src/concurrent/HelloThreaded.lf index dd708b7aa2..2812ceaeb0 100644 --- a/test/C/src/concurrent/HelloThreaded.lf +++ b/test/C/src/concurrent/HelloThreaded.lf @@ -6,7 +6,6 @@ target C { timeout: 10 sec, fast: true, - workers: 1 }; reactor Reschedule(period:time(2 secs), message:string("Hello C")) { state count:int(0); diff --git a/test/C/src/concurrent/ImportThreaded.lf b/test/C/src/concurrent/ImportThreaded.lf index 5b637085b7..33d25b941f 100644 --- a/test/C/src/concurrent/ImportThreaded.lf +++ b/test/C/src/concurrent/ImportThreaded.lf @@ -1,7 +1,6 @@ // This tests the ability to import a reactor definition // that itself imports a reactor definition. target C { - workers: 2 }; import Imported from "../lib/Imported.lf"; diff --git a/test/C/src/concurrent/MinimalThreaded.lf b/test/C/src/concurrent/MinimalThreaded.lf index 87587234ab..fab2c19992 100644 --- a/test/C/src/concurrent/MinimalThreaded.lf +++ b/test/C/src/concurrent/MinimalThreaded.lf @@ -1,6 +1,5 @@ // This is a smoke test of a minimal reactor. target C { - workers: 1 }; main reactor MinimalThreaded { timer t; diff --git a/test/C/src/concurrent/PingPongThreaded.lf b/test/C/src/concurrent/PingPongThreaded.lf index c15b1ed72d..3905532d80 100644 --- a/test/C/src/concurrent/PingPongThreaded.lf +++ b/test/C/src/concurrent/PingPongThreaded.lf @@ -23,7 +23,6 @@ */ target C { fast: true, - workers: 8 }; reactor Ping(count:int(10)) { input receive:int; diff --git a/test/C/src/concurrent/ScheduleAt.lf b/test/C/src/concurrent/ScheduleAt.lf index 13ac9ef4bd..17d35df8d4 100644 --- a/test/C/src/concurrent/ScheduleAt.lf +++ b/test/C/src/concurrent/ScheduleAt.lf @@ -8,7 +8,6 @@ target C { timeout: 1 sec, keepalive: true, - workers: 1 }; reactor Scheduler { diff --git a/test/C/src/concurrent/ScheduleTwice.lf b/test/C/src/concurrent/ScheduleTwice.lf index 7e0f7269c2..1818eb3320 100644 --- a/test/C/src/concurrent/ScheduleTwice.lf +++ b/test/C/src/concurrent/ScheduleTwice.lf @@ -1,4 +1,4 @@ -target C {workers: 1}; +target C; main reactor ScheduleTwice { logical action a:int; state rc_count:int(0); @@ -27,4 +27,4 @@ main reactor ScheduleTwice { exit(2); } =} -} \ No newline at end of file +} diff --git a/test/C/src/concurrent/ScheduleTwiceThreaded.lf b/test/C/src/concurrent/ScheduleTwiceThreaded.lf index 185c21c238..110f390c9e 100644 --- a/test/C/src/concurrent/ScheduleTwiceThreaded.lf +++ b/test/C/src/concurrent/ScheduleTwiceThreaded.lf @@ -1,4 +1,4 @@ -target C {workers: 1}; +target C; main reactor { logical action a:int; state rc_count:int(0); @@ -24,4 +24,4 @@ main reactor { exit(2); } =} -} \ No newline at end of file +} diff --git a/test/C/src/concurrent/SendingInsideThreaded.lf b/test/C/src/concurrent/SendingInsideThreaded.lf index 42de2ddec3..6edd13682d 100644 --- a/test/C/src/concurrent/SendingInsideThreaded.lf +++ b/test/C/src/concurrent/SendingInsideThreaded.lf @@ -1,7 +1,6 @@ // This tests a reactor that contains another reactor and also // has its own reaction that routes inputs to the contained reactor. target C { - workers: 3, timeout: 10 sec, fast: true }; diff --git a/test/C/src/concurrent/StarvationThreaded.lf b/test/C/src/concurrent/StarvationThreaded.lf index 863f4f8317..f82739a06d 100644 --- a/test/C/src/concurrent/StarvationThreaded.lf +++ b/test/C/src/concurrent/StarvationThreaded.lf @@ -6,7 +6,6 @@ * @author Soroush Bateni */ target C { - workers: 8 }; reactor SuperDenseSender(number_of_iterations:int(10)){ logical action loop; diff --git a/test/C/src/concurrent/StopThreaded.lf b/test/C/src/concurrent/StopThreaded.lf index 3ea0e6d552..23ec44697e 100644 --- a/test/C/src/concurrent/StopThreaded.lf +++ b/test/C/src/concurrent/StopThreaded.lf @@ -6,7 +6,6 @@ */ target C { timeout: 11 msec, - workers: 4, build-type: RelWithDebInfo, // logging: DEBUG }; diff --git a/test/C/src/concurrent/StopZeroThreaded.lf b/test/C/src/concurrent/StopZeroThreaded.lf index 0c2beb924f..cc0bcc8e7f 100644 --- a/test/C/src/concurrent/StopZeroThreaded.lf +++ b/test/C/src/concurrent/StopZeroThreaded.lf @@ -5,7 +5,6 @@ * @author Soroush Bateni */ target C { - workers: 4 }; reactor Sender { diff --git a/test/C/src/concurrent/ThreadedMultiport.lf b/test/C/src/concurrent/ThreadedMultiport.lf index 5f8d2109bd..7b9426235b 100644 --- a/test/C/src/concurrent/ThreadedMultiport.lf +++ b/test/C/src/concurrent/ThreadedMultiport.lf @@ -2,7 +2,6 @@ target C { timeout: 2 sec, flags: "", // Disable compiler optimization so that TakeTime actually takes time. - workers: 4 }; reactor Source(width:int(4)) { timer t(0, 200 msec); diff --git a/test/C/src/concurrent/ThreadedThreaded.lf b/test/C/src/concurrent/ThreadedThreaded.lf index 5be9b6c1e5..da8d52b882 100644 --- a/test/C/src/concurrent/ThreadedThreaded.lf +++ b/test/C/src/concurrent/ThreadedThreaded.lf @@ -10,7 +10,6 @@ target C { timeout: 2 sec, tracing: true, flags: "", // Disable compiler optimization so that TakeTime actually takes time. - workers: 4 }; reactor Source { timer t(0, 200 msec); diff --git a/test/C/src/concurrent/TimeLimitThreaded.lf b/test/C/src/concurrent/TimeLimitThreaded.lf index c1880a03ca..692df9aec5 100644 --- a/test/C/src/concurrent/TimeLimitThreaded.lf +++ b/test/C/src/concurrent/TimeLimitThreaded.lf @@ -6,7 +6,6 @@ target C { flags: "-O2", fast: true, - workers: 8 }; reactor Clock(offset:time(0), period:time(1 sec)) { output y:int; diff --git a/test/C/src/concurrent/TimeoutThreaded.lf b/test/C/src/concurrent/TimeoutThreaded.lf index 3f03cf2bbd..25896d9a6d 100644 --- a/test/C/src/concurrent/TimeoutThreaded.lf +++ b/test/C/src/concurrent/TimeoutThreaded.lf @@ -6,7 +6,6 @@ */ target C { timeout: 11 msec, - workers: 4 }; import Sender from "../lib/LoopedActionSender.lf" diff --git a/test/C/src/concurrent/TimeoutZeroThreaded.lf b/test/C/src/concurrent/TimeoutZeroThreaded.lf index 4422686a57..ccf31618b8 100644 --- a/test/C/src/concurrent/TimeoutZeroThreaded.lf +++ b/test/C/src/concurrent/TimeoutZeroThreaded.lf @@ -7,7 +7,6 @@ */ target C { timeout: 0 sec, - workers: 4 }; import Sender from "../lib/LoopedActionSender.lf" diff --git a/test/C/src/concurrent/Tracing.lf b/test/C/src/concurrent/Tracing.lf index a9d0aa887a..5fe9282db3 100644 --- a/test/C/src/concurrent/Tracing.lf +++ b/test/C/src/concurrent/Tracing.lf @@ -3,7 +3,6 @@ target C { timeout: 2 sec, tracing: true, flags: "", // Disable compiler optimization so that TakeTime actually takes time. - workers: 4, logging: DEBUG }; reactor Source { diff --git a/test/C/src/federated/LoopDistributedCentralized.lf b/test/C/src/federated/LoopDistributedCentralized.lf index 3ba15a62c8..fdc8837b62 100644 --- a/test/C/src/federated/LoopDistributedCentralized.lf +++ b/test/C/src/federated/LoopDistributedCentralized.lf @@ -8,7 +8,6 @@ target C { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - workers: 2, timeout: 5 sec } preamble {= diff --git a/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf b/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf index 7ac196b7af..8f66a3b7df 100644 --- a/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf +++ b/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf @@ -9,7 +9,6 @@ target C { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - workers: 2, timeout: 5 sec } diff --git a/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf b/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf index 36a8e70112..c455ce0c6a 100644 --- a/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf +++ b/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf @@ -9,7 +9,6 @@ target C { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - workers: 2, timeout: 5 sec } diff --git a/test/C/src/federated/LoopDistributedDecentralized.lf b/test/C/src/federated/LoopDistributedDecentralized.lf index 611f87b3dd..c714907c4e 100644 --- a/test/C/src/federated/LoopDistributedDecentralized.lf +++ b/test/C/src/federated/LoopDistributedDecentralized.lf @@ -6,7 +6,6 @@ */ target C { coordination: decentralized, - workers: 3, timeout: 5 sec } preamble {= diff --git a/test/C/src/federated/LoopDistributedDouble.lf b/test/C/src/federated/LoopDistributedDouble.lf index 103c30c68b..6043baa116 100644 --- a/test/C/src/federated/LoopDistributedDouble.lf +++ b/test/C/src/federated/LoopDistributedDouble.lf @@ -8,7 +8,6 @@ target C { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - workers: 2, timeout: 5 sec } preamble {= diff --git a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedence.lf b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedence.lf index 45167ac702..830bb64c6e 100644 --- a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedence.lf +++ b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedence.lf @@ -8,7 +8,6 @@ target C { flags: "-Wall", coordination: decentralized, - workers: 2, timeout: 4900 msec } diff --git a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf index 66dddd79ae..0b949e08f6 100644 --- a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf +++ b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf @@ -8,7 +8,6 @@ target C { flags: "-Wall", coordination: decentralized, - workers: 2, timeout: 4900 msec } diff --git a/test/C/src/multiport/BankToBank.lf b/test/C/src/multiport/BankToBank.lf index fa9f89987a..992a0e3c06 100644 --- a/test/C/src/multiport/BankToBank.lf +++ b/test/C/src/multiport/BankToBank.lf @@ -2,7 +2,6 @@ target C { timeout: 2 sec, fast: true, - workers: 4 }; reactor Source( bank_index:int(0) diff --git a/test/C/src/multiport/BankToBankMultiport.lf b/test/C/src/multiport/BankToBankMultiport.lf index 01be54b5ad..cb01994a1d 100644 --- a/test/C/src/multiport/BankToBankMultiport.lf +++ b/test/C/src/multiport/BankToBankMultiport.lf @@ -2,7 +2,6 @@ target C { timeout: 2 sec, fast: true, - workers: 4 }; reactor Source(width:int(1)) { timer t(0, 200 msec); diff --git a/test/C/src/multiport/BankToBankMultiportAfter.lf b/test/C/src/multiport/BankToBankMultiportAfter.lf index 5f494fc882..51a2eeab35 100644 --- a/test/C/src/multiport/BankToBankMultiportAfter.lf +++ b/test/C/src/multiport/BankToBankMultiportAfter.lf @@ -2,7 +2,6 @@ target C { timeout: 2 sec, fast: true, - workers: 4 }; reactor Source(width:int(1)) { timer t(0, 200 msec); diff --git a/test/C/src/multiport/MultiportFromBank.lf b/test/C/src/multiport/MultiportFromBank.lf index 176521c31e..abbf183281 100644 --- a/test/C/src/multiport/MultiportFromBank.lf +++ b/test/C/src/multiport/MultiportFromBank.lf @@ -2,7 +2,6 @@ // Here, the bank is smaller than the width of the sending port. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Source( diff --git a/test/C/src/multiport/MultiportFromBankHierarchy.lf b/test/C/src/multiport/MultiportFromBankHierarchy.lf index 2c48280050..2945281498 100644 --- a/test/C/src/multiport/MultiportFromBankHierarchy.lf +++ b/test/C/src/multiport/MultiportFromBankHierarchy.lf @@ -2,7 +2,6 @@ // Here, the bank is smaller than the width of the sending port. target C { timeout: 2 sec, - workers: 4, fast: true }; import Source, Destination from "MultiportFromBank.lf" diff --git a/test/C/src/multiport/MultiportFromBankHierarchyAfter.lf b/test/C/src/multiport/MultiportFromBankHierarchyAfter.lf index d983d43b1e..8521b7d158 100644 --- a/test/C/src/multiport/MultiportFromBankHierarchyAfter.lf +++ b/test/C/src/multiport/MultiportFromBankHierarchyAfter.lf @@ -2,7 +2,6 @@ // Here, the bank is smaller than the width of the sending port. target C { timeout: 2 sec, - workers: 4, fast: true }; import Destination from "MultiportFromBank.lf" diff --git a/test/C/src/multiport/MultiportFromHierarchy.lf b/test/C/src/multiport/MultiportFromHierarchy.lf index 648fb240ed..88ed9eb083 100644 --- a/test/C/src/multiport/MultiportFromHierarchy.lf +++ b/test/C/src/multiport/MultiportFromHierarchy.lf @@ -1,7 +1,6 @@ // Check multiport output to multiport input, where the former is a hierarchical reactor. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Source(width:int(3)) { diff --git a/test/C/src/multiport/MultiportFromReaction.lf b/test/C/src/multiport/MultiportFromReaction.lf index 418f5656f8..0469f9a796 100644 --- a/test/C/src/multiport/MultiportFromReaction.lf +++ b/test/C/src/multiport/MultiportFromReaction.lf @@ -1,7 +1,6 @@ // Check reaction to multiport input of a contained reactor. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Destination(width:int(1)) { diff --git a/test/C/src/multiport/MultiportOut.lf b/test/C/src/multiport/MultiportOut.lf index 7f85f23918..2d1508a933 100644 --- a/test/C/src/multiport/MultiportOut.lf +++ b/test/C/src/multiport/MultiportOut.lf @@ -1,7 +1,6 @@ // Check multiport capabilities on Outputs. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Source { diff --git a/test/C/src/multiport/MultiportToBankHierarchy.lf b/test/C/src/multiport/MultiportToBankHierarchy.lf index 6468e2dddc..c063fc8dfe 100644 --- a/test/C/src/multiport/MultiportToBankHierarchy.lf +++ b/test/C/src/multiport/MultiportToBankHierarchy.lf @@ -2,7 +2,6 @@ // Here, the bank is smaller than the width of the sending port. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Source(width:int(2)) { diff --git a/test/C/src/multiport/MultiportToHierarchy.lf b/test/C/src/multiport/MultiportToHierarchy.lf index b2c3777e52..cc0f02b9a6 100644 --- a/test/C/src/multiport/MultiportToHierarchy.lf +++ b/test/C/src/multiport/MultiportToHierarchy.lf @@ -2,7 +2,6 @@ // Note that the destination reactor has width wider than the sender, so one input is dangling. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Source(width:int(2)) { diff --git a/test/C/src/multiport/MultiportToMultiport.lf b/test/C/src/multiport/MultiportToMultiport.lf index 4c5346057b..c9e93659db 100644 --- a/test/C/src/multiport/MultiportToMultiport.lf +++ b/test/C/src/multiport/MultiportToMultiport.lf @@ -1,7 +1,6 @@ // Check multiport output to multiport input. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Source(width:int(1)) { diff --git a/test/C/src/multiport/MultiportToMultiportParameter.lf b/test/C/src/multiport/MultiportToMultiportParameter.lf index 1f0e60c99c..9a374dde6a 100644 --- a/test/C/src/multiport/MultiportToMultiportParameter.lf +++ b/test/C/src/multiport/MultiportToMultiportParameter.lf @@ -1,7 +1,6 @@ // Check multiport output to multiport input. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Source(width:int(1)) { diff --git a/test/C/src/multiport/MultiportToReaction.lf b/test/C/src/multiport/MultiportToReaction.lf index d50eb2fb8d..14de79d952 100644 --- a/test/C/src/multiport/MultiportToReaction.lf +++ b/test/C/src/multiport/MultiportToReaction.lf @@ -1,7 +1,6 @@ // Check reaction to multiport output of a contained reactor. target C { timeout: 2 sec, - workers: 4, fast: true }; reactor Source(width:int(1)) { diff --git a/test/C/src/target/HelloWorldThreadedCPP.lf b/test/C/src/target/HelloWorldThreadedCPP.lf index 3ba7a87d50..4545f32b3c 100644 --- a/test/C/src/target/HelloWorldThreadedCPP.lf +++ b/test/C/src/target/HelloWorldThreadedCPP.lf @@ -5,7 +5,6 @@ */ target CCpp { tracing: true, - workers: 1, logging: DEBUG }; import HelloWorld from "HelloWorldCCPP.lf"; diff --git a/test/Python/src/federated/failing/LoopDistributedCentralized.lf b/test/Python/src/federated/failing/LoopDistributedCentralized.lf index f496975929..90a20026b6 100644 --- a/test/Python/src/federated/failing/LoopDistributedCentralized.lf +++ b/test/Python/src/federated/failing/LoopDistributedCentralized.lf @@ -11,7 +11,6 @@ target Python { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - workers: 2, timeout: 5 sec } preamble {= diff --git a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedence.lf b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedence.lf index f087e75360..c393842872 100644 --- a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedence.lf +++ b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedence.lf @@ -12,7 +12,6 @@ target Python { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - workers: 2, timeout: 5 sec } diff --git a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf index d48606d896..3400251079 100644 --- a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf +++ b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf @@ -13,7 +13,6 @@ target Python { flags: "-Wall", coordination: centralized, coordination-options: {advance-message-interval: 100 msec}, - workers: 2, timeout: 5 sec } diff --git a/test/Python/src/federated/failing/LoopDistributedDecentralized.lf b/test/Python/src/federated/failing/LoopDistributedDecentralized.lf index 4f4a5d1d2a..1db7a96dab 100644 --- a/test/Python/src/federated/failing/LoopDistributedDecentralized.lf +++ b/test/Python/src/federated/failing/LoopDistributedDecentralized.lf @@ -9,7 +9,6 @@ target Python { coordination: decentralized, - workers: 3, timeout: 5 sec } preamble {= diff --git a/test/Python/src/federated/failing/LoopDistributedDouble.lf b/test/Python/src/federated/failing/LoopDistributedDouble.lf index d76806789f..f2ec7bac0b 100644 --- a/test/Python/src/federated/failing/LoopDistributedDouble.lf +++ b/test/Python/src/federated/failing/LoopDistributedDouble.lf @@ -9,7 +9,6 @@ target Python { coordination: centralized, - workers: 2, timeout: 5 sec } preamble {= From af647978fc1ce8a068b18f0012c23f227ec5915b Mon Sep 17 00:00:00 2001 From: Soroush Bateni Date: Wed, 9 Mar 2022 13:06:01 -0600 Subject: [PATCH 26/39] First step toward setting the number of cores in the C runtime --- org.lflang/src/lib/c/reactor-c | 2 +- .../src/org/lflang/generator/c/CCmakeGenerator.java | 12 ++++++------ .../src/org/lflang/generator/c/CGenerator.xtend | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/org.lflang/src/lib/c/reactor-c b/org.lflang/src/lib/c/reactor-c index 3d7c4f10f4..73b18ac504 160000 --- a/org.lflang/src/lib/c/reactor-c +++ b/org.lflang/src/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 3d7c4f10f4a93379b5a550639ab3ea836a38835f +Subproject commit 73b18ac504b9ea984a0201f51d4ac3098f74f87b diff --git a/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java b/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java index 2e29eb48fc..cbed532efe 100644 --- a/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java +++ b/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java @@ -101,12 +101,6 @@ CodeBuilder generateCMakeCode( cMakeCode.pr("set(CMAKE_CXX_STANDARD_REQUIRED ON)"); cMakeCode.newLine(); - cMakeCode.pr("# Compile definitions\n"); - targetConfig.compileDefinitions.forEach( (key, value) -> { - cMakeCode.pr("add_compile_definitions("+key+"="+value+")\n"); - }); - cMakeCode.newLine(); - // Set the build type cMakeCode.pr("set(DEFAULT_BUILD_TYPE " + targetConfig.cmakeBuildType + ")\n"); cMakeCode.pr("if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)\n"); @@ -164,6 +158,12 @@ CodeBuilder generateCMakeCode( cMakeCode.newLine(); } + cMakeCode.pr("# Target definitions\n"); + targetConfig.compileDefinitions.forEach( (key, value) -> { + cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC "+key+"="+value+")\n"); + }); + cMakeCode.newLine(); + // Check if CppMode is enabled if (CppMode) { // First enable the CXX language diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index 103764108f..5864e362cb 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -1332,6 +1332,7 @@ class CGenerator extends GeneratorBase { "platform/lf_POSIX_threads_support.h", "platform/lf_POSIX_threads_support.c", "platform/lf_unix_clock_support.c", + "platform/lf_unix_syscall_support.c", "platform/lf_macos_support.c", "platform/lf_macos_support.h", "platform/lf_windows_support.c", From 9b1deb3949e3aa240940d9eb49f9b1a969727482 Mon Sep 17 00:00:00 2001 From: Soroush Bateni Date: Wed, 9 Mar 2022 13:32:47 -0600 Subject: [PATCH 27/39] Slight adjustment to logic --- org.lflang/src/lib/c/reactor-c | 2 +- .../src/org/lflang/generator/c/CGenerator.xtend | 11 ++++++----- .../org/lflang/generator/python/PythonGenerator.java | 7 ++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/org.lflang/src/lib/c/reactor-c b/org.lflang/src/lib/c/reactor-c index 73b18ac504..b89f090dc9 160000 --- a/org.lflang/src/lib/c/reactor-c +++ b/org.lflang/src/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 73b18ac504b9ea984a0201f51d4ac3098f74f87b +Subproject commit b89f090dc91570ec6a1441897c6615170e913cb6 diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index 5864e362cb..7ee9cd0964 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -1038,13 +1038,14 @@ class CGenerator extends GeneratorBase { ''') code.indent() - if (targetConfig.threading && targetConfig.workers > 0) { + if (targetConfig.threading + && targetConfig.setByUser.contains(TargetProperty.WORKERS) + && targetConfig.workers > 0 + ) { // Set this as the default in the generated code, // but only if it has not been overridden on the command line. code.pr(''' - if (_lf_number_of_threads == 0u) { - _lf_number_of_threads = «targetConfig.workers»u; - } + _lf_number_of_threads = «targetConfig.workers»u; ''') } @@ -1641,7 +1642,7 @@ class CGenerator extends GeneratorBase { .num_reactions_per_level = &num_reactions_per_level[0], .num_reactions_per_level_size = (size_t) «numReactionsPerLevel.size»}; lf_sched_init( - «targetConfig.workers», + (size_t)_lf_number_of_threads, &sched_params ); ''') diff --git a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java index 1b9d7fbe25..5428ba8834 100644 --- a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java +++ b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java @@ -48,8 +48,8 @@ import org.lflang.ErrorReporter; import org.lflang.FileConfig; import org.lflang.InferredType; -import org.lflang.ASTUtils; import org.lflang.Target; +import org.lflang.TargetProperty; import org.lflang.federated.FedFileConfig; import org.lflang.federated.FederateInstance; import org.lflang.federated.launcher.FedPyLauncher; @@ -652,6 +652,11 @@ public boolean isOSCompatible() { */ @Override public void doGenerate(Resource resource, LFGeneratorContext context) { + // Set the threading to false by default, unless the user has + // specifically asked for it. + if (!targetConfig.setByUser.contains(TargetProperty.THREADING)) { + targetConfig.threading = false; + } // Prevent the CGenerator from compiling the C code. // The PythonGenerator will compiler it. boolean compileStatus = targetConfig.noCompile; From d78f8b1bab3f12f9fa3e5f81fba09ca2e68caa8d Mon Sep 17 00:00:00 2001 From: Soroush Bateni Date: Wed, 9 Mar 2022 13:42:55 -0600 Subject: [PATCH 28/39] Number of threads will now be decided based on NUMBER_OF_WORKERS --- org.lflang/src/lib/c/reactor-c | 2 +- .../src/org/lflang/generator/c/CGenerator.xtend | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/org.lflang/src/lib/c/reactor-c b/org.lflang/src/lib/c/reactor-c index b89f090dc9..6cf5dcaf2b 160000 --- a/org.lflang/src/lib/c/reactor-c +++ b/org.lflang/src/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit b89f090dc91570ec6a1441897c6615170e913cb6 +Subproject commit 6cf5dcaf2b097a0f213c6fcdc742e7d82d9eaf8c diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index 7ee9cd0964..8a6d188a13 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -1037,18 +1037,7 @@ class CGenerator extends GeneratorBase { void _lf_initialize_trigger_objects() { ''') code.indent() - - if (targetConfig.threading - && targetConfig.setByUser.contains(TargetProperty.WORKERS) - && targetConfig.workers > 0 - ) { - // Set this as the default in the generated code, - // but only if it has not been overridden on the command line. - code.pr(''' - _lf_number_of_threads = «targetConfig.workers»u; - ''') - } - + // Initialize the LF clock. code.pr(''' // Initialize the _lf_clock From c02ac8e15182bfc41c2d7757096269dcd2aa8def Mon Sep 17 00:00:00 2001 From: Soroush Bateni Date: Wed, 9 Mar 2022 13:55:22 -0600 Subject: [PATCH 29/39] Account for workers = 0 --- org.lflang/src/lib/c/reactor-c | 2 +- org.lflang/src/org/lflang/generator/c/CGenerator.xtend | 2 +- org.lflang/src/org/lflang/generator/python/PythonGenerator.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/org.lflang/src/lib/c/reactor-c b/org.lflang/src/lib/c/reactor-c index 6cf5dcaf2b..2f745ab105 160000 --- a/org.lflang/src/lib/c/reactor-c +++ b/org.lflang/src/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 6cf5dcaf2b097a0f213c6fcdc742e7d82d9eaf8c +Subproject commit 2f745ab105d17eb20f7af785229a2c06a87b044e diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index 8a6d188a13..0c4a9ce444 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -4140,7 +4140,7 @@ class CGenerator extends GeneratorBase { // If the program is federated, then ensure that threading is enabled. targetConfig.threading = true // Ensure that there are enough worker threads to handle network input control reactions. - targetConfig.workers += CUtil.minThreadsToHandleInputPorts(federates) + targetConfig.workers += CUtil.minThreadsToHandleInputPorts(federates) + 1 // Account for workers = 0 } if (hasModalReactors) { diff --git a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java index 5428ba8834..f320bacbdb 100644 --- a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java +++ b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java @@ -371,7 +371,7 @@ public boolean generatePreamble() { // If the program is federated, then ensure that threading is enabled. targetConfig.threading = true; // Ensure that there are enough worker threads to handle network input control reactions. - targetConfig.workers += CUtil.minThreadsToHandleInputPorts(federates); + targetConfig.workers += CUtil.minThreadsToHandleInputPorts(federates) + 1; // Account for workers = 0 } includeTargetLanguageHeaders(); code.pr(CPreambleGenerator.generateNumFederatesDirective(federates.size())); From 276cb2592c20cc6da2f5722dc013581b085e5d4c Mon Sep 17 00:00:00 2001 From: Soroush Bateni Date: Wed, 9 Mar 2022 14:32:27 -0600 Subject: [PATCH 30/39] Renamed _lf_number_of_threads and added WORKERS_NEEDED_FOR_FEDERATE --- org.lflang/src/lib/c/reactor-c | 2 +- org.lflang/src/org/lflang/generator/c/CGenerator.xtend | 10 +++++++--- .../org/lflang/generator/python/PythonGenerator.java | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/org.lflang/src/lib/c/reactor-c b/org.lflang/src/lib/c/reactor-c index 2f745ab105..0d299cb41e 160000 --- a/org.lflang/src/lib/c/reactor-c +++ b/org.lflang/src/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 2f745ab105d17eb20f7af785229a2c06a87b044e +Subproject commit 0d299cb41e174a2090a9430cd69670c4694179a0 diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index 0c4a9ce444..38dda27d6a 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -1631,7 +1631,7 @@ class CGenerator extends GeneratorBase { .num_reactions_per_level = &num_reactions_per_level[0], .num_reactions_per_level_size = (size_t) «numReactionsPerLevel.size»}; lf_sched_init( - (size_t)_lf_number_of_threads, + (size_t)_lf_number_of_workers, &sched_params ); ''') @@ -4139,8 +4139,12 @@ class CGenerator extends GeneratorBase { code.pr(CPreambleGenerator.generateFederatedDirective(targetConfig.coordination)) // If the program is federated, then ensure that threading is enabled. targetConfig.threading = true - // Ensure that there are enough worker threads to handle network input control reactions. - targetConfig.workers += CUtil.minThreadsToHandleInputPorts(federates) + 1 // Account for workers = 0 + // Convey to the C runtime the required number of worker threads to + // handle network input control reactions. + targetConfig.compileDefinitions.put( + "WORKERS_NEEDED_FOR_FEDERATE", + CUtil.minThreadsToHandleInputPorts(federates).toString + ); } if (hasModalReactors) { diff --git a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java index f320bacbdb..3f08a3b488 100644 --- a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java +++ b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java @@ -370,8 +370,12 @@ public boolean generatePreamble() { code.pr(CPreambleGenerator.generateFederatedDirective(targetConfig.coordination)); // If the program is federated, then ensure that threading is enabled. targetConfig.threading = true; - // Ensure that there are enough worker threads to handle network input control reactions. - targetConfig.workers += CUtil.minThreadsToHandleInputPorts(federates) + 1; // Account for workers = 0 + // Convey to the C runtime the required number of worker threads to + // handle network input control reactions. + targetConfig.compileDefinitions.put( + "WORKERS_NEEDED_FOR_FEDERATE", + String.valueOf(PyUtil.minThreadsToHandleInputPorts(federates)) + ); } includeTargetLanguageHeaders(); code.pr(CPreambleGenerator.generateNumFederatesDirective(federates.size())); From 57d3cba784ba21239fefedb4bdf19782fdbc4dbe Mon Sep 17 00:00:00 2001 From: Soroush Bateni Date: Wed, 9 Mar 2022 14:39:25 -0600 Subject: [PATCH 31/39] Updated pointer to reactor-c --- org.lflang/src/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang/src/lib/c/reactor-c b/org.lflang/src/lib/c/reactor-c index 0d299cb41e..c10537c345 160000 --- a/org.lflang/src/lib/c/reactor-c +++ b/org.lflang/src/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 0d299cb41e174a2090a9430cd69670c4694179a0 +Subproject commit c10537c345a8295f1f426623147b583d2e1a4f68 From 0482f284fdbccad98addf3259012e74ddaec4a3d Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 9 Mar 2022 14:24:59 -0800 Subject: [PATCH 32/39] Apply suggestions from code review --- example/C/src/Deadline.lf | 1 - example/C/src/ROS/ROSBuiltInSerialization.lf | 1 - example/C/src/ReflexGame.lf | 1 - example/C/src/ReflexGame/ReflexGameTest.lf | 1 - example/C/src/Rhythm/Rhythm.lf | 1 - example/C/src/Rhythm/SensorSimulator.lf | 1 - example/C/src/TrainDoor/TrainDoor.lf | 2 +- 7 files changed, 1 insertion(+), 7 deletions(-) diff --git a/example/C/src/Deadline.lf b/example/C/src/Deadline.lf index 4fbbeb5869..0256020612 100644 --- a/example/C/src/Deadline.lf +++ b/example/C/src/Deadline.lf @@ -10,7 +10,6 @@ * @author Edward A. Lee */ target C { - workers: 1, keepalive: true }; preamble {= diff --git a/example/C/src/ROS/ROSBuiltInSerialization.lf b/example/C/src/ROS/ROSBuiltInSerialization.lf index b07284e75a..b9e588a1ce 100644 --- a/example/C/src/ROS/ROSBuiltInSerialization.lf +++ b/example/C/src/ROS/ROSBuiltInSerialization.lf @@ -24,7 +24,6 @@ target CCpp { cmake: true, // Only CMake is supported cmake-include: "include/CMakeListsExtension.txt", - workers: 1, }; preamble {= diff --git a/example/C/src/ReflexGame.lf b/example/C/src/ReflexGame.lf index 9c225439c8..16a65b0527 100644 --- a/example/C/src/ReflexGame.lf +++ b/example/C/src/ReflexGame.lf @@ -12,7 +12,6 @@ * @author Marten Lohstroh */ target C { - workers: 1, keepalive: true }; /** diff --git a/example/C/src/ReflexGame/ReflexGameTest.lf b/example/C/src/ReflexGame/ReflexGameTest.lf index f41a5686ab..b959c39c56 100644 --- a/example/C/src/ReflexGame/ReflexGameTest.lf +++ b/example/C/src/ReflexGame/ReflexGameTest.lf @@ -1,5 +1,4 @@ target C { - workers: 1, keepalive: true, timeout: 5 sec }; diff --git a/example/C/src/Rhythm/Rhythm.lf b/example/C/src/Rhythm/Rhythm.lf index e659dd7a08..49b93f2fdd 100644 --- a/example/C/src/Rhythm/Rhythm.lf +++ b/example/C/src/Rhythm/Rhythm.lf @@ -29,7 +29,6 @@ * @see RhythmDistributedNoUI.lf */ target C { - workers: 2, tracing: true, files: [ "/lib/c/reactor-c/util/sensor_simulator.c", "/lib/c/reactor-c/util/sensor_simulator.h", diff --git a/example/C/src/Rhythm/SensorSimulator.lf b/example/C/src/Rhythm/SensorSimulator.lf index ac9d54f6f3..8eb6383713 100644 --- a/example/C/src/Rhythm/SensorSimulator.lf +++ b/example/C/src/Rhythm/SensorSimulator.lf @@ -3,7 +3,6 @@ * This has no audio output, but just tests the ncurses interface. */ target C { - workers: 2, keepalive: true, files: [ "/lib/c/reactor-c/util/sensor_simulator.c", diff --git a/example/C/src/TrainDoor/TrainDoor.lf b/example/C/src/TrainDoor/TrainDoor.lf index 38cb841d54..4b2d2bddca 100644 --- a/example/C/src/TrainDoor/TrainDoor.lf +++ b/example/C/src/TrainDoor/TrainDoor.lf @@ -1,4 +1,4 @@ -target C {workers: 1, keepalive: true}; +target C {keepalive: true}; preamble {= #include From 0c5040819560909d40875264e8a7b8f83188a708 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 9 Mar 2022 16:05:22 -0800 Subject: [PATCH 33/39] Run tests with `threading=on` by default, `threading=off` as special case. --- .../src/org/lflang/tests/AbstractTest.java | 24 +++++----- .../src/org/lflang/tests/Configurators.java | 45 ++++++------------- .../src/org/lflang/tests/TestBase.java | 33 ++++++-------- .../src/org/lflang/tests/runtime/CTest.java | 6 +-- .../src/org/lflang/tests/runtime/CppTest.java | 6 +-- .../org/lflang/tests/runtime/PythonTest.java | 2 +- 6 files changed, 47 insertions(+), 69 deletions(-) diff --git a/org.lflang.tests/src/org/lflang/tests/AbstractTest.java b/org.lflang.tests/src/org/lflang/tests/AbstractTest.java index 5299475590..ee8c9c28a1 100644 --- a/org.lflang.tests/src/org/lflang/tests/AbstractTest.java +++ b/org.lflang.tests/src/org/lflang/tests/AbstractTest.java @@ -36,9 +36,9 @@ protected AbstractTest(List targets) { /** - * Whether to enable {@link #runWithFourThreads()}. + * Whether to enable {@link #runWithThreadsOff()}. */ - protected boolean supportsThreadsOption() { + protected boolean supportsSingleThreadedExecution() { return false; } @@ -80,21 +80,21 @@ public void validateExamples() { @Test public void runGenericTests() { runTestsForTargets(Message.DESC_GENERIC, - TestCategory.GENERIC::equals, Configurators::useSingleThread, + TestCategory.GENERIC::equals, Configurators::noChanges, TestLevel.EXECUTION, false); } @Test public void runTargetSpecificTests() { runTestsForTargets(Message.DESC_TARGET_SPECIFIC, - TestCategory.TARGET::equals, Configurators::useSingleThread, + TestCategory.TARGET::equals, Configurators::noChanges, TestLevel.EXECUTION, false); } @Test public void runMultiportTests() { runTestsForTargets(Message.DESC_MULTIPORT, - TestCategory.MULTIPORT::equals, Configurators::useSingleThread, + TestCategory.MULTIPORT::equals, Configurators::noChanges, TestLevel.EXECUTION, false); } @@ -102,7 +102,7 @@ public void runMultiportTests() { public void runTypeParameterTests() { Assumptions.assumeTrue(supportsGenericTypes(), Message.NO_GENERICS_SUPPORT); runTestsForTargets(Message.DESC_TYPE_PARMS, - TestCategory.GENERICS::equals, Configurators::useSingleThread, + TestCategory.GENERICS::equals, Configurators::noChanges, TestLevel.EXECUTION, false); } @@ -110,7 +110,7 @@ public void runTypeParameterTests() { @Test public void runSerializationTests() { runTestsForTargets(Message.DESC_SERIALIZATION, - TestCategory.SERIALIZATION::equals, Configurators::useSingleThread, + TestCategory.SERIALIZATION::equals, Configurators::noChanges, TestLevel.EXECUTION, false); } @@ -181,12 +181,12 @@ public void runDockerFederatedTests() { @Test - public void runWithFourThreads() { - Assumptions.assumeTrue(supportsThreadsOption(), Message.NO_THREAD_SUPPORT); + public void runWithThreadsOff() { + Assumptions.assumeTrue(supportsSingleThreadedExecution(), Message.NO_SINGLE_THREADED_SUPPORT); this.runTestsForTargets( - Message.DESC_FOUR_THREADS, - Configurators::isExcluded, - Configurators::useFourThreads, + Message.DESC_SINGLE_THREADED, + Configurators::compatibleWithThreadingOff, + Configurators::disableThreading, TestLevel.EXECUTION, true ); diff --git a/org.lflang.tests/src/org/lflang/tests/Configurators.java b/org.lflang.tests/src/org/lflang/tests/Configurators.java index dd3e4363a9..6b6ad416d4 100644 --- a/org.lflang.tests/src/org/lflang/tests/Configurators.java +++ b/org.lflang.tests/src/org/lflang/tests/Configurators.java @@ -56,54 +56,37 @@ public interface Configurator { * @param test The test to configure. * @return True if successful, false otherwise. */ - public static boolean useSingleThread(LFTest test) { + public static boolean disableThreading(LFTest test) { test.context.getArgs().setProperty("threading", "false"); test.context.getArgs().setProperty("workers", "1"); return true; } - /** - * Configure the given test to use multi-threaded with 4 workers. - * - * For targets that provide a threaded and an unthreaded runtime, - * this configures using the threaded runtime. For all targets, - * the number of workers is set to 4. - * - * @param test The test to configure - * @return True if successful, false otherwise. - */ - public static boolean useFourThreads(LFTest test) { - test.context.getArgs().setProperty("threading", "true"); - test.context.getArgs().setProperty("workers", "4"); - return true; - } - /** * Make no changes to the configuration. * - * @param test The test to configure. + * @param ignoredTest The test to configure. * @return True */ - public static boolean noChanges(LFTest test) { + public static boolean noChanges(LFTest ignoredTest) { return true; } /** - * Given a test category, return true if it is not one of the default excluded - * categories. + * Given a test category, return true if it is compatible with single-threaded execution. */ - public static boolean isExcluded(TestCategory category) { - boolean excluded = false; - - // CONCURRENT, FEDERATED, EXAMPLE, DOCKER_FEDERATED, DOCKER are excluded - excluded |= (category == TestCategory.CONCURRENT - || category == TestCategory.FEDERATED - || category == TestCategory.EXAMPLE - || category == TestCategory.DOCKER_FEDERATED - || category == TestCategory.DOCKER); + public static boolean compatibleWithThreadingOff(TestCategory category) { + + // CONCURRENT, FEDERATED, EXAMPLE, DOCKER_FEDERATED, DOCKER + // are not compatible with single-threaded execution. + boolean excluded = category == TestCategory.CONCURRENT + || category == TestCategory.FEDERATED + || category == TestCategory.EXAMPLE + || category == TestCategory.DOCKER_FEDERATED + || category == TestCategory.DOCKER; // SERIALIZATION and TARGET tests are excluded on Windows. - excluded |= (TestBase.isWindows() && (category == TestCategory.SERIALIZATION || category == TestCategory.TARGET)); + excluded |= TestBase.isWindows() && (category == TestCategory.SERIALIZATION || category == TestCategory.TARGET); return !excluded; } } diff --git a/org.lflang.tests/src/org/lflang/tests/TestBase.java b/org.lflang.tests/src/org/lflang/tests/TestBase.java index 55f13f0f14..73e2a93c68 100644 --- a/org.lflang.tests/src/org/lflang/tests/TestBase.java +++ b/org.lflang.tests/src/org/lflang/tests/TestBase.java @@ -12,7 +12,6 @@ import java.nio.file.Path; import java.io.File; import java.io.FileWriter; -import java.io.FileFilter; import java.io.BufferedWriter; import java.util.Arrays; import java.util.Collections; @@ -116,28 +115,27 @@ public enum TestLevel {VALIDATION, CODE_GEN, BUILD, EXECUTION} public static class Message { /* Reasons for not running tests. */ public static final String NO_WINDOWS_SUPPORT = "Not (yet) supported on Windows."; - public static final String ALWAYS_MULTITHREADED = "The reactor-cpp runtime is always multithreaded."; - public static final String NO_THREAD_SUPPORT = "Target does not support the 'threads' property."; + public static final String NO_SINGLE_THREADED_SUPPORT = "Target does not support single-threaded execution."; public static final String NO_FEDERATION_SUPPORT = "Target does not support federated execution."; 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."; /* Descriptions of collections of tests. */ - public static final String DESC_SERIALIZATION = "Run serialization tests (threads = 0)."; - public static final String DESC_GENERIC = "Run generic tests (threads = 0)."; + public static final String DESC_SERIALIZATION = "Run serialization tests."; + public static final String DESC_GENERIC = "Run generic tests."; public static final String DESC_TYPE_PARMS = "Run tests for reactors with type parameters."; public static final String DESC_EXAMPLES = "Validate examples."; public static final String DESC_EXAMPLE_TESTS = "Run example tests."; - public static final String DESC_MULTIPORT = "Run multiport tests (threads = 0)."; + public static final String DESC_MULTIPORT = "Run multiport tests."; public static final String DESC_AS_FEDERATED = "Run non-federated tests in federated mode."; public static final String DESC_FEDERATED = "Run federated tests."; public static final String DESC_DOCKER = "Run docker tests."; public static final String DESC_DOCKER_FEDERATED = "Run docker federated tests."; public static final String DESC_CONCURRENT = "Run concurrent tests."; - public static final String DESC_TARGET_SPECIFIC = "Run target-specific tests (threads = 0)"; + public static final String DESC_TARGET_SPECIFIC = "Run target-specific tests"; 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_SINGLE_THREADED = "Run non-concurrent and non-federated tests with threading = off."; public static final String DESC_SCHED_SWAPPING = "Running with non-default runtime scheduler "; public static final String DESC_ROS2 = "Running tests using ROS2."; @@ -484,7 +482,7 @@ private void execute(LFTest test, GeneratorResult generatorResult) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); - test.execLog.buffer.append(sw.toString()); + test.execLog.buffer.append(sw); return; } test.result = Result.TEST_PASS; @@ -498,16 +496,13 @@ private void execute(LFTest test, GeneratorResult generatorResult) { private Map getFederatedDockerFiles(LFTest test) { Map fedNameToDockerFile = new HashMap<>(); File[] srcGenFiles = test.fileConfig.getSrcGenPath().toFile().listFiles(); - for (File srcGenFile : srcGenFiles) { - if (srcGenFile.isDirectory()) { - File[] dockerFile = srcGenFile.listFiles(new FileFilter() { - @Override - public boolean accept(File pathName) { - return pathName.getName().endsWith("Dockerfile"); - } - }); - assert dockerFile.length == 1; - fedNameToDockerFile.put(srcGenFile.getName(), dockerFile[0].getAbsoluteFile().toPath()); + if (srcGenFiles != null) { + for (File srcGenFile : srcGenFiles) { + if (srcGenFile.isDirectory()) { + File[] dockerFile = srcGenFile.listFiles(pathName -> pathName.getName().endsWith("Dockerfile")); + assert (dockerFile != null ? dockerFile.length : 0) == 1; + fedNameToDockerFile.put(srcGenFile.getName(), dockerFile[0].getAbsoluteFile().toPath()); + } } } return fedNameToDockerFile; diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/CTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/CTest.java index 4873ff1266..52bb296ed8 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/CTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/CTest.java @@ -48,7 +48,7 @@ public CTest() { } @Override - protected boolean supportsThreadsOption() { + protected boolean supportsSingleThreadedExecution() { return true; } @@ -95,8 +95,8 @@ public void runMultiportTests() { @Test @Override - public void runWithFourThreads() { - super.runWithFourThreads(); + public void runWithThreadsOff() { + super.runWithThreadsOff(); } @Test diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java index 2703a3db7d..942074e561 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java @@ -48,7 +48,7 @@ public CppTest() { } @Override - protected boolean supportsThreadsOption() { + protected boolean supportsSingleThreadedExecution() { return true; } @@ -77,8 +77,8 @@ public void runMultiportTests() { @Test @Override - public void runWithFourThreads() { - Assumptions.assumeFalse(true, Message.ALWAYS_MULTITHREADED); + public void runWithThreadsOff() { + Assumptions.assumeFalse(true, Message.NO_SINGLE_THREADED_SUPPORT); } @Test diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java index 265a813424..1f3a8094d7 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java @@ -53,7 +53,7 @@ protected boolean supportsFederatedExecution() { } @Override - protected boolean supportsThreadsOption() { + protected boolean supportsSingleThreadedExecution() { return true; } From 28242b89cd62c7ad2bb0a5d812fe819c6092d191 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 9 Mar 2022 16:23:18 -0800 Subject: [PATCH 34/39] Fix compile error --- .../src/org/lflang/tests/runtime/CSchedulerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/CSchedulerTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/CSchedulerTest.java index d9ab56ed30..552297a81c 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/CSchedulerTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/CSchedulerTest.java @@ -64,7 +64,7 @@ private void runTest(SchedulerOption scheduler, EnumSet categories "scheduler", scheduler.toString() ); - return Configurators.useFourThreads(test); + return Configurators.noChanges(test); }, TestLevel.EXECUTION, true From 34463fc87cf30c162db51d7c5c7400dd4c23d8c3 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 9 Mar 2022 16:24:25 -0800 Subject: [PATCH 35/39] Added tests that verify `workers` property is heeded --- test/C/src/concurrent/Workers.lf | 10 ++++++++++ test/Cpp/src/concurrent/Workers.lf | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/C/src/concurrent/Workers.lf create mode 100644 test/Cpp/src/concurrent/Workers.lf diff --git a/test/C/src/concurrent/Workers.lf b/test/C/src/concurrent/Workers.lf new file mode 100644 index 0000000000..aaefb324c3 --- /dev/null +++ b/test/C/src/concurrent/Workers.lf @@ -0,0 +1,10 @@ +target C { workers: 16 }; +main reactor { + reaction(startup) {= + if (NUMBER_OF_WORKERS != 16) { + error_print_and_exit("Expected to have 16 workers."); + } else { + info_print("Using 16 workers."); + } + =} +} \ No newline at end of file diff --git a/test/Cpp/src/concurrent/Workers.lf b/test/Cpp/src/concurrent/Workers.lf new file mode 100644 index 0000000000..814763fdf0 --- /dev/null +++ b/test/Cpp/src/concurrent/Workers.lf @@ -0,0 +1,11 @@ +target Cpp { workers: 16 }; +main reactor { + reaction(startup) {= + if (environment()->num_workers() != 16) { + std::cout << "Expected to have 16 workers.\n"; + exit(1); + } else { + std::cout << "Using 16 workers.\n"; + } + =} +} \ No newline at end of file From 21be25cc96161b0af68490baf42e356fe877c135 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 9 Mar 2022 17:05:46 -0800 Subject: [PATCH 36/39] Renamed AbstractTest to RuntimeTest and created a category for modal models --- .../tests/{AbstractTest.java => RuntimeTest.java} | 13 ++++++------- .../src/org/lflang/tests/TestRegistry.java | 6 ++++-- .../src/org/lflang/tests/runtime/CTest.java | 8 ++++---- .../src/org/lflang/tests/runtime/CppTest.java | 6 +++--- .../src/org/lflang/tests/runtime/PythonTest.java | 4 ++-- .../src/org/lflang/tests/runtime/RustTest.java | 4 ++-- .../org/lflang/tests/runtime/TypeScriptTest.java | 4 ++-- 7 files changed, 23 insertions(+), 22 deletions(-) rename org.lflang.tests/src/org/lflang/tests/{AbstractTest.java => RuntimeTest.java} (96%) diff --git a/org.lflang.tests/src/org/lflang/tests/AbstractTest.java b/org.lflang.tests/src/org/lflang/tests/RuntimeTest.java similarity index 96% rename from org.lflang.tests/src/org/lflang/tests/AbstractTest.java rename to org.lflang.tests/src/org/lflang/tests/RuntimeTest.java index ee8c9c28a1..a525c8c629 100644 --- a/org.lflang.tests/src/org/lflang/tests/AbstractTest.java +++ b/org.lflang.tests/src/org/lflang/tests/RuntimeTest.java @@ -15,14 +15,14 @@ * @author Marten Lohstroh * */ -public abstract class AbstractTest extends TestBase { +public abstract class RuntimeTest extends TestBase { /** * Construct a test instance that runs tests for a single target. * * @param target The target to run tests for. */ - protected AbstractTest(Target target) { + protected RuntimeTest(Target target) { super(target); } @@ -30,13 +30,12 @@ protected AbstractTest(Target target) { * Construct a test instance that runs tests for a list of targets. * @param targets The targets to run tests for. */ - protected AbstractTest(List targets) { + protected RuntimeTest(List targets) { super(targets); } - - + /** - * Whether to enable {@link #runWithThreadsOff()}. + * Whether to enable {@link #runWithThreadingOff()}. */ protected boolean supportsSingleThreadedExecution() { return false; @@ -181,7 +180,7 @@ public void runDockerFederatedTests() { @Test - public void runWithThreadsOff() { + public void runWithThreadingOff() { Assumptions.assumeTrue(supportsSingleThreadedExecution(), Message.NO_SINGLE_THREADED_SUPPORT); this.runTestsForTargets( Message.DESC_SINGLE_THREADED, diff --git a/org.lflang.tests/src/org/lflang/tests/TestRegistry.java b/org.lflang.tests/src/org/lflang/tests/TestRegistry.java index c889e04869..c19dc73b7c 100644 --- a/org.lflang.tests/src/org/lflang/tests/TestRegistry.java +++ b/org.lflang.tests/src/org/lflang/tests/TestRegistry.java @@ -153,10 +153,12 @@ public enum TestCategory { FEDERATED(true), /** Tests about specific target properties. */ PROPERTIES(true), + /** Tests concerning modal reactors */ + MODAL_MODELS(true), // non-shared tests - DOCKER(false), - DOCKER_FEDERATED(false, "docker" + File.separator + "federated"), + DOCKER(true), + DOCKER_FEDERATED(true, "docker" + File.separator + "federated"), SERIALIZATION(false), TARGET(false), EXAMPLE(false), diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/CTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/CTest.java index 52bb296ed8..fded4c3720 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/CTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/CTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; import org.lflang.Target; -import org.lflang.tests.AbstractTest; +import org.lflang.tests.RuntimeTest; /** * Collection of tests for the C target. @@ -41,7 +41,7 @@ * then clicking "Run".* * @author Marten Lohstroh */ -public class CTest extends AbstractTest { +public class CTest extends RuntimeTest { public CTest() { super(Target.C); @@ -95,8 +95,8 @@ public void runMultiportTests() { @Test @Override - public void runWithThreadsOff() { - super.runWithThreadsOff(); + public void runWithThreadingOff() { + super.runWithThreadingOff(); } @Test diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java index 942074e561..57fd3cdaa6 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.lflang.Target; -import org.lflang.tests.AbstractTest; +import org.lflang.tests.RuntimeTest; /** * Collection of tests for the Cpp target. @@ -41,7 +41,7 @@ * * @author Marten Lohstroh */ -public class CppTest extends AbstractTest { +public class CppTest extends RuntimeTest { public CppTest() { super(Target.CPP); @@ -77,7 +77,7 @@ public void runMultiportTests() { @Test @Override - public void runWithThreadsOff() { + public void runWithThreadingOff() { Assumptions.assumeFalse(true, Message.NO_SINGLE_THREADED_SUPPORT); } diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java index 1f3a8094d7..1ac10fee53 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.lflang.Target; -import org.lflang.tests.AbstractTest; +import org.lflang.tests.RuntimeTest; /** * Collection of tests for the Python target. @@ -41,7 +41,7 @@ * * @author Marten Lohstroh {@literal } */ -public class PythonTest extends AbstractTest { +public class PythonTest extends RuntimeTest { public PythonTest() { super(Target.Python); diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/RustTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/RustTest.java index fc454f6cc6..a064a8e8d2 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/RustTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/RustTest.java @@ -27,12 +27,12 @@ import java.util.Properties; import org.lflang.Target; -import org.lflang.tests.AbstractTest; +import org.lflang.tests.RuntimeTest; /** * */ -public class RustTest extends AbstractTest { +public class RustTest extends RuntimeTest { public RustTest() { super(Target.Rust); diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/TypeScriptTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/TypeScriptTest.java index 108bf220e8..e755fbbef9 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/TypeScriptTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/TypeScriptTest.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.lflang.Target; -import org.lflang.tests.AbstractTest; +import org.lflang.tests.RuntimeTest; /** * Collection of tests for the TypeScript target. @@ -16,7 +16,7 @@ * * @author Marten Lohstroh */ -public class TypeScriptTest extends AbstractTest { +public class TypeScriptTest extends RuntimeTest { public TypeScriptTest() { super(Target.TS); } From dd7bc59c30c2b3cb2c56f6239165a5e0c80cca31 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 9 Mar 2022 17:23:52 -0800 Subject: [PATCH 37/39] Do not perform single-threaded tests for C++ --- .../src/org/lflang/tests/runtime/CppTest.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java b/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java index 57fd3cdaa6..c57ff60c6e 100644 --- a/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java +++ b/org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java @@ -47,11 +47,6 @@ public CppTest() { super(Target.CPP); } - @Override - protected boolean supportsSingleThreadedExecution() { - return true; - } - @Override public void runExampleTests() { super.runExampleTests(); @@ -74,12 +69,6 @@ public void runTargetSpecificTests() { public void runMultiportTests() { super.runMultiportTests(); } - - @Test - @Override - public void runWithThreadingOff() { - Assumptions.assumeFalse(true, Message.NO_SINGLE_THREADED_SUPPORT); - } @Test @Override From 75a8df841139e80a47d566658fb97a4c682da9cc Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 9 Mar 2022 18:33:01 -0800 Subject: [PATCH 38/39] Run the tests for modal reactors also with the multithreaded runtime --- org.lflang.tests/src/org/lflang/tests/RuntimeTest.java | 10 ++++++++++ org.lflang.tests/src/org/lflang/tests/TestBase.java | 1 + 2 files changed, 11 insertions(+) diff --git a/org.lflang.tests/src/org/lflang/tests/RuntimeTest.java b/org.lflang.tests/src/org/lflang/tests/RuntimeTest.java index a525c8c629..8cb6c33a89 100644 --- a/org.lflang.tests/src/org/lflang/tests/RuntimeTest.java +++ b/org.lflang.tests/src/org/lflang/tests/RuntimeTest.java @@ -150,6 +150,16 @@ public void runFederatedTests() { false); } + /** + * Run the tests for modal reactors. + */ + @Test + public void runModalTests() { + runTestsForTargets(Message.DESC_MODAL, + TestCategory.MODAL_MODELS::equals, Configurators::noChanges, TestLevel.EXECUTION, + false); + } + /** * Run docker tests, provided that the platform is Linux and the target supports Docker. * Skip if platform is not Linux or target does not support Docker. diff --git a/org.lflang.tests/src/org/lflang/tests/TestBase.java b/org.lflang.tests/src/org/lflang/tests/TestBase.java index 73e2a93c68..1d37930fa0 100644 --- a/org.lflang.tests/src/org/lflang/tests/TestBase.java +++ b/org.lflang.tests/src/org/lflang/tests/TestBase.java @@ -138,6 +138,7 @@ public static class Message { public static final String DESC_SINGLE_THREADED = "Run non-concurrent and non-federated tests with threading = off."; public static final String DESC_SCHED_SWAPPING = "Running with non-default runtime scheduler "; public static final String DESC_ROS2 = "Running tests using ROS2."; + public static final String DESC_MODAL = "Run docker tests."; /* Missing dependency messages */ public static final String MISSING_DOCKER = "Executable 'docker' not found or 'docker' daemon thread not running"; From 3f9278bf49915445f8c7af6934854d07aa2de00f Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 9 Mar 2022 19:50:27 -0800 Subject: [PATCH 39/39] Fixed typo --- org.lflang.tests/src/org/lflang/tests/TestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.lflang.tests/src/org/lflang/tests/TestBase.java b/org.lflang.tests/src/org/lflang/tests/TestBase.java index 1d37930fa0..3ae4995b96 100644 --- a/org.lflang.tests/src/org/lflang/tests/TestBase.java +++ b/org.lflang.tests/src/org/lflang/tests/TestBase.java @@ -138,7 +138,7 @@ public static class Message { public static final String DESC_SINGLE_THREADED = "Run non-concurrent and non-federated tests with threading = off."; public static final String DESC_SCHED_SWAPPING = "Running with non-default runtime scheduler "; public static final String DESC_ROS2 = "Running tests using ROS2."; - public static final String DESC_MODAL = "Run docker tests."; + public static final String DESC_MODAL = "Run modal reactor tests."; /* Missing dependency messages */ public static final String MISSING_DOCKER = "Executable 'docker' not found or 'docker' daemon thread not running";