This patch adds code emission in emitTargetCall to call the OpenMP runtime to launch an kernel, and to call the fallback host implementation if the launch fails.
Details
Diff Detail
Event Timeline
Fixes from review feedback. Rebase.
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
4390 | Even if it is, it should not be part of this patch. I will remove it. Good catch. | |
4403 | It should be the equivalent of llvm::Value *NumThreads = OMPRuntime->emitNumThreadsForTargetDirective(CGF, D); in clang, which looks a bit involved, but is essentially ThreadLimit from what I can tell. |
This patch adds code emission in emitTargetCall to call the OpenMP runtime to launch an kernel, and to call the fallback host implementation if the launch fails.
This is not visible in the IR generated from MLIR. Could you add a test?
Also could @TIFitis review this patch?
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
4411 | Expand type here. | |
4416 | This allows debug info to be accurately generated. | |
4452–4455 | No need to explicitly specify OpenMPIRBuilder namespace here. | |
4453 | Same, remove explicit namespace. | |
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp | ||
5077–5078 | Maybe we can replace this with OMPBuilder.getOrCreateDefaultSrcLocStr? Also it is fine to leave the Names empty if not available. | |
5084 | Can you please check if this works with function arguments? AFAIK getTypeAllocSize doesn't work on function arguments, in that case we might want to move this function as a callback to MLIR. |
I have not gone through the patch in detail. If you feel the patch is in good shape and @jdoerfert has not further comments you may go ahead.
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp | ||
---|---|---|
5137–5154 | Nit: leftover debug? |
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp | ||
---|---|---|
5137–5154 |
Yes, thank you for finding that. I will remove this and update the parameter names CreateDefaultMapInfos. |
Is the AllocaIP expected to be used later?