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

Improve access to port references in Rust target #1360

Open
oowekyala opened this issue Sep 7, 2022 · 0 comments
Open

Improve access to port references in Rust target #1360

oowekyala opened this issue Sep 7, 2022 · 0 comments
Labels
rust Related to the Rust target

Comments

@oowekyala
Copy link
Collaborator

oowekyala commented Sep 7, 2022

Currently when a reaction references a port of a child reactor, the Rust target exposes a port with a special name, that is bound to the child's port. For reactor banks this is more problematic, since banks are flattened into a Vec of ports, and the structure of the bank is lost.

The C++ and C targets do not do this. They expose a view on the child instance that allows access to only the declared dependencies. Implementing this would make the Rust target more similar to the others and simplify interactions with banks´.

See also this comment:

Are other targets doing this differently?

I am not sure if I understand how this works in Rust, but in C++ we do not unroll the multiport. In the case of multiports within a bank, the reaction body can say precisely which port in which reactor instance it wants to access. If it wants to read all values, it needs two nested loops:

target Cpp
reactor Source {
  output[5] out: int;
  reaction (startup) -> out {= /* ... */ =}
}
main reactor {
  source = new[4] Source()
  reaction (source.out) {=
    for (int i{0}; i < source.size(); i++) {
      for (int j{0}; j < source[i].out.size(); j++) {
         int value = *source[i].out[j].get();
         // ....
      }
    }
  =}
}

Originally posted by @cmnrd in #1228 (comment)

@oowekyala oowekyala added the rust Related to the Rust target label Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Related to the Rust target
Projects
None yet
Development

No branches or pull requests

1 participant