Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeplive natively inferred in the C++ runtime #1630

Merged
merged 7 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/test-lfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bin/lfc --output-path . test/C/src/Minimal.lf
# --runtime-version <arg> Specify the version of the runtime
# library used for compiling LF
# programs.
bin/lfc --runtime-version f157be30bbeab0e2a991f29f9c7f388ca39681a7 test/Cpp/src/Minimal.lf
bin/lfc --runtime-version e80cd36ce5bd625a7b167e7dfd65d25f78b0dd01 test/Cpp/src/Minimal.lf

# -w,--workers Specify the default number of worker threads.
bin/lfc -w 2 test/C/src/Minimal.lf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ class CppRos2NodeGenerator(
| : Node("$nodeName", node_options) {
| 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::max()"}};
|
| // provide a globally accessible reference to this node
| // FIXME: this is pretty hacky...
| lf_node = this;
|
| lf_env = std::make_unique<reactor::Environment>(workers, keepalive, fast, lf_timeout);
| lf_env = std::make_unique<reactor::Environment>(workers, fast, lf_timeout);
|
| // instantiate the main reactor
| lf_main_reactor = std::make_unique<${main.name}> ("${main.name}", lf_env.get(), ${main.name}::Parameters{});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class CppStandaloneMainGenerator(
|
| 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::max()"};
|
| // the timeout variable needs to be tested beyond fitting the Duration-type
Expand All @@ -69,7 +68,6 @@ class CppStandaloneMainGenerator(
| .add_options()
| ("w,workers", "the number of worker threads used by the scheduler", cxxopts::value<unsigned>(workers)->default_value(std::to_string(workers)), "'unsigned'")
| ("o,timeout", "Time after which the execution is aborted.", cxxopts::value<reactor::Duration>(timeout)->default_value(time_to_string(timeout)), "'FLOAT UNIT'")
| ("k,keepalive", "Continue execution even when there are no events to process.", cxxopts::value<bool>(keepalive)->default_value("${targetConfig.keepalive}"))
| ("f,fast", "Allow logical time to run faster than physical time.", cxxopts::value<bool>(fast)->default_value("${targetConfig.fastMode}"))
| ("help", "Print help");
|
Expand All @@ -91,7 +89,7 @@ class CppStandaloneMainGenerator(
| return parse_error ? -1 : 0;
| }
|
| reactor::Environment e{workers, keepalive, fast, timeout};
| reactor::Environment e{workers, fast, timeout};
|
| // instantiate the main reactor
| ${generateMainReactorInstantiation()}
Expand Down
11 changes: 10 additions & 1 deletion org.lflang/src/org/lflang/validation/LFValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ public void checkParameter(Parameter param) {
Reactor reactor = (Reactor) container;
if (reactor.isMain()) {
// we need to check for the cli parameters that are always taken
List<String> cliParams = List.of("t", "threads", "o", "timeout", "k", "keepalive", "f", "fast", "help");
List<String> cliParams = List.of("t", "threads", "o", "timeout", "f", "fast", "help");
if (cliParams.contains(param.getName())) {
error("Parameter '" + param.getName()
+ "' is already in use as command line argument by Lingua Franca,",
Expand Down Expand Up @@ -1030,6 +1030,7 @@ public void checkTargetProperties(KeyValuePairs targetProperties) {
validateClockSyncTargetProperties(targetProperties);
validateSchedulerTargetProperties(targetProperties);
validateRos2TargetProperties(targetProperties);
validateKeepalive(targetProperties);
}

private KeyValuePair getKeyValuePair(KeyValuePairs targetProperties, TargetProperty property) {
Expand Down Expand Up @@ -1125,6 +1126,14 @@ private void validateSchedulerTargetProperties(KeyValuePairs targetProperties) {
}
}

private void validateKeepalive(KeyValuePairs targetProperties) {
KeyValuePair keepalive = getKeyValuePair(targetProperties, TargetProperty.KEEPALIVE);
if (keepalive != null && target == Target.CPP) {
warning("The keepalive property is inferred automatically by the C++ " +
"runtime and the value given here is ignored", keepalive, Literals.KEY_VALUE_PAIR__NAME);
}
}

private void validateRos2TargetProperties(KeyValuePairs targetProperties) {
KeyValuePair ros2 = getKeyValuePair(targetProperties, TargetProperty.ROS2);
KeyValuePair ros2Dependencies = getKeyValuePair(targetProperties, TargetProperty.ROS2_DEPENDENCIES);
Expand Down
1 change: 0 additions & 1 deletion test/Cpp/src/concurrent/AsyncCallback.lf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Test asynchronous callbacks that trigger a physical action.
target Cpp {
timeout: 2 sec,
keepalive: true,
cmake-include: "AsyncCallback.cmake"
}

Expand Down
1 change: 0 additions & 1 deletion test/Cpp/src/concurrent/AsyncCallback2.lf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Test asynchronous callbacks that trigger a non-physical action.
target Cpp {
timeout: 2 sec,
keepalive: true,
cmake-include: "AsyncCallback.cmake"
}

Expand Down
43 changes: 0 additions & 43 deletions test/Cpp/src/properties/Keepalive.lf

This file was deleted.