llvm-project/mlir/test
William S. Moses 973cb2c326 [MLIR][OMP] Ensure nested scf.parallel execute all iterations
Presently, the lowering of nested scf.parallel loops to OpenMP creates one omp.parallel region, with two (nested) OpenMP worksharing loops on the inside. When lowered to LLVM and executed, this results in incorrect results. The reason for this is as follows:

An OpenMP parallel region results in the code being run with whatever number of threads available to OpenMP. Within a parallel region a worksharing loop divides up the total number of requested iterations by the available number of threads, and distributes accordingly. For a single ws loop in a parallel region, this works as intended.

Now consider nested ws loops as follows:

omp.parallel {
   A: omp.ws %i = 0...10 {
      B: omp.ws %j = 0...10 {
          code(%i, %j)
      }
   }
}

Suppose we ran this on two threads. The first workshare loop would decide to execute iterations 0, 1, 2, 3, 4 on thread 0, and iterations 5, 6, 7, 8, 9 on thread 1. The second workshare loop would decide the same for its iteration. This means thread 0 would execute i \in [0, 5) and j \in [0, 5). Thread 1 would execute i \in [5, 10) and j \in [5, 10). This means that iterations i in [5, 10), j in [0, 5) and i in [0, 5), j in [5, 10) never get executed, which is clearly wrong.

This permits two options for a remedy:
1) Change the semantics of the omp.wsloop to be distinct from that of the OpenMP runtime call or equivalently #pragma omp for. This could then allow some lowering transformation to remedy the aforementioned issue. I don't think this is desirable for an abstraction standpoint.
2) When lowering an scf.parallel always surround the wsloop with a new parallel region (thereby causing the innermost wsloop to use the number of threads available only to it).

This PR implements the latter change.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D108426
2021-08-20 19:06:28 -04:00
..
Analysis [mlir] Set the namespace of the BuiltinDialect to 'builtin' 2021-07-28 21:00:10 +00:00
CAPI [mlir] Set the namespace of the BuiltinDialect to 'builtin' 2021-07-28 21:00:10 +00:00
Conversion [MLIR][OMP] Ensure nested scf.parallel execute all iterations 2021-08-20 19:06:28 -04:00
Dialect [mlir][linalg] Finish refactor of TC ops to YAML 2021-08-20 12:35:04 -07:00
Examples [MLIR] Fix Standalone dialect test to work in out-of-tree builds 2021-06-02 17:24:46 +00:00
IR [mlir] Allow to override type/attr aliases from various hooks 2021-08-06 12:05:31 +03:00
Integration [mlir][linalg] Finish refactor of TC ops to YAML 2021-08-20 12:35:04 -07:00
Interfaces Split `InferShapedTypeOpInterface` to create `ReifyRankedShapedTypeInterface`. 2021-07-19 14:44:52 -07:00
Pass [mlir] Set the namespace of the BuiltinDialect to 'builtin' 2021-07-28 21:00:10 +00:00
Rewrite [mlir][PDL] Add support for variadic operands and results in the PDL byte code 2021-03-16 13:20:19 -07:00
Target Recommit "[Matrix] Overload stride arg in matrix.columnwise.load/store." 2021-08-12 18:31:57 +01:00
Transforms [mlir] Support normalizing memrefs with MemRef_ReinterpretCastOp 2021-08-11 01:15:18 +05:30
Unit Revert "Attempt to disable MLIR JIT tests on PowerPC to unbreak the bot" 2021-06-29 18:03:23 -05:00
lib [mlir][Analysis][NFC] Split FlatAffineConstraints class 2021-08-17 10:09:17 +09:00
mlir-cpu-runner [mlir][CPURunner] Avoid a crash in memrefCopy when called with empty shapes. 2021-08-03 16:02:01 +02:00
mlir-linalg-ods-gen Revert "[mlir][Linalg] Allow all build methods of Structured ops to specify additional attributes." 2021-08-19 11:53:41 -07:00
mlir-lsp-server [mlir] Set the namespace of the BuiltinDialect to 'builtin' 2021-07-28 21:00:10 +00:00
mlir-opt [mlir] Set the namespace of the BuiltinDialect to 'builtin' 2021-07-28 21:00:10 +00:00
mlir-reduce [mlir-reduce] Reducer refactor. 2021-06-02 07:45:00 +08:00
mlir-spirv-cpu-runner [mlir] fix SPIR-V CPU and Vulkan runners after e2310704d8 2021-03-15 18:36:58 +01:00
mlir-tblgen [mlir][ods] Skip adding TOC in doc gen when present 2021-08-20 07:01:54 -07:00
mlir-translate [mlir] Print the correct tool name in mlirTranslateMain 2021-01-05 19:17:01 -08:00
mlir-vulkan-runner [mlir] fix SPIR-V CPU and Vulkan runners after e2310704d8 2021-03-15 18:36:58 +01:00
python [mlir][sparse][python] migrate more code from boilerplate into proper numpy land 2021-08-20 09:18:17 -07:00
APITest.h Mass update the MLIR license header to mention "Part of the LLVM project" 2020-01-26 03:58:30 +00:00
CMakeLists.txt Re-engineer MLIR python build support. 2021-07-27 15:54:58 +00:00
lit.cfg.py Re-engineer MLIR python build support. 2021-07-27 15:54:58 +00:00
lit.site.cfg.py.in [MLIR] Fix Standalone dialect test to work in out-of-tree builds 2021-06-02 17:24:46 +00:00