[PATCH] D78299: [OpenMPOpt] deduplicateRuntimeCalls(): avoid traditional map lookup pitfall

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 07:48:34 PDT 2020


lebedev.ri created this revision.
lebedev.ri added reviewers: jdoerfert, hfinkel.
lebedev.ri added a project: LLVM.
Herald added subscribers: guansong, hiraditya, yaxunl.

This roughly halves time spent in that pass,
while unsurprisingly significantly reducing total memory usage.

This makes sense because most functions won't use any openmp functions..

old

  0.2329 (  0.5%)   0.0409 (  0.9%)   0.2738 (  0.5%)   0.2736 (  0.5%)  OpenMP specific optimizations

  total runtime: 63.32s.
  bytes allocated in total (ignoring deallocations): 8.34GB (131.70MB/s)
  calls to allocation functions: 14526259 (229410/s)
  temporary memory allocations: 3335760 (52680/s)
  peak heap memory consumption: 324.36MB
  peak RSS (including heaptrack overhead): 5.39GB
  total memory leaked: 289.93MB

new

  0.1457 (  0.3%)   0.0276 (  0.6%)   0.1732 (  0.3%)   0.1731 (  0.3%)  OpenMP specific optimizations

  total runtime: 55.01s.
  bytes allocated in total (ignoring deallocations): 6.70GB (121.89MB/s)
  calls to allocation functions: 14268205 (259398/s)
  temporary memory allocations: 3225355 (58637/s)
  peak heap memory consumption: 324.09MB
  peak RSS (including heaptrack overhead): 5.39GB
  total memory leaked: 289.87MB

diff

  total runtime: -8.31s.
  bytes allocated in total (ignoring deallocations): -1.63GB (196.58MB/s)
  calls to allocation functions: -258054 (31034/s)
  temporary memory allocations: -110405 (13277/s)
  peak heap memory consumption: -262.36KB
  peak RSS (including heaptrack overhead): 0B
  total memory leaked: -61.45KB


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78299

Files:
  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
@@ -248,7 +248,11 @@
   /// \p ReplVal if given.
   bool deduplicateRuntimeCalls(Function &F, RuntimeFunctionInfo &RFI,
                                Value *ReplVal = nullptr) {
-    auto &Uses = RFI.UsesMap[&F];
+    auto UsesIt = RFI.UsesMap.find(&F);
+    if (UsesIt == RFI.UsesMap.end())
+      return false;
+
+    auto &Uses = UsesIt->getSecond();
     if (Uses.size() + (ReplVal != nullptr) < 2)
       return false;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78299.258046.patch
Type: text/x-patch
Size: 625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/9072e041/attachment.bin>


More information about the llvm-commits mailing list