Skip to content

Commit

Permalink
Merge pull request #2400 from lf-lang/rti-DNET
Browse files Browse the repository at this point in the history
A target property for handling `downstream next event tag` (`DNET`) signal
  • Loading branch information
edwardalee authored Jan 24, 2025
2 parents 854e0b3 + 9d6a84c commit aa667fb
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ts-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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#master"
- name: Report to CodeCov
uses: ./.github/actions/report-code-coverage
with:
Expand Down
18 changes: 18 additions & 0 deletions core/src/main/java/org/lflang/federated/extensions/CExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,27 @@ private boolean containsAllVarRefs(Iterable<VarRef> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -323,6 +324,9 @@ private String getRtiCommand(List<FederateInstance> 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() + " \\",
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/lflang/target/Target.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ public void initialize(TargetConfig config) {
CompilerProperty.INSTANCE,
CoordinationOptionsProperty.INSTANCE,
CoordinationProperty.INSTANCE,
DNETProperty.INSTANCE,
DockerProperty.INSTANCE,
FilesProperty.INSTANCE,
KeepaliveProperty.INSTANCE,
Expand Down
27 changes: 27 additions & 0 deletions core/src/main/java/org/lflang/target/property/DNETProperty.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.lflang.target.property;

/**
* @brief Target property turning on or off the DNET signal optimization.
* <p>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 {

/** 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";
}
}

0 comments on commit aa667fb

Please sign in to comment.