diff --git a/.github/scripts/test-lfc.sh b/.github/scripts/test-lfc.sh index 2f82c01964..6f557f8600 100755 --- a/.github/scripts/test-lfc.sh +++ b/.github/scripts/test-lfc.sh @@ -65,9 +65,11 @@ 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 +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/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}"] 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: 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: diff --git a/example/C/src/Deadline.lf b/example/C/src/Deadline.lf index 91eb37b237..0256020612 100644 --- a/example/C/src/Deadline.lf +++ b/example/C/src/Deadline.lf @@ -10,7 +10,6 @@ * @author Edward A. Lee */ target C { - threads: 1, keepalive: true }; preamble {= diff --git a/example/C/src/MQTT/MQTTDistributed.lf b/example/C/src/MQTT/MQTTDistributed.lf index 92ea8504bd..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 { - threads: 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..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. - threads: 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 163e8b0d88..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 { - threads: 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 3e6bb169ef..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 { - threads: 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/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..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", - threads: 1, }; preamble {= diff --git a/example/C/src/ReflexGame.lf b/example/C/src/ReflexGame.lf index a342da1d58..16a65b0527 100644 --- a/example/C/src/ReflexGame.lf +++ b/example/C/src/ReflexGame.lf @@ -12,7 +12,6 @@ * @author Marten Lohstroh */ target C { - threads: 1, keepalive: true }; /** diff --git a/example/C/src/ReflexGame/ReflexGameTest.lf b/example/C/src/ReflexGame/ReflexGameTest.lf index 2c0a090abf..b959c39c56 100644 --- a/example/C/src/ReflexGame/ReflexGameTest.lf +++ b/example/C/src/ReflexGame/ReflexGameTest.lf @@ -1,5 +1,4 @@ target C { - threads: 1, keepalive: true, timeout: 5 sec }; diff --git a/example/C/src/Rhythm/Rhythm.lf b/example/C/src/Rhythm/Rhythm.lf index 59d3deff0f..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 { - threads: 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 129d573d6e..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 { - threads: 2, keepalive: true, files: [ "/lib/c/reactor-c/util/sensor_simulator.c", 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..4b2d2bddca 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 {keepalive: true}; preamble {= #include diff --git a/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf b/example/Cpp/src/Patterns/FullyConnected_00_Broadcast.lf index 65a9f4b03f..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 { - threads: 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..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 { - threads: 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..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 { - threads: 1 }; public preamble {= diff --git a/org.lflang.lfc/src/org/lflang/lfc/Main.java b/org.lflang.lfc/src/org/lflang/lfc/Main.java index 6081892a42..63661ed7e3 100644 --- a/org.lflang.lfc/src/org/lflang/lfc/Main.java +++ b/org.lflang.lfc/src/org/lflang/lfc/Main.java @@ -118,8 +118,9 @@ 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); + 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); /** * 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 ec2521ab77..6b6ad416d4 100644 --- a/org.lflang.tests/src/org/lflang/tests/Configurators.java +++ b/org.lflang.tests/src/org/lflang/tests/Configurators.java @@ -46,53 +46,47 @@ public interface Configurator { } /** - * Configure the given test by setting its `threads` target property to 0. + * Configure the given test to use single-threaded execution. * - * @param test The test to configure. - * @return True if successful, false otherwise. - */ - public static boolean useSingleThread(LFTest test) { - test.context.getArgs().setProperty("threads", "0"); - return true; - } - - /** - * Configure the given test by setting its `threads` target property to 4. + * 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 + * @param test The test to configure. * @return True if successful, false otherwise. */ - public static boolean useFourThreads(LFTest test) { - test.context.getArgs().setProperty("threads", "4"); + public static boolean disableThreading(LFTest test) { + test.context.getArgs().setProperty("threading", "false"); + test.context.getArgs().setProperty("workers", "1"); 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/AbstractTest.java b/org.lflang.tests/src/org/lflang/tests/RuntimeTest.java similarity index 86% rename from org.lflang.tests/src/org/lflang/tests/AbstractTest.java rename to org.lflang.tests/src/org/lflang/tests/RuntimeTest.java index 5299475590..8cb6c33a89 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,15 +30,14 @@ 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 #runWithFourThreads()}. + * Whether to enable {@link #runWithThreadingOff()}. */ - protected boolean supportsThreadsOption() { + protected boolean supportsSingleThreadedExecution() { return false; } @@ -80,21 +79,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 +101,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 +109,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); } @@ -151,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. @@ -181,12 +190,12 @@ public void runDockerFederatedTests() { @Test - public void runWithFourThreads() { - Assumptions.assumeTrue(supportsThreadsOption(), Message.NO_THREAD_SUPPORT); + public void runWithThreadingOff() { + 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/TestBase.java b/org.lflang.tests/src/org/lflang/tests/TestBase.java index 55f13f0f14..3ae4995b96 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,30 +115,30 @@ 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."; + 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"; @@ -484,7 +483,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 +497,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/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/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 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..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,14 +41,14 @@ * then clicking "Run".* * @author Marten Lohstroh */ -public class CTest extends AbstractTest { +public class CTest extends RuntimeTest { public CTest() { super(Target.C); } @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 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 2703a3db7d..c57ff60c6e 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,17 +41,12 @@ * * @author Marten Lohstroh */ -public class CppTest extends AbstractTest { +public class CppTest extends RuntimeTest { public CppTest() { super(Target.CPP); } - @Override - protected boolean supportsThreadsOption() { - return true; - } - @Override public void runExampleTests() { super.runExampleTests(); @@ -74,12 +69,6 @@ public void runTargetSpecificTests() { public void runMultiportTests() { super.runMultiportTests(); } - - @Test - @Override - public void runWithFourThreads() { - Assumptions.assumeFalse(true, Message.ALWAYS_MULTITHREADED); - } @Test @Override 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..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); @@ -53,7 +53,7 @@ protected boolean supportsFederatedExecution() { } @Override - protected boolean supportsThreadsOption() { + protected boolean supportsSingleThreadedExecution() { return true; } 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); } diff --git a/org.lflang/src/lib/c/reactor-c b/org.lflang/src/lib/c/reactor-c index 3d7c4f10f4..c10537c345 160000 --- a/org.lflang/src/lib/c/reactor-c +++ b/org.lflang/src/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 3d7c4f10f4a93379b5a550639ab3ea836a38835f +Subproject commit c10537c345a8295f1f426623147b583d2e1a4f68 diff --git a/org.lflang/src/org/lflang/TargetConfig.java b/org.lflang/src/org/lflang/TargetConfig.java index ea44d31e2d..fc9010aee1 100644 --- a/org.lflang/src/org/lflang/TargetConfig.java +++ b/org.lflang/src/org/lflang/TargetConfig.java @@ -210,10 +210,15 @@ public class TargetConfig { 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). + * 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 threads = 0; + 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 32d522b571..8a0e49a0ca 100644 --- a/org.lflang/src/org/lflang/TargetProperty.java +++ b/org.lflang/src/org/lflang/TargetProperty.java @@ -341,12 +341,21 @@ public enum TargetProperty { }), /** - * Directive to specify the number of threads. + * Directive to indicate whether the runtime should use multi-threading. */ - THREADS("threads", PrimitiveType.NON_NEGATIVE_INTEGER, - Arrays.asList(Target.C, Target.CPP, Target.CCPP, Target.Python), + 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. + */ + WORKERS("workers", PrimitiveType.NON_NEGATIVE_INTEGER, + List.of(Target.C, Target.CCPP, Target.Python, Target.CPP, Target.Rust), (config, value, err) -> { - config.threads = ASTUtils.toInteger(value); + config.workers = ASTUtils.toInteger(value); }), /** diff --git a/org.lflang/src/org/lflang/generator/GeneratorUtils.java b/org.lflang/src/org/lflang/generator/GeneratorUtils.java index f5cf198fb6..c668a693d4 100644 --- a/org.lflang/src/org/lflang/generator/GeneratorUtils.java +++ b/org.lflang/src/org/lflang/generator/GeneratorUtils.java @@ -80,8 +80,11 @@ public static void setTargetConfig( if (context.getArgs().containsKey("no-compile")) { targetConfig.noCompile = true; } - if (context.getArgs().containsKey("threads")) { - targetConfig.threads = Integer.parseInt(context.getArgs().getProperty("threads")); + if (context.getArgs().containsKey("workers")) { + targetConfig.workers = Integer.parseInt(context.getArgs().getProperty("workers")); + } + 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"); diff --git a/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java b/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java index 4faabfa2af..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"); @@ -150,7 +144,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,10 +154,16 @@ 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(); } + 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/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/c/CGenerator.xtend b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend index 7bbe39f7b6..38dda27d6a 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.xtend @@ -372,8 +372,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« @@ -480,11 +480,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); @@ -1037,17 +1037,7 @@ class CGenerator extends GeneratorBase { void _lf_initialize_trigger_objects() { ''') code.indent() - - if (targetConfig.threads > 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; - } - ''') - } - + // Initialize the LF clock. code.pr(''' // Initialize the _lf_clock @@ -1332,6 +1322,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", @@ -1626,10 +1617,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(''' @@ -1640,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( - «targetConfig.threads», + (size_t)_lf_number_of_workers, &sched_params ); ''') @@ -4146,9 +4137,14 @@ 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. - targetConfig.threads = CUtil.minThreadsToHandleInputPorts(federates) + // If the program is federated, then ensure that threading is enabled. + targetConfig.threading = true + // 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) { @@ -4251,7 +4247,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 { 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()); diff --git a/org.lflang/src/org/lflang/generator/cpp/CppStandaloneMainGenerator.kt b/org.lflang/src/org/lflang/generator/cpp/CppStandaloneMainGenerator.kt index e6bdbd6e9c..a6f84c56a1 100644 --- a/org.lflang/src/org/lflang/generator/cpp/CppStandaloneMainGenerator.kt +++ b/org.lflang/src/org/lflang/generator/cpp/CppStandaloneMainGenerator.kt @@ -62,7 +62,7 @@ class CppStandaloneMainGenerator( |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()"}; @@ -71,7 +71,7 @@ class CppStandaloneMainGenerator( | 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(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}")) @@ -90,7 +90,7 @@ class CppStandaloneMainGenerator( | | // 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()} diff --git a/org.lflang/src/org/lflang/generator/python/PythonGenerator.java b/org.lflang/src/org/lflang/generator/python/PythonGenerator.java index 58c4443d96..3f08a3b488 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; @@ -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); @@ -368,9 +368,14 @@ 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. - targetConfig.threads = CUtil.minThreadsToHandleInputPorts(federates); + // If the program is federated, then ensure that threading is enabled. + targetConfig.threading = true; + // 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())); @@ -651,11 +656,11 @@ 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 (isFederated) { - targetConfig.threads = 1; + // 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; diff --git a/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt b/org.lflang/src/org/lflang/generator/rust/RustMainFileEmitter.kt index 1171aaed93..0a28891fac 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.threads = ${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.threads = 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 adb9358a0b..20f7e3eff5 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, ) diff --git a/test/C/src/concurrent/AsyncCallback.lf b/test/C/src/concurrent/AsyncCallback.lf index e9c160282f..5ce8b7c013 100644 --- a/test/C/src/concurrent/AsyncCallback.lf +++ b/test/C/src/concurrent/AsyncCallback.lf @@ -9,7 +9,6 @@ */ target C { - threads: 2, tracing: true, timeout: 2 sec }; diff --git a/test/C/src/concurrent/AsyncCallbackDrop.lf b/test/C/src/concurrent/AsyncCallbackDrop.lf index 36d5d45d23..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 { - threads: 1, timeout: 2 sec }; diff --git a/test/C/src/concurrent/AsyncCallbackReplace.lf b/test/C/src/concurrent/AsyncCallbackReplace.lf index d771143bca..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 { - threads: 1, timeout: 2 sec }; diff --git a/test/C/src/concurrent/CompositionThreaded.lf b/test/C/src/concurrent/CompositionThreaded.lf index dc281bf0f0..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 { - threads: 1, fast: true, timeout: 10 sec }; diff --git a/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf b/test/C/src/concurrent/DeadlineHandledAboveThreaded.lf index 77fe936f74..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 {threads: 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 a1fbca4b4f..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, - threads: 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..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 { - threads: 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..91c0231d2d 100644 --- a/test/C/src/concurrent/DeterminismThreaded.lf +++ b/test/C/src/concurrent/DeterminismThreaded.lf @@ -1,5 +1,4 @@ target C { - threads: 1 }; reactor Source { output y:int; diff --git a/test/C/src/concurrent/DoubleReactionThreaded.lf b/test/C/src/concurrent/DoubleReactionThreaded.lf index 9c8d434d4f..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, - threads: 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..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 {threads: 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 5fd80207a3..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, - threads: 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..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 { - threads: 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..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 { - threads: 1 }; main reactor MinimalThreaded { timer t; diff --git a/test/C/src/concurrent/PingPongThreaded.lf b/test/C/src/concurrent/PingPongThreaded.lf index e7f17417a3..3905532d80 100644 --- a/test/C/src/concurrent/PingPongThreaded.lf +++ b/test/C/src/concurrent/PingPongThreaded.lf @@ -23,7 +23,6 @@ */ target C { fast: true, - threads: 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..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, - threads: 1 }; reactor Scheduler { diff --git a/test/C/src/concurrent/ScheduleTwice.lf b/test/C/src/concurrent/ScheduleTwice.lf index b06e682cdb..1818eb3320 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; 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 1df61adab3..110f390c9e 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; 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 749768657e..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 { - threads: 3, timeout: 10 sec, fast: true }; diff --git a/test/C/src/concurrent/StarvationThreaded.lf b/test/C/src/concurrent/StarvationThreaded.lf index fcd18715c1..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 { - threads: 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..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, - threads: 4, build-type: RelWithDebInfo, // logging: DEBUG }; diff --git a/test/C/src/concurrent/StopZeroThreaded.lf b/test/C/src/concurrent/StopZeroThreaded.lf index e3db1f9663..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 { - threads: 4 }; reactor Sender { diff --git a/test/C/src/concurrent/ThreadedMultiport.lf b/test/C/src/concurrent/ThreadedMultiport.lf index ee3837d7bf..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. - threads: 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..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. - threads: 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..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, - threads: 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..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, - threads: 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..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, - threads: 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..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. - threads: 4, logging: DEBUG }; reactor Source { 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/C/src/federated/LoopDistributedCentralized.lf b/test/C/src/federated/LoopDistributedCentralized.lf index ff4e60333f..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}, - threads: 2, timeout: 5 sec } preamble {= diff --git a/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf b/test/C/src/federated/LoopDistributedCentralizedPrecedence.lf index 3c3a3ac0a8..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}, - threads: 2, timeout: 5 sec } diff --git a/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf b/test/C/src/federated/LoopDistributedCentralizedPrecedenceHierarchy.lf index 690733e2a3..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}, - threads: 2, timeout: 5 sec } diff --git a/test/C/src/federated/LoopDistributedDecentralized.lf b/test/C/src/federated/LoopDistributedDecentralized.lf index 5382ffdf6e..c714907c4e 100644 --- a/test/C/src/federated/LoopDistributedDecentralized.lf +++ b/test/C/src/federated/LoopDistributedDecentralized.lf @@ -6,7 +6,6 @@ */ target C { coordination: decentralized, - threads: 3, timeout: 5 sec } preamble {= diff --git a/test/C/src/federated/LoopDistributedDouble.lf b/test/C/src/federated/LoopDistributedDouble.lf index e4959476a6..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}, - threads: 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..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, - threads: 2, timeout: 4900 msec } diff --git a/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf b/test/C/src/federated/failing/LoopDistributedDecentralizedPrecedenceHierarchy.lf index ec63a26f48..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, - threads: 2, timeout: 4900 msec } diff --git a/test/C/src/multiport/BankToBank.lf b/test/C/src/multiport/BankToBank.lf index f01df5bf0e..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, - threads: 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..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, - threads: 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..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, - threads: 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..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, - threads: 4, fast: true }; reactor Source( diff --git a/test/C/src/multiport/MultiportFromBankHierarchy.lf b/test/C/src/multiport/MultiportFromBankHierarchy.lf index 26106bfe3f..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, - threads: 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..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, - threads: 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..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, - threads: 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..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, - threads: 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..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, - threads: 4, fast: true }; reactor Source { diff --git a/test/C/src/multiport/MultiportToBankHierarchy.lf b/test/C/src/multiport/MultiportToBankHierarchy.lf index 9b9cffbaea..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, - threads: 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..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, - threads: 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..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, - threads: 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..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, - threads: 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..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, - threads: 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..4545f32b3c 100644 --- a/test/C/src/target/HelloWorldThreadedCPP.lf +++ b/test/C/src/target/HelloWorldThreadedCPP.lf @@ -5,7 +5,6 @@ */ target CCpp { tracing: true, - threads: 1, logging: DEBUG }; import HelloWorld from "HelloWorldCCPP.lf"; diff --git a/test/Cpp/src/Composition.lf b/test/Cpp/src/Composition.lf index af9813fd3f..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 { - threads: 1, fast: true, timeout: 10 sec }; diff --git a/test/Cpp/src/CompositionAfter.lf b/test/Cpp/src/CompositionAfter.lf index ef8fab48ff..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 { - threads: 1, fast: true, timeout: 10 sec }; diff --git a/test/Cpp/src/Deadline.lf b/test/Cpp/src/Deadline.lf index 48511151b5..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 { - threads: 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..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{ - threads: 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..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{ - threads: 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..a37c102e92 100644 --- a/test/Cpp/src/Determinism.lf +++ b/test/Cpp/src/Determinism.lf @@ -1,5 +1,4 @@ target Cpp{ - threads: 1 }; reactor Source { output y:int; diff --git a/test/Cpp/src/DoubleReaction.lf b/test/Cpp/src/DoubleReaction.lf index 125d073263..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 { - threads: 1, timeout: 10 sec, fast: true }; diff --git a/test/Cpp/src/Gain.lf b/test/Cpp/src/Gain.lf index 5975281f12..69492856f0 100644 --- a/test/Cpp/src/Gain.lf +++ b/test/Cpp/src/Gain.lf @@ -1,6 +1,5 @@ // Example in the Wiki. target Cpp{ - threads: 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..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, - threads: 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..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{ - threads: 1 }; import Imported from "lib/Imported.lf"; diff --git a/test/Cpp/src/Minimal.lf b/test/Cpp/src/Minimal.lf index d853a763b8..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 { - threads: 1 }; main reactor Minimal { diff --git a/test/Cpp/src/SendingInside.lf b/test/Cpp/src/SendingInside.lf index 70fc936f20..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, - threads: 1, fast: true }; reactor Printer { diff --git a/test/Cpp/src/TimeLimit.lf b/test/Cpp/src/TimeLimit.lf index fe13b97fec..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, - threads: 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..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, - threads: 1 }; reactor Source { 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 diff --git a/test/Cpp/src/multiport/BankToBankMultiportAfter.lf b/test/Cpp/src/multiport/BankToBankMultiportAfter.lf index 0a74e8f8d7..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, - threads: 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..a235d6a29f 100644 --- a/test/Cpp/src/multiport/FullyConnected.lf +++ b/test/Cpp/src/multiport/FullyConnected.lf @@ -1,5 +1,4 @@ target Cpp { - threads: 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..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 { - threads: 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..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 { - threads: 1 } import Node from "FullyConnectedAddressable.lf" diff --git a/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf b/test/Cpp/src/multiport/MultiportFromBankHierarchy.lf index ada038de7a..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, - threads: 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..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, - threads: 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..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, - threads: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportOut.lf b/test/Cpp/src/multiport/MultiportOut.lf index 1ace1876bb..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, - threads: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportToBankHierarchy.lf b/test/Cpp/src/multiport/MultiportToBankHierarchy.lf index 84d619ea4e..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, - threads: 1, fast: true }; reactor Source { diff --git a/test/Cpp/src/multiport/MultiportToHierarchy.lf b/test/Cpp/src/multiport/MultiportToHierarchy.lf index 06cc6d037c..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, - threads: 1, fast: true }; reactor Source(width:size_t(4)) { diff --git a/test/Python/src/federated/failing/LoopDistributedCentralized.lf b/test/Python/src/federated/failing/LoopDistributedCentralized.lf index 9b1a665d33..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}, - threads: 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..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}, - threads: 2, timeout: 5 sec } diff --git a/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf b/test/Python/src/federated/failing/LoopDistributedCentralizedPrecedenceHierarchy.lf index e435c658fe..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}, - threads: 2, timeout: 5 sec } diff --git a/test/Python/src/federated/failing/LoopDistributedDecentralized.lf b/test/Python/src/federated/failing/LoopDistributedDecentralized.lf index 0900857866..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, - threads: 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..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, - threads: 2, timeout: 5 sec } preamble {=