[PATCH] D116292: [OMPIRBuilder][MLIR] Support ordered clause specified with parameter

Peixin Qiao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 27 01:15:17 PST 2021


peixin added a comment.

To make the review work easier, I would like to give a brief explanation of the design of OMPIRBuilder of ordered clause with parameter. First of all, the ordered clause cannot work alone to make the code region execute in order. The ordered clause and ordered construct must cooperate to make the code region executing in order. For ordered clause specified with a paramter, the outer n (the parameter) loops form the doacross loop nest and OpenMP runtime function `kmpc_doacross_init` is generated to initialize the loop bounds info of the doacross loop nest. For ordered construct with depend clause, it posts/waits the corresponding thread id according to the index specified in ordered depend directive.

Clang transforms the doacross loop nest into a new one with lower bound of 0 and step of 1. However, this is really not necessary. OpenMP runtime can handle the doacross loop nest regardless of positive or negative step https://github.com/llvm/llvm-project/blob/7c3cf4c2c0689be1a08b8a1326703ec5770de471/openmp/runtime/src/kmp_csupport.cpp#L4050-L4058. The doacross loop nest is independent of worksharing-loop.

When lowering parse-tree to MLIR (https://github.com/flang-compiler/f18-llvm-project/pull/1370/commits/75a8db9c0f7f8c21c2720a794a46afc950ccd0ff), the loop bounds info of lower bounds, upper bounds and steps of the doacross loop nest is collected. The loop bounds info can be taken as the fourth argument of `kmpc_doacross_init` call directly, and using the expression value of ordered depend directive as the argument of `kmpc_doacross_wait/post` will make it work (https://github.com/flang-compiler/f18-llvm-project/pull/1368).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116292/new/

https://reviews.llvm.org/D116292



More information about the llvm-commits mailing list