From 9da28024edac8ba1a6d2bde30f0d365a383473d6 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Tue, 13 Aug 2024 11:33:51 -0700 Subject: [PATCH 01/12] Add a target property of DNET --- .../launcher/FedLauncherGenerator.java | 4 +++ .../main/java/org/lflang/target/Target.java | 2 ++ .../lflang/target/property/DNETProperty.java | 25 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 core/src/main/java/org/lflang/target/property/DNETProperty.java diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index 332ee003c6..6ccb6fd8ca 100644 --- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java +++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java @@ -40,6 +40,7 @@ import org.lflang.target.property.AuthProperty; import org.lflang.target.property.ClockSyncModeProperty; import org.lflang.target.property.ClockSyncOptionsProperty; +import org.lflang.target.property.DNETProperty; import org.lflang.target.property.TracingProperty; import org.lflang.target.property.type.ClockSyncModeType.ClockSyncMode; @@ -323,6 +324,9 @@ private String getRtiCommand(List federates, boolean isRemote) if (targetConfig.getOrDefault(TracingProperty.INSTANCE).isEnabled()) { commands.add(" -t \\"); } + if (targetConfig.getOrDefault(DNETProperty.INSTANCE)) { + commands.add(" -d \\"); + } commands.addAll( List.of( " -n " + federates.size() + " \\", diff --git a/core/src/main/java/org/lflang/target/Target.java b/core/src/main/java/org/lflang/target/Target.java index 30048f5a58..bce87c9ec4 100644 --- a/core/src/main/java/org/lflang/target/Target.java +++ b/core/src/main/java/org/lflang/target/Target.java @@ -38,6 +38,7 @@ import org.lflang.target.property.CompilerProperty; import org.lflang.target.property.CoordinationOptionsProperty; import org.lflang.target.property.CoordinationProperty; +import org.lflang.target.property.DNETProperty; import org.lflang.target.property.DockerProperty; import org.lflang.target.property.ExportDependencyGraphProperty; import org.lflang.target.property.ExportToYamlProperty; @@ -593,6 +594,7 @@ public void initialize(TargetConfig config) { CompilerProperty.INSTANCE, CoordinationOptionsProperty.INSTANCE, CoordinationProperty.INSTANCE, + DNETProperty.INSTANCE, DockerProperty.INSTANCE, FilesProperty.INSTANCE, KeepaliveProperty.INSTANCE, diff --git a/core/src/main/java/org/lflang/target/property/DNETProperty.java b/core/src/main/java/org/lflang/target/property/DNETProperty.java new file mode 100644 index 0000000000..e451372511 --- /dev/null +++ b/core/src/main/java/org/lflang/target/property/DNETProperty.java @@ -0,0 +1,25 @@ +package org.lflang.target.property; + +/** + * If true, the RTI sends DNET signals during the execution of federation. + * The default is ture (for now, for testing). + */ +public final class DNETProperty extends BooleanProperty { + + /** Singleton target property instance. */ + public static final DNETProperty INSTANCE = new DNETProperty(); + + private DNETProperty() { + super(); + } + + @Override + public Boolean initialValue() { + return true; + } + + @Override + public String name() { + return "DNET"; + } +} From 62614550c81cce1641dc286a7b5c4878a7c13a90 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Tue, 13 Aug 2024 11:41:33 -0700 Subject: [PATCH 02/12] Update submodule reactor-c --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 89b0e3617d..925985b170 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 89b0e3617db1d2730552a418fd35f1395afe114a +Subproject commit 925985b170046b4d24ec294efdf051c690395f3e From e29043545de31e0f22afd730315462edc244a247 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Tue, 13 Aug 2024 13:08:38 -0700 Subject: [PATCH 03/12] Apply spotless --- .../main/java/org/lflang/target/property/DNETProperty.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/lflang/target/property/DNETProperty.java b/core/src/main/java/org/lflang/target/property/DNETProperty.java index e451372511..958282cf69 100644 --- a/core/src/main/java/org/lflang/target/property/DNETProperty.java +++ b/core/src/main/java/org/lflang/target/property/DNETProperty.java @@ -1,8 +1,8 @@ package org.lflang.target.property; /** - * If true, the RTI sends DNET signals during the execution of federation. - * The default is ture (for now, for testing). + * If true, the RTI sends DNET signals during the execution of federation. The default is ture (for + * now, for testing). */ public final class DNETProperty extends BooleanProperty { From cf467ec3a6e6ebe0825495fbdf65c30a180908b9 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Wed, 14 Aug 2024 11:02:47 -0700 Subject: [PATCH 04/12] Update submodule reactor-c --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 925985b170..fc970bbd1b 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 925985b170046b4d24ec294efdf051c690395f3e +Subproject commit fc970bbd1b0a47615821943ef348c9e02c83167c From c105ee18cda5e99aa29347feec98a5675bd9a2ae Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Thu, 15 Aug 2024 14:29:39 -0700 Subject: [PATCH 05/12] Update submodules --- .github/workflows/ts-tests.yml | 3 +-- core/src/main/resources/lib/c/reactor-c | 2 +- core/src/main/resources/lib/ts/package.json | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ts-tests.yml b/.github/workflows/ts-tests.yml index 79d2e895d3..344698ba66 100644 --- a/.github/workflows/ts-tests.yml +++ b/.github/workflows/ts-tests.yml @@ -38,8 +38,7 @@ jobs: if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} - name: Perform TypeScript tests run: | - ./gradlew targetTest -Ptarget=TypeScript - # -Druntime="git://github.com/lf-lang/reactor-ts.git#master" + ./gradlew targetTest -Ptarget=TypeScript -Druntime="git://github.com/lf-lang/reactor-ts.git#dnet-ad-hoc" - name: Report to CodeCov uses: ./.github/actions/report-code-coverage with: diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index fc970bbd1b..5e09b528e3 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit fc970bbd1b0a47615821943ef348c9e02c83167c +Subproject commit 5e09b528e39252f8df402366c8d6d5cb9aad3f0d diff --git a/core/src/main/resources/lib/ts/package.json b/core/src/main/resources/lib/ts/package.json index fc063d791e..4224a17075 100644 --- a/core/src/main/resources/lib/ts/package.json +++ b/core/src/main/resources/lib/ts/package.json @@ -2,7 +2,7 @@ "name": "LinguaFrancaDefault", "type": "commonjs", "dependencies": { - "@lf-lang/reactor-ts": "git://github.com/lf-lang/reactor-ts.git#master", + "@lf-lang/reactor-ts": "git://github.com/lf-lang/reactor-ts.git#dnet-ad-hoc", "command-line-args": "^5.1.1", "command-line-usage": "^6.1.3" }, From 70372f17ab945c714dda15aba98b4031bf0016c7 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Sun, 25 Aug 2024 00:28:25 -0700 Subject: [PATCH 06/12] Align reactor-c --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 5e09b528e3..0fab3b6392 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 5e09b528e39252f8df402366c8d6d5cb9aad3f0d +Subproject commit 0fab3b6392b4a6cf87516b120fa9ec6d565c2562 From c60b555bd402d2ed9ff7b4e1771f87bdbda69705 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Sun, 13 Oct 2024 16:20:04 -0700 Subject: [PATCH 07/12] Align submodule reactor-c --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 184567d3bd..da80702620 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 184567d3bd06ae5c5f8a75a0b51093115e7fbe52 +Subproject commit da807026204818cc38c1f39cff167a1c0da9b789 From 83bd58f7eeb5a8a0e5234ab299186f6a9ebf16b0 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Sat, 19 Oct 2024 15:29:20 -0700 Subject: [PATCH 08/12] Update the DNET property --- .github/workflows/ts-tests.yml | 2 +- .../lflang/federated/launcher/FedLauncherGenerator.java | 2 +- .../main/java/org/lflang/target/property/DNETProperty.java | 7 +++++-- core/src/main/resources/lib/c/reactor-c | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ts-tests.yml b/.github/workflows/ts-tests.yml index 68330269b5..0d6e1c85b0 100644 --- a/.github/workflows/ts-tests.yml +++ b/.github/workflows/ts-tests.yml @@ -38,7 +38,7 @@ jobs: if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} - name: Perform TypeScript tests run: | - ./gradlew targetTest -Ptarget=TypeScript -Druntime="git://github.com/lf-lang/reactor-ts.git#dnet-ad-hoc" + ./gradlew targetTest -Ptarget=TypeScript -Druntime="git://github.com/lf-lang/reactor-ts.git#master" - name: Report to CodeCov uses: ./.github/actions/report-code-coverage with: diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index 6ccb6fd8ca..4f824ebc80 100644 --- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java +++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java @@ -324,7 +324,7 @@ private String getRtiCommand(List federates, boolean isRemote) if (targetConfig.getOrDefault(TracingProperty.INSTANCE).isEnabled()) { commands.add(" -t \\"); } - if (targetConfig.getOrDefault(DNETProperty.INSTANCE)) { + if (!targetConfig.getOrDefault(DNETProperty.INSTANCE)) { commands.add(" -d \\"); } commands.addAll( diff --git a/core/src/main/java/org/lflang/target/property/DNETProperty.java b/core/src/main/java/org/lflang/target/property/DNETProperty.java index 958282cf69..9d34cca7b3 100644 --- a/core/src/main/java/org/lflang/target/property/DNETProperty.java +++ b/core/src/main/java/org/lflang/target/property/DNETProperty.java @@ -1,8 +1,11 @@ package org.lflang.target.property; /** - * If true, the RTI sends DNET signals during the execution of federation. The default is ture (for - * now, for testing). + * @brief Target property turning on or off the DNET signal optimization. + * + * If this target property is true, the RTI sends DNET (downstream next event tag) signals to an upstream federate + * to tell the federate that sending LTC and NET signals with tags less than the specified value is unnecessary. + * The default is true. */ public final class DNETProperty extends BooleanProperty { diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 05280d0f54..c2f5316458 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 05280d0f5488058693e18863725bcd1e5fe68a29 +Subproject commit c2f5316458bac61074285ca34d92a87c8511eaf9 From 32bbd70118c426854fdcd2eb9516b95f2819ecc4 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Sat, 19 Oct 2024 16:03:21 -0700 Subject: [PATCH 09/12] Apply spotless --- .../main/java/org/lflang/target/property/DNETProperty.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/lflang/target/property/DNETProperty.java b/core/src/main/java/org/lflang/target/property/DNETProperty.java index 9d34cca7b3..d8c76d7e43 100644 --- a/core/src/main/java/org/lflang/target/property/DNETProperty.java +++ b/core/src/main/java/org/lflang/target/property/DNETProperty.java @@ -2,10 +2,9 @@ /** * @brief Target property turning on or off the DNET signal optimization. - * - * If this target property is true, the RTI sends DNET (downstream next event tag) signals to an upstream federate - * to tell the federate that sending LTC and NET signals with tags less than the specified value is unnecessary. - * The default is true. + *

If this target property is true, the RTI sends DNET (downstream next event tag) signals to + * an upstream federate to tell the federate that sending LTC and NET signals with tags less + * than the specified value is unnecessary. The default is true. */ public final class DNETProperty extends BooleanProperty { From 874bceaa1033d162fa685bed196ecc75cb20d7be Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Wed, 8 Jan 2025 13:59:17 -0700 Subject: [PATCH 10/12] Update reactor-c --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 25a32c9210..463d49051d 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 25a32c9210e95752619db5ddae445dffd34c1b03 +Subproject commit 463d49051dbe78fd7a7438f291517e60f5c99ac5 From 4a2541ce94e17cb7c9b73ee0c2bd88ac9e4750c5 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Wed, 8 Jan 2025 14:00:48 -0700 Subject: [PATCH 11/12] Align reactor-c --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 463d49051d..d32b2255db 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 463d49051dbe78fd7a7438f291517e60f5c99ac5 +Subproject commit d32b2255db0e428e3323531c7c7cf7ae2715f04f From 0d772cd61c2f4adfdb2cc950110067cd24aebc05 Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Thu, 16 Jan 2025 17:22:23 -0700 Subject: [PATCH 12/12] Warn when DNET is enabling and there is a physical action --- .../federated/extensions/CExtension.java | 18 ++++++++++++++++ .../federated/generator/FederateInstance.java | 21 +++++++++++++++++++ core/src/main/resources/lib/c/reactor-c | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/lflang/federated/extensions/CExtension.java b/core/src/main/java/org/lflang/federated/extensions/CExtension.java index 12edb2e693..9e91349c98 100644 --- a/core/src/main/java/org/lflang/federated/extensions/CExtension.java +++ b/core/src/main/java/org/lflang/federated/extensions/CExtension.java @@ -43,6 +43,7 @@ import org.lflang.federated.generator.FederationFileConfig; import org.lflang.federated.launcher.RtiConfig; import org.lflang.federated.serialization.FedROS2CPPSerialization; +import org.lflang.generator.ActionInstance; import org.lflang.generator.CodeBuilder; import org.lflang.generator.LFGeneratorContext; import org.lflang.generator.ReactorInstance; @@ -60,6 +61,7 @@ import org.lflang.target.property.ClockSyncOptionsProperty; import org.lflang.target.property.CoordinationOptionsProperty; import org.lflang.target.property.CoordinationProperty; +import org.lflang.target.property.DNETProperty; import org.lflang.target.property.FedSetupProperty; import org.lflang.target.property.KeepaliveProperty; import org.lflang.target.property.SingleThreadedProperty; @@ -833,6 +835,22 @@ private String generateCodeForPhysicalActions( outputFound = output; } } + if (federate.targetConfig.getOrDefault(DNETProperty.INSTANCE)) { + ActionInstance found = federate.findPhysicalAction(instance); + if (found != null) { + String warning = + String.join( + "\n", + "Found a physical action inside the federate " + + addDoubleQuotes(instance.getName()), + "and a signal downstream next event tag (DNET) will be used.", + "The signal DNET may increase the lag, the time difference between ", + "the time this physical action is scheduled and the time it is executed, ", + "specifically when this federate has multiple upstream reactors.", + "Consider disabling the signal DNET with a property {DNET: false}."); + messageReporter.at(found.getDefinition()).warning(warning); + } + } if (minDelay != TimeValue.MAX_VALUE) { // Unless silenced, issue a warning. if (coordinationOptions.advanceMessageInterval == null) { diff --git a/core/src/main/java/org/lflang/federated/generator/FederateInstance.java b/core/src/main/java/org/lflang/federated/generator/FederateInstance.java index 4ce02d4793..5b7775719d 100644 --- a/core/src/main/java/org/lflang/federated/generator/FederateInstance.java +++ b/core/src/main/java/org/lflang/federated/generator/FederateInstance.java @@ -647,6 +647,27 @@ private boolean containsAllVarRefs(Iterable varRefs) { return inFederate; } + /** + * Return the first found physical action or null if there is no physical action in this federate. + * + * @param instance The reactor instance to check whether there is a physical action. + */ + public ActionInstance findPhysicalAction(ReactorInstance instance) { + for (ActionInstance action : instance.actions) { + if (action.isPhysical()) { + return action; + } + } + for (ReactorInstance child : instance.children) { + for (ActionInstance action : child.actions) { + if (action.isPhysical()) { + return action; + } + } + } + return null; + } + /** * Find output ports that are connected to a physical action trigger upstream in the same reactor. * Return a list of such outputs paired with the minimum delay from the nearest physical action. diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index d32b2255db..df786d36b3 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit d32b2255db0e428e3323531c7c7cf7ae2715f04f +Subproject commit df786d36b3c40112b153c4cf6d6d421366d71fa0