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

Multiport iterator for more efficient access to sparse inputs #1298

Merged
merged 33 commits into from
Jul 23, 2022

Conversation

edwardalee
Copy link
Collaborator

@edwardalee edwardalee commented Jul 18, 2022

This PR enables more efficient access to input multiports that are sparse, meaning that few of the channels (typically) have inputs present. This is used as in the following example:

     @sparse
     input[100] in:int;
     reaction(in) {=
         struct lf_multiport_iterator_t i = lf_multiport_iterator(in);
         int channel = lf_multiport_next(&i);
         while(channel >= 0) {
             printf("Received %d on channel %d.\n", in[channel]->value, channel);
             channel = lf_multiport_next(&i);
         }
     =}

In my informal measurement, this yields a 15% improvement in the unthreaded execution of the Big benchmark (with the default setting of 120 Worker reactors).

This PR also includes fixes to the annotation scheme to enable annotations with no arguments, as in @sparse above. @lsk567: Please have a look at those changes. If we decide that the 15% improvement is not worth the additional complexity, then we should cherry pick those changes.

The following PRs should be merged with this:

@edwardalee edwardalee changed the title Input iterator Multiport iterator for more efficient access to sparse inputs Jul 20, 2022
Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

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

It left some nitpicks...

org.lflang/src/org/lflang/AttributeUtils.java Outdated Show resolved Hide resolved
test/C/src/multiport/Sparse.lf Outdated Show resolved Hide resolved
test/C/src/multiport/SparseFallback.lf Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/AttributeUtils.java Outdated Show resolved Hide resolved
edwardalee and others added 3 commits July 23, 2022 10:18
Co-authored-by: Marten Lohstroh <marten@berkeley.edu>
Co-authored-by: Marten Lohstroh <marten@berkeley.edu>
@edwardalee edwardalee merged commit 1c7924c into master Jul 23, 2022
@edwardalee edwardalee deleted the input-iterator branch July 23, 2022 19:50
@lhstrh lhstrh added the feature New feature label Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants