Skip to content

Commit

Permalink
Additional advice when setting up HWLoops.
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Gouedo <[email protected]>
  • Loading branch information
Pascal Gouedo committed Jan 8, 2024
1 parent 308c5b6 commit b7abe3a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/source/corev_hw_loop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ Below an assembly code example of a nested HWLoop that computes a matrix additio
asm volatile (
"add %[i],x0, x0;"
"add %[j],x0, x0;"
"cv.count 1, %[N];"
".balign 4;"
"cv.endi 1, endO;"
"cv.starti 1, startO;"
"cv.count 1, %[N];"
"any instructions here"
".balign 4;"
"cv.endi 0, endZ;"
Expand All @@ -128,6 +128,7 @@ Below an assembly code example of a nested HWLoop that computes a matrix additio
: [N] "r" (10)
);
As HWLoop feature is enabled as soon as lpcountX > 0, it is a good practice to set lpstartX and lpendX **before** lpcountX to avoid unexpected behavior. For HWLoop where body contains up to 30 instructions, it is always better to use cv.setup* instructions which are updating all 3 HWLoop CSRs in the same cycle.

At the beginning of the HWLoop, the registers %[i] and %[j] are 0.
The innermost loop, from startZ to (endZ - 4), adds to %[i] three times 1 and
Expand Down

3 comments on commit b7abe3a

@jstraus59
Copy link

Choose a reason for hiding this comment

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

It seems problematic to indicate that not following this can result in "unexpected behavior", but to only describe it as "a good practice".
Perhaps this should be an additional constraint: lpstart and lpend may be changed only when the corresponding lpcount is 0?

@pascalgouedo
Copy link

Choose a reason for hiding this comment

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

Perhaps this should be an additional constraint: lpstart and lpend may be changed only when the corresponding lpcount is 0?

There is nothing in the design to enforce that.

@jstraus59
Copy link

Choose a reason for hiding this comment

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

There is nothing in the design to enforce that.

There is nothing in the design to enforce any of the HW Loop constraints, so I don't understand why this is an issue for adding this additional constraint?

Please sign in to comment.