Hi,
A new Fortran frontend (Flang) was recently accepted as part of the LLVM project. Since OpenMP API is available for both C and Fortran we are investigating whether Flang and Clang can share the OpenMP codegen part. There is a proposal (OpenMP IRBuilder, https://reviews.llvm.org/D61953, https://reviews.llvm.org/D61964) which generates LLVMIR for OpenMP constructs. This proposal would move existing OpenMP LLVM IR generation code from Clang to LLVM so that it can be used by other frontends too.
An MLIR dialect (FIR) is planned for Flang. To use the OpenMP IRBuilder from MLIR I was exploring the possibility of adding OpenMP regions as operations in the LLVM dialect. If this is possible then the plan was to lower these regions to outlined LLVM IR code while converting the dialect to LLVM IR using the OpenMP IRBuilder. The existing LLVM dialect seems to be a wrapper over LLVM instructions and uses the LLVM IR builder internally. Is there a design decision to keep the LLVM dialect as close to the LLVM IR as possible? And hence regions inside operations/closures will not be allowed in the LLVM dialect? Nested regions were recommended for OpenMP abstractions in MLIR presentations. I can guess that the recommendation might have been for a separate OpenMP dialect and when the OpenMP dialect is lowered to the LLVM dialect it will just have calls to OpenMP runtime functions. But this approach might prevent usage of the OpenMP IR Builder and sharing of code with Clang in the current state.
Looking forward to suggestions and feedback on how to go about adding OpenMP support in MLIR with an eye on sharing code with Clang in its current state.
Thanks in advance,
Kiran
Hi,
A new Fortran frontend (Flang) was recently accepted as part of the LLVM project. Since OpenMP API is available for both C and Fortran we are investigating whether Flang and Clang can share the OpenMP codegen part. There is a proposal (OpenMP IRBuilder, https://reviews.llvm.org/D61953, https://reviews.llvm.org/D61964) which generates LLVMIR for OpenMP constructs. This proposal would move existing OpenMP LLVM IR generation code from Clang to LLVM so that it can be used by other frontends too.
An MLIR dialect (FIR) is planned for Flang. To use the OpenMP IRBuilder from MLIR I was exploring the possibility of adding OpenMP regions as operations in the LLVM dialect.
If this is possible then the plan was to lower these regions to outlined LLVM IR code while converting the dialect to LLVM IR using the OpenMP IRBuilder. The existing LLVM dialect seems to be a wrapper over LLVM instructions and uses the LLVM IR builder internally. Is there a design decision to keep the LLVM dialect as close to the LLVM IR as possible? And hence regions inside operations/closures will not be allowed in the LLVM dialect? Nested regions were recommended for OpenMP abstractions in MLIR presentations. I can guess that the recommendation might have been for a separate OpenMP dialect and when the OpenMP dialect is lowered to the LLVM dialect it will just have calls to OpenMP runtime functions. But this approach might prevent usage of the OpenMP IR Builder and sharing of code with Clang in the current state.
Looking forward to suggestions and feedback on how to go about adding OpenMP support in MLIR with an eye on sharing code with Clang in its current state.
--
You received this message because you are subscribed to the Google Groups "MLIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/CANF-O%3DY4isQ%2BTUTxU8HPYCMhU3fKuxkwGMRcRGszrrRHrN0mSg%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ml...@tensorflow.org.
Thanks, Mehdi and Alex for your suggestions and opinion.
Alex, I was kind of thinking that the LLVM dialect of MLIR will be the last stop in MLIR before conversion to LLVM IR.
From your answer, it seems that this is not a requirement. To confirm, Are you are saying that the final code in MLIR will contain both OpenMP dialect and LLVM dialect? and they will be lowered to LLVM IR by using a translation library which can make use of the existing LLVM IR translation library and the OpenMP IR Builder.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/903b2f85-e4f8-4544-8337-aa11b8dd762c%40tensorflow.org.
Thanks, Mehdi and Alex for your suggestions and opinion.
Alex, I was kind of thinking that the LLVM dialect of MLIR will be the last stop in MLIR before conversion to LLVM IR. From your answer, it seems that this is not a requirement. To confirm, Are you are saying that the final code in MLIR will contain both OpenMP dialect and LLVM dialect? and they will be lowered to LLVM IR by using a translation library which can make use of the existing LLVM IR translation library and the OpenMP IR Builder.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/903b2f85-e4f8-4544-8337-aa11b8dd762c%40tensorflow.org.
On Jul 2, 2019, at 7:54 AM, Mehdi AMINI <joke...@gmail.com> wrote:On Tue, Jul 2, 2019 at 5:41 AM Kiran Chandramohan <kirancha...@gmail.com> wrote:Thanks, Mehdi and Alex for your suggestions and opinion.
Alex, I was kind of thinking that the LLVM dialect of MLIR will be the last stop in MLIR before conversion to LLVM IR. From your answer, it seems that this is not a requirement. To confirm, Are you are saying that the final code in MLIR will contain both OpenMP dialect and LLVM dialect? and they will be lowered to LLVM IR by using a translation library which can make use of the existing LLVM IR translation library and the OpenMP IR Builder.To clarify, I wasn’t suggesting anything different when I wrote:> I'm also interested to see if we could model the OpenMP construct in an dialect orthogonal to the LLVM dialect and be able to re-use them with other dialects (like standard ops.And even if we can’t have OpenMP constructs that are independent of the LLVM dialect (types for instance), I would still create a separate dialect anyway.
--
You received this message because you are subscribed to the Google Groups "MLIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/39FA7ED1-D7F8-4ECA-A906-C4FE4542C578%40google.com.
Just a quick question to clarify the result of the conversation for me:It seems, MLIR folks also feel that the (yet to be implemented) OpenMP IRBuilder should be (re)usable to create OpenMP runtime calls from some MLIR OpenMP dialect, assuming the dialect retains information about the OpenMP directives and clauses. Is that correct?
(The OpenMP IRBuilder prototype, design principles etc. can be found behind the links in the first email.)Thanks,Johannes
On Sun, Jul 7, 2019 at 2:37 PM 'Chris Lattner' via MLIR <ml...@tensorflow.org> wrote:
--On Jul 2, 2019, at 7:54 AM, Mehdi AMINI <joke...@gmail.com> wrote:On Tue, Jul 2, 2019 at 5:41 AM Kiran Chandramohan <kirancha...@gmail.com> wrote:Thanks, Mehdi and Alex for your suggestions and opinion.
Alex, I was kind of thinking that the LLVM dialect of MLIR will be the last stop in MLIR before conversion to LLVM IR. From your answer, it seems that this is not a requirement. To confirm, Are you are saying that the final code in MLIR will contain both OpenMP dialect and LLVM dialect? and they will be lowered to LLVM IR by using a translation library which can make use of the existing LLVM IR translation library and the OpenMP IR Builder.To clarify, I wasn’t suggesting anything different when I wrote:> I'm also interested to see if we could model the OpenMP construct in an dialect orthogonal to the LLVM dialect and be able to re-use them with other dialects (like standard ops.And even if we can’t have OpenMP constructs that are independent of the LLVM dialect (types for instance), I would still create a separate dialect anyway.+1. The OpenMP dialect should be relatively orthogonal to the types of operations it contains. Those operations could be at the LLVM IR level, but could also be at the C or Fortran level. The point in time in which the parallelism abstraction is lowered to openmp library calls should be separable from when/how the constructs inside the parallel regions are lowered.The affine dialect works the same way, and I think this is a good strategy to continue.-Chris
You received this message because you are subscribed to the Google Groups "MLIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ml...@tensorflow.org.
To unsubscribe from this group and stop receiving emails from it, send an email to ml...@tensorflow.org.
Would that mean that in a JIT context, we could directly use the OpenMP IR dialect without having to reimplement our own threading library for CPU targets?
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/bbd7d99e-5e27-479c-9c12-13c3a55abe34%40tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/bbd7d99e-5e27-479c-9c12-13c3a55abe34%40tensorflow.org.