[OpenMPOpt] Merge parallel regions
authorGiorgis Georgakoudis <georgakoudis1@llnl.gov>
Tue, 7 Jul 2020 21:14:47 +0000 (14:14 -0700)
committerGiorgis Georgakoudis <georgakoudis1@llnl.gov>
Fri, 9 Oct 2020 16:59:04 +0000 (09:59 -0700)
commit3a6bfcf2f902341bb618c4d5e06b2b10d9f02c72
treeca0ee5d3d433578211c7a36f0c5a61ecd14b536e
parentc778f6c4f9d511023c0d71b9e14a90e60445d314
[OpenMPOpt] Merge parallel regions

There are cases that generated OpenMP code consists of multiple,
consecutive OpenMP parallel regions, either due to high-level
programming models, such as RAJA, Kokkos, lowering to OpenMP code, or
simply because the programmer parallelized code this way.  This
optimization merges consecutive parallel OpenMP regions to: (1) reduce
the runtime overhead of re-activating a team of threads; (2) enlarge the
scope for other OpenMP optimizations, e.g., runtime call deduplication
and synchronization elimination.

This implementation defensively merges parallel regions, only when they
are within the same BB and any in-between instructions are safe to
execute in parallel.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D83635
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/parallel_region_merging.ll [new file with mode: 0644]
llvm/test/Transforms/OpenMP/parallel_region_merging_legacy_pm.ll [new file with mode: 0644]