[PATCH] D110286: [WIP][Clang][OpenMP] Add new clang argument `-fopenmp-target-simd`

Shilei Tian via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 22 13:11:25 PDT 2021


tianshilei1992 created this revision.
Herald added subscribers: dexonsmith, dang, guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Currently an OpenMP thread is mapped to a hardware thread. In order to support
SIMD, we have to map an OpenMP thread to a warp (wavefront). This mapping has to
be determined when the kernel is launched, and the execution mode is encoded in
the `int8_t Mode` when calling `__kmpc_target_init`, which is introduced in
D110279 <https://reviews.llvm.org/D110279>. However, we cannot determine if `simd` is used and then adjust `Mode`
accordingly in current Clang CodeGen because the function call to
`__kmpc_target_init` is emitted before the body of target region.

This patches adds a new clang argument `-fopenmp-target-simd` to emit code that
supports SIMD mapping. When this argument is set, no matter whether there is
`simd` directive in target region, the new mappig is always used. If it is not
set or `-fopenmp-no-target-simd` is set, the existing mapping will be used, and
`simd` directive will be ignored.

The reason we don't reuse `-fopenmp-simd` is the CodeGen of device code shares
some implementation with host code. `-fopenmp-simd` can change CodeGen, which we
don't expect to introduce any unknown effects.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110286

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110286.374341.patch
Type: text/x-patch
Size: 5688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210922/3cfec756/attachment-0001.bin>


More information about the cfe-commits mailing list