This patch adds OMPIRBuilder support for the depend clause for the
task construct.
Details
Diff Detail
Event Timeline
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h | ||
---|---|---|
644 | There is some code duplication going on here. For example, this enum is basically copied from clang/include/clang/Basic/OpenMPKinds.def. I tried extracting this enum into llvm/include/llvm/Frontend/OpenMP/OMPConstants.h so that Clang can use it, but it seems that the OPENMP_DEPEND_KIND macro is complex and does not lend itself to a simple extraction. The macro is redefined in many different files. Any suggestions here would be appreciated. |
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h | ||
---|---|---|
210 | Do we need definition of OMPRTLDependenceKindTy and OpenMPDependKind ? It looks like these two class enums are overlapping. |
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h | ||
---|---|---|
210 | OMPRTLDependenceKindTy is to be used with the OMPRTL___kmpc_omp_task_with_deps runtime function to encode what kind of dependency a given clause is, whereas OpenMPDependKind is for the MLIR to encode what kind of dependency a given clause is. You could map them to the same thing, but IMO, it is better to keep them separate. llvm::OpenMPIRBuilder::OpenMPDependKind::OMP_DEPEND_out and llvm::OpenMPIRBuilder::OpenMPDependKind::OMP_DEPEND_inout happen to map to the same thing, OMPRTLDependenceKindTy::OMPDepInOut, which is what the translateDependencyKind function does, but I don't think it makes much sense to map them to the same thing at the MLIR level. IMO, they should be kept distinct. |
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h | ||
---|---|---|
210 | I doubt we want duplication. It doesn't buy as anything and introduces confusion. | |
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h | ||
644 | I don't understand the problem. Define all depend kinds similar to proc bind here https://github.com/llvm/llvm-project/blob/25162418c60475185cf29b5336015ca2f52ce3eb/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def#L1052 . Then use that to create the enum class in OMPConstants.h and use that enum class as well as the macro everywhere, including clang. | |
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
1516 | Is the insert point set to the right place for sure? | |
1551 | Generally, llvm:: inside llvm/ if we open the namespace anyway. |
- Remove unnecessary llvm:: from OMPIRBuilder.cpp
- Change the insertion point for DepArray alloca to be before the Then basic block for the if clause
- Use only one enum RTLDependenceKindInfoTy to encode the kind of dependency; use this enum in Clang
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h | ||
---|---|---|
644 | Thanks for the suggestion! However, if we don't want to have 2 enums, one for the clause and one for the RTL function, as you mentioned in one of your other comments (quoted below), then I can just define a singular enum in OMPConstants.h. IMO, this is simpler.
| |
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
1516 | Looking more closely at it, I think this should be inserted before the Then of the IfThenElse for the if clause, but then the OMPRTL___kmpc_omp_task_with_deps call should still be in the Then. |
Generally fine, I think. The alloca placement is the last bit that needs changing.
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h | ||
---|---|---|
644 | If these are all uses, I assume a fixed enum is good enough. | |
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
1441 | Same question as before. How do you ensure the alloca is placed where you want it (which is the function entry block). | |
1516 | The entire conditional here is a bad idea. We should pass the if-clause value to the runtime. This causes all sort of problems, but it's unrelated to this patch... |
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
1441 | Isn't the insertion point set on L1356 in OMPIRBuilder.cpp at the caller of the outlined function, i.e. the outlined function entry block? I thought it made sense to do the alloca in this same block, right after the __kmpc_omp_task_alloc. If not this one, which function entry block are you suggesting I should place the alloca in? |
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
1441 | Reading L1356, it looks like it is set to the call site of outlined function, which could be anywhere in current function, no? Allocas that only need to provide a single memory location for each function invocation should be placed in the function entry block. |
- Set insertion point for DependInfo array alloca to the function entry block, then restore the original insertion point
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
1441 | That makes sense. Thanks for the clarification. |
LG, one nit.
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h | ||
---|---|---|
651 | Add doxygen documentation for this class please. |
The enums above are enum class.