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

MLIR::loopUnrollByFactor fails for small loops #1556

Closed
AndraBisca opened this issue Jun 14, 2024 · 2 comments · Fixed by #1568
Closed

MLIR::loopUnrollByFactor fails for small loops #1556

AndraBisca opened this issue Jun 14, 2024 · 2 comments · Fixed by #1568

Comments

@AndraBisca
Copy link
Collaborator

AndraBisca commented Jun 14, 2024

After #1545 designs with loops that have less iterations than the unroll factor fail silently.

It was caught by one of @eddierichter-amd designs.

The example here shows this error and expected output. The loop has 4 iterations and the unroll factor is 6.

@jtuyls

@makslevental
Copy link
Contributor

You can use this to compute the trip count of an scf.for with static bounds and step: https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h#L175.

@makslevental
Copy link
Contributor

makslevental commented Jun 14, 2024

          if (!forLoop.getSingleLowerBound() ||
              !forLoop.getSingleUpperBound() || !forLoop.getSingleStep() ||
              constantTripCount(*forLoop.getSingleLowerBound(),
                                *forLoop.getSingleUpperBound(),
                                *forLoop.getSingleStep())
                      .value_or(0) < unrollFactor)
            forLoop.emitOpError()
                << "could not be unrolled because tripcount < unrollFactor: "
                << unrollFactor << "\n"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants