[OpenMP] Detect SPMD compatible kernels and execute them as such
authorJohannes Doerfert <johannes@jdoerfert.de>
Wed, 23 Jun 2021 21:33:49 +0000 (16:33 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Sat, 10 Jul 2021 23:44:25 +0000 (18:44 -0500)
commit514c033db1e0c237eccd56b9fc11fe05a6baff39
tree5967106c0bf8a2dd1cc7a4784672d59868fab573
parent8cb7d71355f9ca884efde1dfa03dc349fb890721
[OpenMP] Detect SPMD compatible kernels and execute them as such

In the spirit of TRegions [0], this patch analyzes a kernel and tracks
if it can be executed in SPMD-mode. If so, we flip the arguments of
the __kmpc_target_init and deinit call to enable the mode. We also
update the `<kernel>_exec_mode` flag to indicate to the runtime we
changed the mode to SPMD.

The code analysis is done interprocedurally by extending the
AAKernelInfo abstract attribute to track SPMD compatibility as well.

[0] https://link.springer.com/chapter/10.1007/978-3-030-28596-8_11

Differential Revision: https://reviews.llvm.org/D102307
clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
llvm/lib/IR/Assumptions.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/custom_state_machines.ll
llvm/test/Transforms/OpenMP/custom_state_machines_remarks.ll
llvm/test/Transforms/OpenMP/spmdization.ll [new file with mode: 0644]
llvm/test/Transforms/OpenMP/spmdization_remarks.ll [new file with mode: 0644]