Skip to content

Commit c5431df

Browse files
committed
Fixed description of sparse inputs
1 parent 949897f commit c5431df

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

docs/assets/code/c/src/Sparse.lf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
target C;
22
reactor Sparse {
3-
@sparse
4-
input[100] in:int;
3+
input[100] in: int
54
reaction(in) {=
65
// Create an iterator over the input channels.
76
struct lf_multiport_iterator_t i = lf_multiport_iterator(in);

docs/writing-reactors/multiports-and-banks.mdx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,13 @@ In the Python target, multiports can be iterated on in a for loop (e.g., `for p
8484

8585
Sometimes, a program needs a wide multiport input, but when reactions are triggered by this input, few of the channels are present.
8686
In this case, it can be inefficient to iterate over all the channels to determine which are present.
87-
If you know that a multiport input will be **sparse** in this way, then you can provide a hint to the compiler and use a more efficient iterator to access the port. For example:
87+
If you know that a multiport input will be **sparse** in this way, then you can use a more efficient iterator to access the port. For example:
8888

8989
import C_Sparse from '../assets/code/c/src/Sparse.lf';
9090

9191
<NoSelectorTargetCodeBlock c={C_Sparse} lf />
9292

93-
Notice the `@sparse` annotation on the input declaration.
94-
This provides a hint to the compiler to optimize for sparse inputs.
95-
Then, instead of iterating over all input channels, this code uses the built-in function `lf_multiport_iterator()` to construct an iterator. The function `lf_multiport_next()` returns the first (and later, the next) channel index that is present. It returns -1 when no more channels have present inputs.
96-
97-
The multiport iterator can be used for any input multiport, even if it is not marked sparse.
98-
But if it is not marked sparse, then the `lf_multiport_next()` function will not optimize for sparse inputs and will simply iterate over the channels until it finds one that is present.
93+
Instead of iterating over all input channels, this code uses the built-in function `lf_multiport_iterator()` to construct an iterator. The function `lf_multiport_next()` returns the first (and later, the next) channel index that is present. It returns -1 when no more channels have present inputs.
9994

10095
</ShowOnly>
10196

versioned_docs/version-0.8.0/assets/code/c/src/Sparse.lf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
target C;
22
reactor Sparse {
3-
@sparse
43
input[100] in:int;
54
reaction(in) {=
65
// Create an iterator over the input channels.

versioned_docs/version-0.8.0/writing-reactors/multiports-and-banks.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ import C_Sparse from '../assets/code/c/src/Sparse.lf';
9090

9191
<NoSelectorTargetCodeBlock c={C_Sparse} lf />
9292

93-
Notice the `@sparse` annotation on the input declaration.
94-
This provides a hint to the compiler to optimize for sparse inputs.
95-
Then, instead of iterating over all input channels, this code uses the built-in function `lf_multiport_iterator()` to construct an iterator. The function `lf_multiport_next()` returns the first (and later, the next) channel index that is present. It returns -1 when no more channels have present inputs.
96-
97-
The multiport iterator can be used for any input multiport, even if it is not marked sparse.
98-
But if it is not marked sparse, then the `lf_multiport_next()` function will not optimize for sparse inputs and will simply iterate over the channels until it finds one that is present.
93+
Instead of iterating over all input channels, this code uses the built-in function `lf_multiport_iterator()` to construct an iterator. The function `lf_multiport_next()` returns the first (and later, the next) channel index that is present. It returns -1 when no more channels have present inputs.
9994

10095
</ShowOnly>
10196

0 commit comments

Comments
 (0)