[PATCH] D88243: [OpenMP] OpenMPOpt Support for Globalization Remarks
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 09:54:37 PDT 2020
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
jhuber6 added projects: OpenMP, LLVM.
Herald added subscribers: llvm-commits, guansong, hiraditya, yaxunl.
jhuber6 requested review of this revision.
Herald added a subscriber: sstefan1.
This patch add support for printing analysis messages relating to data globalization on the GPU. This occurs when data is shared between the threads in a GPU context and must be pushed to global or shared memory.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88243
Files:
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -476,6 +476,12 @@
: M(*(*SCC.begin())->getParent()), SCC(SCC), CGUpdater(CGUpdater),
OREGetter(OREGetter), OMPInfoCache(OMPInfoCache), A(A) {}
+ /// Check if any remarks are enabled for openmp-opt
+ bool remarksEnabled() {
+ auto &Ctx = M.getContext();
+ return Ctx.getDiagHandlerPtr()->isAnyRemarkEnabled(DEBUG_TYPE);
+ }
+
/// Run all OpenMP optimizations on the underlying SCC/ModuleSlice.
bool run() {
if (SCC.empty())
@@ -503,6 +509,8 @@
Changed |= deleteParallelRegions();
if (HideMemoryTransferLatency)
Changed |= hideMemTransfersLatency();
+ if (remarksEnabled())
+ analysisGlobalization();
return Changed;
}
@@ -695,6 +703,27 @@
return Changed;
}
+ void analysisGlobalization() {
+ auto &RFI =
+ OMPInfoCache.RFIs[OMPRTL___kmpc_data_sharing_coalesced_push_stack];
+ for (Function *F : SCC) {
+ auto *UV = RFI.getUseVector(*F);
+ if (!UV)
+ return;
+ for (Use *U : *UV) {
+ if (CallInst *CI = getCallIfRegularCall(*U, &RFI)) {
+ auto Remark = [&](OptimizationRemarkAnalysis ORA) {
+ return ORA << "Found thread data sharing on the GPU. Expect "
+ << "degraded performance due to data globalization.";
+ };
+ emitRemark<OptimizationRemarkAnalysis>(CI, "OpenMPGlobalization",
+ Remark);
+ }
+ }
+ }
+ return;
+ }
+
/// Maps the values stored in the offload arrays passed as arguments to
/// \p RuntimeCall into the offload arrays in \p OAs.
bool getValuesInOffloadArrays(CallInst &RuntimeCall,
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -144,9 +144,11 @@
__OMP_TYPE(Void)
__OMP_TYPE(Int1)
__OMP_TYPE(Int8)
+__OMP_TYPE(Int16)
__OMP_TYPE(Int32)
__OMP_TYPE(Int64)
__OMP_TYPE(Int8Ptr)
+__OMP_TYPE(Int16Ptr)
__OMP_TYPE(Int32Ptr)
__OMP_TYPE(Int64Ptr)
@@ -500,6 +502,13 @@
__OMP_RTL(__kmpc_task_allow_completion_event, false, VoidPtr, IdentPtr,
/* Int */ Int32, /* kmp_task_t */ VoidPtr)
+__OMP_RTL(__kmpc_data_sharing_init_stack, false, Void, )
+__OMP_RTL(__kmpc_data_sharing_init_stack_spmd, false, Void, )
+__OMP_RTL(__kmpc_data_sharing_coalesced_push_stack, false, VoidPtr, SizeTy,
+ Int16)
+__OMP_RTL(__kmpc_data_sharing_push_stack, false, VoidPtr, SizeTy, Int16)
+__OMP_RTL(__kmpc_data_sharing_pop_stack, false, Void, VoidPtr)
+
/// Note that device runtime functions (in the following) do not necessarily
/// need attributes as we expect to see the definitions.
__OMP_RTL(__kmpc_kernel_parallel, false, Int1, VoidPtrPtr)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88243.294102.patch
Type: text/x-patch
Size: 2964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200924/da2369bc/attachment.bin>
More information about the llvm-commits
mailing list