This is an archive of the discontinued LLVM Phabricator instance.

OpenMP Canonical Loop Operation for OMP Dialect (WIP)
Needs ReviewPublic

Authored by abidmalikwaterloo on Apr 5 2023, 1:10 PM.



This is a Work In Progress.
The patch define the OpenMP Canonical Operation for OpenMP MLIR Dialect

Diff Detail

Event Timeline

abidmalikwaterloo requested review of this revision.Apr 5 2023, 1:10 PM

Do we need LoopControlCanonical for canonical operation? The current is Fortran-style and may not exactly match the naive C/C++ for-stmt.


Depends on what is the value that is returned. What value are you expecting to return here?


Try to reuse the same loop control unless you need a different one.

You might also want to discuss whether the loop should unit step forward counting as in the OpenMP IRBuilder or general like in the current LoopControl.

abidmalikwaterloo added inline comments.

@Meinersbur @kiranchandramohan My understanding is that the return result is an array of loop features that are OpenMP canonicalized. We can have ArrayAttr. We need Variadic because loop nesting can be variable.


@Meinersbur Please see the comments for the increment.
@kiranchandramohan We need a conditional variable to take care of C/C++

for (init-expr; test-expr; incr-expr) structured-block

We can add an optional condition variable for this format in the LoopControl.

Meinersbur added inline comments.May 24 2023, 11:27 AM

Personally, I would only make it take the trip count N with normalized %iv = 0...N-1 and let the Frontend handle all language semantics (is ub inclusive?, negative step, integer overflow, non-integer iteration variables, ...). It also simplifies mid-end passes since they only have to handle this normalized form.

However, for omp.wsloop the Fortran people had strong opinion that we should represent lb/ub/step explicitly. IMHO it only makes the MLIR representation more complex. Apart from edge cases (lb=INT_MIN, ub=INT_MAX) it more expressive than the normalized way, so I am willing to compromise.

kiranchandramohan added a subscriber: do.

@abidmalikwaterloo What is the plan here? Would @do or @Meinersbur be taking over this patch? Do you have a timeline?

@abidmalikwaterloo What is the plan here? Would @do or @Meinersbur be taking over this patch? Do you have a timeline?

@kiranchandramohan I am working on this with the help of @Meinersbur . I am aiming to wind up this ASAP.