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

Reactor naming mechanism in C target #2319

Open
OmerMajNition opened this issue Jun 14, 2024 · 0 comments · May be fixed by #2320
Open

Reactor naming mechanism in C target #2319

OmerMajNition opened this issue Jun 14, 2024 · 0 comments · May be fixed by #2320
Assignees
Labels
c Related to C target

Comments

@OmerMajNition
Copy link
Collaborator

OmerMajNition commented Jun 14, 2024

target C;

reactor A (bank_index:int = 0, name:string = "A", log_level:int = 0) {
    reaction (startup) {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Started\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index
        );
    =}

    reaction (shutdown) {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Terminated\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index
        );
    =}
}

reactor B (bank_index:int = 0, name:string = "B", log_level:int = 0) {
    a = new [3] A();
    reaction (startup) {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Started\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index
        );
    =}

    reaction (shutdown) {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Terminated\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index
        );
    =}
}

reactor C (bank_index:int = 0, name:string = "C", log_level:int = 0) {
    b = new [2] B();
    reaction (startup) {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Started\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index
        );
    =}

    reaction (shutdown) {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Terminated\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index
        );
    =}
}

reactor D (bank_index:int = 0, name:string = "D", log_level:int = 0) {
    a = new [2] A(name = "Another");
    reaction (startup) {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Started\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index
        );
    =}

    reaction (shutdown) {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Terminated\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index
        );
    =}
}

main reactor (name:string = "Base") {
    c = new [2] C(name = "C", log_level = 0);
    d = new [3] D(name = "D");
}

How to let user name reactors with hierarchy maintained in the name. This would also enable to have a unique name for each reactor.

  • With this PR name would be a keyword (the way bank_index is) that could be used to build a FQN of a reactor
  • Default name of the reactor would be used if user doesn't provide name when instantiating a reactor instance
  • a = new [2] A(name = "A"); Two banked instances of A would have names A0 and A1
  • If parent reactor of A also has a name parameter, it would be used while building a name for A (Base0.C0.B0.A0, Base0.C0.B0.A1, Base0.C0.B0.A2 would be the names of A instances part of Bank-0 B instance and Bank-0 C instance)
@OmerMajNition OmerMajNition added the c Related to C target label Jun 14, 2024
@OmerMajNition OmerMajNition self-assigned this Jun 14, 2024
@OmerMajNition OmerMajNition linked a pull request Jun 14, 2024 that will close this issue
@OmerMajNition OmerMajNition linked a pull request Jun 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c Related to C target
Projects
Status: To do
Development

Successfully merging a pull request may close this issue.

1 participant