[all-commits] [llvm/llvm-project] 2c941f: [OpenMP][deviceRTLs] Fix wrong return value of `__...

Shilei Tian via All-commits all-commits at lists.llvm.org
Sat Oct 16 09:58:41 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2c941fa2f9b9a93b42bdddc810a817b02a937b55
      https://github.com/llvm/llvm-project/commit/2c941fa2f9b9a93b42bdddc810a817b02a937b55
  Author: Shilei Tian <tianshilei1992 at gmail.com>
  Date:   2021-10-16 (Sat, 16 Oct 2021)

  Changed paths:
    M openmp/libomptarget/deviceRTLs/common/src/omptarget.cu

  Log Message:
  -----------
  [OpenMP][deviceRTLs] Fix wrong return value of `__kmpc_is_spmd_exec_mode`

D110279 introduced a bug to the device runtime. In `__kmpc_parallel_51`, we detect
whether we are already in parallel region by `__kmpc_parallel_level() > __kmpc_is_spmd_exec_mode()`.
It is based on the assumption that:
- In SPMD mode, parallel level is initialized to 1.
- In generic mode, parallel level is initialized to 0.
- `__kmpc_is_spmd_exec_mode` returns `1` for SPMD mode, 0 otherwise.

Because the return value type of `__kmpc_is_spmd_exec_mode` is `int8_t`, there
was an implicit cast from `bool` to `int8_t`. We can make sure it is either 0 or
1 since C++14. In D110279, the return value is the result of an `and` operation,
which is 2 in SPMD mode. This breaks the assumption in `__kmpc_parallel_51`.

Reviewed By: carlo.bertolli, dpalermo

Differential Revision: https://reviews.llvm.org/D111905




More information about the All-commits mailing list