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

Sdk #78

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Sdk #78

wants to merge 13 commits into from

Conversation

OmerMajNition
Copy link
Collaborator

@OmerMajNition OmerMajNition commented Feb 19, 2025

What this SDK provides

  • Lazy construction of child reactors
  • Lazy construction of child reactor banks
  • Lazy construction of multi-ports
  • Simplified, single line wiring syntax
  • Simplified reaction definition, function can be a lambda function or a member function of reactor class
  • Parameter definition in the form of metadata for self explanatory reactor parameters as well as configurability via a config map of whole topology

Features missing so far, work in progress

  • After delay
  • Enclaves
  • Physical connection
  • Interleaved connection

Building
cd reactor-cpp
mkdir build && cd build && cmake ..
make -j && make install

Examples and Tests
examples and test folders have use cases that help understand the concepts.

Immediate next item

  • Complete the wiring
  • Homogeneous config
  • Generate config files (header and source) by SDK

@OmerMajNition OmerMajNition added the enhancement Enhancement of existing feature label Feb 19, 2025
@OmerMajNition OmerMajNition self-assigned this Feb 19, 2025
@OmerMajNition OmerMajNition marked this pull request as draft February 19, 2025 23:58
Copy link
Member

@tanneberger tanneberger left a comment

Choose a reason for hiding this comment

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

Okay, first of all, thanks for the contributions.

I've looked at several things and a couple of high level points:

  • please adapt the sdk to the google c++ coding style guide a couple "mistakes" I've seen a lot:
    • member variables should have a trailing _
    • trailing return types auto x(...) const noexcept -> int
    • I very often saw a space between function name and opening parenthesis /test (...)/test(...)
    • remove using namespace std
    • Occasionally I have also occasionally hungarian naming notation, please replace these with descriptive names
    • The is .clang-tidy and .clang-format file which enforce the style.
  • Try make things constexpr: I think we should be able to precompile a lot of things in the SDK.
  • Duplication of work between the SDK and the runtime: I've often seen you introduce member variables that do some kind of bookkeeping. The runtime already does a lot of this bookkeeping, try to take advantage of this. Otherwise, it will be very hard to implement new runtime features (like mutations).
  • I would remove the images and dot files from the examples.

@@ -0,0 +1,17 @@
#include "Config-a.hh"
Copy link
Member

Choose a reason for hiding this comment

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

make a folder for all the sdk stuff:

/examples/sdk/SrcSinkFanout/ConfigA/ConfigA.cc


void MainReactor::construction() {

cout << "Construction Main\n";
Copy link
Member

Choose a reason for hiding this comment

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

did you overload cout? or did I miss the using namespace std ?

@@ -0,0 +1,44 @@
digraph {
Copy link
Member

Choose a reason for hiding this comment

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

I think this file should not be added.

Copy link
Member

Choose a reason for hiding this comment

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

I think this file should not be added.

cxxopts::ParseResult result{};
bool parse_error{false};
try {
result = options.parse(argc, argv);
Copy link
Member

Choose a reason for hiding this comment

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

indentation

reactor::ShutdownTrigger shutdown{"shutdown", this};

private:
size_t bank_index_ = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I see so this is so every reactor knows what index he has inside a bank? (Like the example I gave couple of months ago?)


private:
size_t bank_index_ = 0;
SystemParameterBase *p_param = nullptr;
Copy link
Member

Choose a reason for hiding this comment

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

/p_param/system_parameters_/

private:
size_t bank_index_ = 0;
SystemParameterBase *p_param = nullptr;
Environment *env{nullptr};
Copy link
Member

Choose a reason for hiding this comment

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

This is duplicate. You can get it via the environment() function.

/env/env_/ (https://google.github.io/styleguide/cppguide.html)

Reactor *parent{nullptr};
std::string current_reaction_name;
std::unordered_map<std::string, std::shared_ptr<BaseTrigger>> reaction_map;
int priority = 1;
Copy link
Member

Choose a reason for hiding this comment

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

what does the priority field?

std::string current_reaction_name;
std::unordered_map<std::string, std::shared_ptr<BaseTrigger>> reaction_map;
int priority = 1;
std::set<Reactor*> child_reactors;
Copy link
Member

Choose a reason for hiding this comment

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

inside the Reactor class you have the reactor_ field which keeps track of the child reactors.

Copy link
Contributor

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

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

Besides the stylistic issues as noted by Tassilo, I currently see three major hurdles for accepting this PR.

  1. I am currently not convinced that an SDK fits in the scope of this repository. As of now, the purpose of this repository is to provide a reactor runtime implementation supporting lf-lang/lingua-franca where it is integrated as a submodule. As the proposed SDK is meant as an alternative to LF, it does not serve the current purpose of the repository. I am open to a discussion around changing the scope of the repository. However, I want to make sure that such a change happens deliberately and with good reasons. Also, a change in scope implies a change in the relationship with lf-lang/lingua-franca that would need to be carried by the community.
  2. The lack of mechanisms to prevent the user from violating the reactor semantics. While the SDK (like the existing runtime API) provides one correct way for expressing reactor programs, there are also many more wrong ways that the user can choose. There are no guardrails that nudge the user in the right direction, or even better, prevent the users from violating the reactor semantics. While there are limitations to how far one can go with this, I strongly believe that a good measure of protection techniques is required for a reactor SDK to be useful and successful.
  3. The lack of a domain boundary. In LF, the code generator establishes a layer of indirection that can be used to shield user code from changes in the runtime code. The SDK in this PR, however, fully exposes the underlying runtime types and their API. This creates a tight coupling between the runtime code and the user code. This coupling makes it harder to evolve and maintain the runtime. To me, this seems like the opposite of what we want moving forward. Establishing a clear domain boundary would both shield the user from internal runtime changes, and shield the runtime from having to maintain too many user-facing contracts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing feature
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

3 participants