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

Support for basic scheduling enclaves in the C++ target #1513

Merged
merged 40 commits into from
Jan 13, 2023
Merged

Conversation

cmnrd
Copy link
Collaborator

@cmnrd cmnrd commented Dec 21, 2022

This PR introduces the @enclave attribute which allows to nest reactor programs such they can execute independently (similar to federates) while sharing the same address space. Any reactor instance annotated with @enclave will create its own execution environment and scheduler (the enclave), and act as the top-level reactor in this enclave. This also works for banks. By default, a bank annotated with @enclave will create a single enclave where all bank instances are top-level reactors. If instead @enclave(individual=true) is used, this will create n enclaves for a bank of width n where each bank instance is the top-level reactor in one of the enclaves.

This pulls in lf-lang/reactor-cpp#37

Missing features that will be added in later PRs:

  • Communication between enclaves
  • Synchronized shutdown (currently, timeout can be used to shut down synchronously at the same tag)

Closes #1383

@cmnrd cmnrd added cpp Related to C++ target feature New feature labels Dec 21, 2022
private boolean isOptional() {
return defaultValue == null;
}
record AttrParamSpec(String name, AttrParamType type, boolean isOptional) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is very sensible. Previously isOptional was implemented in terms of the default value. With your change we can't add back default values later, as changing the constructor back to take an Object as third param would make all existing constructor calls have a default value of true...

If you want to increase readability of the ctor calls then a better way IMO would be to have static factory methods newRequiredParam(String name, AttrParamType type), newParamWithDefault(String name, AttrParamType type, Object defaultValue) that delegate to the constructor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value was not used anywhere and since this class only works as a spec for the verifier I would argue that the default value is not needed anyway. It would only make sense to keep it if we use this spec in `AttributUtils' to retrieve the value of the parameter, but this would be a larger change.

org.lflang/src/org/lflang/validation/AttributeSpec.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/validation/AttributeSpec.java Outdated Show resolved Hide resolved
List.of(new AttrParamSpec(VALUE_ATTR, AttrParamType.STRING, true))
));
// @enclave(indivdual=boolean)
ATTRIBUTE_SPECS_BY_NAME.put("enclave", new AttributeSpec(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this individual attribute is optional, then it should mention a default value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't manage default values centrally at the moment, I don't think it should. I agree that we should provide a better infrastructure for attribute parameters, but this should be done in another PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the term "enclave" is getting established. Did we decide the terminology collision with Intel SGX doesn't matter?

@cmnrd
Copy link
Collaborator Author

cmnrd commented Dec 21, 2022

I am moving @edwardalee's comment out of the code discussion for better visibility.

It looks like the term "enclave" is getting established. Did we decide the terminology collision with Intel SGX doesn't matter?

I think enclave is the best option currently on the table and I went with it. I wouldn't consider the terminology final, though. But personally I think the feature is conceptually sufficiently distinct from Intel SGX.

@cmnrd
Copy link
Collaborator Author

cmnrd commented Dec 21, 2022

The discussion in today's meeting concluded that we should use the term "scheduling enclave" in our documentation to disambiguate from secure enclaves.

@cmnrd
Copy link
Collaborator Author

cmnrd commented Jan 5, 2023

I hope the tests are fixed for good now. As far as I am concerned, this is ready to be merged.

@lhstrh
Copy link
Member

lhstrh commented Jan 5, 2023

I agree that it looks ready, but I left a suggestion for a syntax change...

@cmnrd cmnrd merged commit 6c76a4b into master Jan 13, 2023
@cmnrd cmnrd deleted the cpp-affiliated branch January 13, 2023 12:36
@lhstrh lhstrh changed the title Enable basic enclaves in the C++ target Support for basic enclaves in the C++ target Jan 26, 2023
@lhstrh lhstrh changed the title Support for basic enclaves in the C++ target Support for basic scheduling enclaves in the C++ target Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp Related to C++ target feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build the infrastructure to generate multiple unconnected enclaves.
4 participants